|
1 |
| -import*asReactfrom"react" |
2 |
| -import{Slot}from"@radix-ui/react-slot" |
3 |
| -import{cva,typeVariantProps}from"class-variance-authority" |
| 1 | +import{Slot}from"@radix-ui/react-slot"; |
| 2 | +import{typeVariantProps,cva}from"class-variance-authority"; |
| 3 | +import*asReactfrom"react"; |
4 | 4 |
|
5 |
| -import{cn}from"@/lib/utils" |
| 5 | +import{cn}from"@/lib/utils"; |
6 | 6 |
|
7 | 7 | constbuttonVariants=cva(
|
8 |
| -"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", |
9 |
| -{ |
10 |
| -variants:{ |
11 |
| -variant:{ |
12 |
| -default: |
13 |
| -"bg-primary text-primary-foreground shadow hover:bg-primary/90", |
14 |
| -destructive: |
15 |
| -"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", |
16 |
| -outline: |
17 |
| -"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", |
18 |
| -secondary: |
19 |
| -"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", |
20 |
| -ghost:"hover:bg-accent hover:text-accent-foreground", |
21 |
| -link:"text-primary underline-offset-4 hover:underline", |
22 |
| -}, |
23 |
| -size:{ |
24 |
| -default:"h-9 px-4 py-2", |
25 |
| -sm:"h-8 rounded-md px-3 text-xs", |
26 |
| -lg:"h-10 rounded-md px-8", |
27 |
| -icon:"h-9 w-9", |
28 |
| -}, |
29 |
| -}, |
30 |
| -defaultVariants:{ |
31 |
| -variant:"default", |
32 |
| -size:"default", |
33 |
| -}, |
34 |
| -} |
35 |
| -) |
| 8 | +"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 border-0 font-semibold", |
| 9 | +{ |
| 10 | +variants:{ |
| 11 | +variant:{ |
| 12 | +default: |
| 13 | +"bg-surface-invert-primary text-content-invert hover:bg-surface-invert-secondary", |
| 14 | +outline: |
| 15 | +"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground", |
| 16 | +subtle: |
| 17 | +"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80", |
| 18 | +warning: |
| 19 | +"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90", |
| 20 | +}, |
| 21 | +size:{ |
| 22 | +default:"h-10 px-3 py-2", |
| 23 | +sm:"h-8 px-2 text-xs", |
| 24 | +}, |
| 25 | +}, |
| 26 | +defaultVariants:{ |
| 27 | +variant:"default", |
| 28 | +size:"default", |
| 29 | +}, |
| 30 | +}, |
| 31 | +); |
36 | 32 |
|
37 | 33 | exportinterfaceButtonProps
|
38 |
| -extendsReact.ButtonHTMLAttributes<HTMLButtonElement>, |
39 |
| -VariantProps<typeofbuttonVariants>{ |
40 |
| -asChild?:boolean |
| 34 | +extendsReact.ButtonHTMLAttributes<HTMLButtonElement>, |
| 35 | +VariantProps<typeofbuttonVariants>{ |
| 36 | +asChild?:boolean; |
41 | 37 | }
|
42 | 38 |
|
43 | 39 | constButton=React.forwardRef<HTMLButtonElement,ButtonProps>(
|
44 |
| -({ className, variant, size, asChild=false, ...props},ref)=>{ |
45 |
| -constComp=asChild ?Slot :"button" |
46 |
| -return( |
47 |
| -<Comp |
48 |
| -className={cn(buttonVariants({ variant, size, className}))} |
49 |
| -ref={ref} |
50 |
| -{...props} |
51 |
| -/> |
52 |
| -) |
53 |
| -} |
54 |
| -) |
55 |
| -Button.displayName="Button" |
| 40 | +({ className, variant, size, asChild=false, ...props},ref)=>{ |
| 41 | +constComp=asChild ?Slot :"button"; |
| 42 | +return( |
| 43 | +<Comp |
| 44 | +className={cn(buttonVariants({ variant, size, className}))} |
| 45 | +ref={ref} |
| 46 | +{...props} |
| 47 | +/> |
| 48 | +); |
| 49 | +}, |
| 50 | +); |
| 51 | +Button.displayName="Button"; |
56 | 52 |
|
57 |
| -export{Button,buttonVariants} |
| 53 | +export{Button,buttonVariants}; |