11import { clsx } from "@lib/utils/clsx" ;
22import { WithRequired } from "@lib/utils/typeUtils/WithRequired" ;
33import { HTMLMotionProps , motion , useAnimate } from "framer-motion" ;
4- import { forwardRef , useImperativeHandle , useMemo , useRef } from "react" ;
4+ import { forwardRef , useMemo } from "react" ;
55
66type ButtonStyleProps = {
77 variant ?: "solid" | "outline" | "link" ;
@@ -61,21 +61,17 @@ function useCommonProps<Type extends "a" | "button">(
6161 // eslint-disable-next-line @typescript-eslint/no-explicit-any
6262 onClick : async ( e : any ) => {
6363 props . onClick ?.( e ) ;
64- await animate (
65- scope . current ,
66- { backgroundColor : "#FF00A6" } ,
67- { duration : 0.1 } ,
68- ) ;
69- await animate (
70- scope . current ,
71- { backgroundColor : "#DB0082" } ,
72- { duration : 0.1 } ,
73- ) ;
64+ await animate ( scope . current , { opacity : 0.95 } , { duration : 0.1 } ) ;
65+ await animate ( scope . current , { opacity : 0.8 } , { duration : 0.1 } ) ;
7466 } ,
75- initial : { backgroundColor : "#DB0082" } ,
76- whileHover : { backgroundColor : "#AC0067" } ,
77- whileFocus : { backgroundColor : "#AC0067" } ,
78- className : clsx ( variantClasses ( props ) , className , "cursor-pointer" ) ,
67+ initial : { opacity : 1 } ,
68+ whileHover : { opacity : 0.8 } ,
69+ whileFocus : { opacity : 0.8 } ,
70+ className : clsx (
71+ variantClasses ( props ) ,
72+ className ,
73+ "cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed" ,
74+ ) ,
7975 ...props ,
8076 ref : mergeRefs ( ref , scope ) ,
8177 } ) ,
@@ -96,24 +92,17 @@ Button.displayName = "Button";
9692
9793export const ButtonLink = forwardRef < HTMLAnchorElement , LinkProps > (
9894 ( { children, ...props } , ref ) => {
99- const common = useCommonProps < "a" > ( props ) ;
95+ const common = useCommonProps < "a" > ( props , ref ) ;
10096
101- return (
102- < motion . a ref = { ref } { ...common } >
103- { children }
104- </ motion . a >
105- ) ;
97+ return < motion . a { ...common } > { children } </ motion . a > ;
10698 } ,
10799) ;
108100ButtonLink . displayName = "ButtonLink" ;
109101
110102export const Link = forwardRef < HTMLAnchorElement , Omit < LinkProps , "variant" > > (
111103 ( { children, ...props } , ref ) => {
112104 return (
113- < motion . a
114- ref = { ref }
115- { ...useCommonProps < "a" > ( { variant : "link" , ...props } ) }
116- >
105+ < motion . a { ...useCommonProps < "a" > ( { variant : "link" , ...props } , ref ) } >
117106 { children }
118107 </ motion . a >
119108 ) ;
0 commit comments