1- "use client" ;
1+ "use client"
22
3- import React from "react" ;
4- import {
5- motion ,
6- type AnimationProps ,
7- type HTMLMotionProps ,
8- } from "motion/react" ;
9- import { cn } from "@/lib/utils" ;
3+ import React from "react"
4+ import { motion , type MotionProps } from "motion/react"
105
11- const animationProps = {
6+ import { cn } from "@/lib/utils"
7+
8+ const animationProps : MotionProps = {
129 initial : { "--x" : "100%" , scale : 0.8 } ,
1310 animate : { "--x" : "-100%" , scale : 1 } ,
1411 whileTap : { scale : 0.95 } ,
@@ -27,50 +24,52 @@ const animationProps = {
2724 mass : 0.5 ,
2825 } ,
2926 } ,
30- } as AnimationProps ;
27+ }
3128
32- interface ShinyButtonProps extends HTMLMotionProps < "button" > {
33- children : React . ReactNode ;
34- className ?: string ;
35- ref ?: React . Ref < HTMLButtonElement > ;
29+ interface ShinyButtonProps
30+ extends Omit < React . HTMLAttributes < HTMLElement > , keyof MotionProps > ,
31+ MotionProps {
32+ children : React . ReactNode
33+ className ?: string
3634}
3735
38- /**
39- * https://magicui.design/docs/components/shiny-button
40- */
41- const ShinyButton = React . forwardRef < HTMLButtonElement , ShinyButtonProps > (
42- ( { children, className, ...props } , ref ) => {
43- return (
44- < motion . button
45- ref = { ref }
46- { ...animationProps }
47- { ...props }
48- className = { cn (
49- "relative rounded-lg px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/10%)_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_hsl(var(--primary)/10%)]" ,
50- className ,
51- ) }
36+ export const ShinyButton = React . forwardRef <
37+ HTMLButtonElement ,
38+ ShinyButtonProps
39+ > ( ( { children, className, ...props } , ref ) => {
40+ return (
41+ < motion . button
42+ ref = { ref }
43+ className = { cn (
44+ "relative cursor-pointer rounded-lg border px-6 py-2 font-medium backdrop-blur-xl transition-shadow duration-300 ease-in-out hover:shadow dark:bg-[radial-gradient(circle_at_50%_0%,var(--primary)/10%_0%,transparent_60%)] dark:hover:shadow-[0_0_20px_var(--primary)/10%]" ,
45+ className
46+ ) }
47+ { ...animationProps }
48+ { ...props }
49+ >
50+ < span
51+ className = "relative block size-full text-sm tracking-wide text-[rgb(0,0,0,65%)] uppercase dark:font-light dark:text-[rgb(255,255,255,90%)]"
52+ style = { {
53+ maskImage :
54+ "linear-gradient(-75deg,var(--primary) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),var(--primary) calc(var(--x) + 100%))" ,
55+ } }
5256 >
53- < span
54- className = "relative block size-full text-sm uppercase tracking-wide text-[rgb(0,0,0,65%)] dark:font-light dark:text-[rgb(255,255,255,90%)]"
55- style = { {
56- maskImage :
57- "linear-gradient(-75deg,hsl(var(--primary)) calc(var(--x) + 20%),transparent calc(var(--x) + 30%),hsl(var(--primary)) calc(var(--x) + 100%))" ,
58- } }
59- >
60- { children }
61- </ span >
62- < span
63- style = { {
64- mask : "linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box,linear-gradient(rgb(0,0,0), rgb(0,0,0))" ,
65- maskComposite : "exclude" ,
66- } }
67- className = "absolute inset-0 z-10 block rounded-[inherit] bg-[linear-gradient(-75deg,hsl(var(--primary)/10%)_calc(var(--x)+20%),hsl(var(--primary)/50%)_calc(var(--x)+25%),hsl(var(--primary)/10%)_calc(var(--x)+100%))] p-px"
68- > </ span >
69- </ motion . button >
70- ) ;
71- } ,
72- ) ;
57+ { children }
58+ </ span >
59+ < span
60+ style = { {
61+ mask : "linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box exclude,linear-gradient(rgb(0,0,0), rgb(0,0,0))" ,
62+ WebkitMask :
63+ "linear-gradient(rgb(0,0,0), rgb(0,0,0)) content-box exclude,linear-gradient(rgb(0,0,0), rgb(0,0,0))" ,
64+ backgroundImage :
65+ "linear-gradient(-75deg,var(--primary)/10% calc(var(--x)+20%),var(--primary)/50% calc(var(--x)+25%),var(--primary)/10% calc(var(--x)+100%))" ,
66+ } }
67+ className = "absolute inset-0 z-10 block rounded-[inherit] p-px"
68+ />
69+ </ motion . button >
70+ )
71+ } )
7372
74- ShinyButton . displayName = "ShinyButton" ;
73+ ShinyButton . displayName = "ShinyButton"
7574
7675export default ShinyButton ;
0 commit comments