@@ -3,12 +3,9 @@ import { Slot } from "@radix-ui/react-slot";
3
3
import { type VariantProps , cva , cn } from "@/utils/classes" ;
4
4
5
5
const buttonVariants = cva (
6
- "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-80" ,
6
+ "group relative grid overflow-hidden duration-300 inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-80 " ,
7
7
{
8
8
variants : {
9
- variant : {
10
- sparkle : "" ,
11
- } ,
12
9
size : {
13
10
default : "h-10 px-4 py-2" ,
14
11
sm : "h-9 rounded-md px-3" ,
@@ -17,7 +14,6 @@ const buttonVariants = cva(
17
14
} ,
18
15
} ,
19
16
defaultVariants : {
20
- variant : "sparkle" ,
21
17
size : "default" ,
22
18
} ,
23
19
}
@@ -29,44 +25,24 @@ export interface ButtonProps
29
25
asChild ?: boolean ;
30
26
}
31
27
32
- const Button = React . forwardRef < HTMLButtonElement , ButtonProps > (
33
- ( { className, variant , size, asChild = false , ...props } , ref ) => {
28
+ const SparkleButton = React . forwardRef < HTMLButtonElement , ButtonProps > (
29
+ ( { className, size, asChild = false , ...props } , ref ) => {
34
30
const Comp = asChild ? Slot : "button" ;
35
- if ( variant === "sparkle" ) {
36
- return (
37
- < button
38
- className = { cn (
39
- "group relative grid overflow-hidden rounded-full duration-300" ,
40
- buttonVariants ( { size, className } )
41
- ) }
42
- >
43
- < span >
44
- < span
45
- className = { cn (
46
- "spark mask-gradient animate-flip before:animate-rotate absolute inset-0 h-[100%] w-[100%] overflow-hidden rounded-lg [mask:linear-gradient(white,_transparent_50%)] before:absolute before:aspect-square before:w-[200%] before:rotate-[-90deg] before:bg-[conic-gradient(from_0deg,transparent_0_340deg,white_360deg)] before:content-[''] before:[inset:0_auto_auto_50%] before:[translate:-50%_-15%]" ,
47
- { "rounded-full" : size === "sm" }
48
- ) }
49
- />
50
- </ span >
31
+ return (
32
+ < Comp ref = { ref } className = { cn ( buttonVariants ( { size } ) , className ) } >
33
+ < span >
51
34
< span
52
35
className = { cn (
53
- "backdrop absolute inset-[1px] rounded-md bg-secondary transition-colors duration-200 group-hover:bg-primary" ,
54
- { "rounded-full" : size === "sm" }
36
+ "absolute inset-0 h-[100%] w-[100%] animate-flip overflow-hidden rounded-lg [mask:linear-gradient(white,_transparent_50%)] before:absolute before:aspect-square before:w-[200%] before:rotate-[-90deg] before:animate-rotate before:bg-[conic-gradient(from_0deg,transparent_0_340deg,white_360deg)] before:content-[''] before:[inset:0_auto_auto_50%] before:[translate:-50%_-15%]"
55
37
) }
56
38
/>
57
- < span className = "z-10" > { props . children } </ span >
58
- </ button >
59
- ) ;
60
- }
61
- return (
62
- < Comp
63
- className = { cn ( buttonVariants ( { variant, size, className } ) ) }
64
- ref = { ref }
65
- { ...props }
66
- />
39
+ </ span >
40
+ < span className = "backdrop absolute inset-[1px] rounded-md bg-secondary transition-colors duration-200" />
41
+ < span className = "z-10" > { props . children } </ span >
42
+ </ Comp >
67
43
) ;
68
44
}
69
45
) ;
70
- Button . displayName = "Button" ;
46
+ SparkleButton . displayName = "Button" ;
71
47
72
- export { Button , buttonVariants } ;
48
+ export { SparkleButton } ;
0 commit comments