Skip to content

Commit 0f47bf6

Browse files
authored
fix: UI Alignments (#1010)
1 parent a911a8c commit 0f47bf6

51 files changed

Lines changed: 11623 additions & 9230 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1+
import { Slot } from '@radix-ui/react-slot'
12
import { cva, type VariantProps } from 'class-variance-authority'
23
import * as React from 'react'
34

45
import { cn } from '@ui/lib'
56

67
const badgeVariants = cva(
7-
'inline-flex items-center rounded-md border text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
8+
'inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 rounded-md border text-xs font-semibold gap-1 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 [&>svg]:pointer-events-none',
89
{
910
variants: {
1011
variant: {
1112
default: 'border-transparent bg-brand text-brand-foreground shadow hover:bg-brand/80',
12-
brand: 'border-transparent bg-brand text-brand-foreground shadow hover:bg-brand/80',
1313
warning: 'border-transparent bg-warning text-warning-foreground shadow hover:bg-warning/80',
1414
success: 'border-transparent bg-success text-success-foreground shadow hover:bg-success/80',
15-
primary: 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
1615
secondary:
1716
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
1817
destructive:
1918
'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
2019
outline: 'text-foreground',
20+
ghost: 'border-dashed border-muted-foreground/50 text-muted-foreground bg-transparent',
2121
},
2222
size: {
2323
sm: 'px-1.5 py-0 text-xs',
@@ -32,11 +32,16 @@ const badgeVariants = cva(
3232
)
3333

3434
export interface BadgeProps
35-
extends React.HTMLAttributes<HTMLDivElement>,
36-
VariantProps<typeof badgeVariants> {}
35+
extends React.HTMLAttributes<HTMLElement>,
36+
VariantProps<typeof badgeVariants> {
37+
asChild?: boolean
38+
}
3739

38-
function Badge({ className, variant, size, ...props }: BadgeProps) {
39-
return <div className={cn(badgeVariants({ variant, size }), className)} {...props} />
40+
function Badge({ className, variant, size, asChild = false, ...props }: BadgeProps) {
41+
const Comp = asChild ? Slot : 'span'
42+
return (
43+
<Comp data-slot="badge" className={cn(badgeVariants({ variant, size }), className)} {...props} />
44+
)
4045
}
4146

4247
export { Badge, badgeVariants }

0 commit comments

Comments
 (0)