1
- import React , { useEffect , useState } from "react"
1
+ import { type ReactNode , useEffect , useState } from "react"
2
2
import { motion , type Transition } from "framer-motion"
3
- import { createIcon , Flex , Text , TextProps } from "@chakra-ui/react"
3
+
4
+ import { cn } from "@/lib/utils/cn"
5
+
6
+ import { createIconBase } from "../icons/icon-base"
7
+ import { Flex } from "../ui/flex"
4
8
5
9
const MotionFlex = motion ( Flex )
6
10
7
11
const DownArrowLong = motion (
8
- createIcon ( {
12
+ createIconBase ( {
9
13
displayName : "DownArrowLong" ,
10
14
viewBox : "0 0 8 24" ,
11
- defaultProps : { fill : "currentColor" } ,
12
- path : (
15
+ className : " fill-current" ,
16
+ children : (
13
17
< path d = "M3.64645 23.3536C3.84171 23.5488 4.15829 23.5488 4.35355 23.3536L7.53553 20.1716C7.7308 19.9763 7.7308 19.6597 7.53553 19.4645C7.34027 19.2692 7.02369 19.2692 6.82843 19.4645L4 22.2929L1.17157 19.4645C0.976312 19.2692 0.659729 19.2692 0.464467 19.4645C0.269205 19.6597 0.269205 19.9763 0.464467 20.1716L3.64645 23.3536ZM3.5 2.18557e-08L3.5 23L4.5 23L4.5 -2.18557e-08L3.5 2.18557e-08Z" />
14
18
) ,
15
19
} )
16
20
)
17
21
18
- type ClickAnimationProps = Pick < TextProps , "children" > & {
22
+ type ClickAnimationProps = {
23
+ children : ReactNode
19
24
below ?: boolean
20
25
delay ?: number
21
26
}
@@ -34,34 +39,28 @@ export const ClickAnimation = ({
34
39
times : [ 0 , 0.25 , 0.5 ] ,
35
40
repeat : Infinity ,
36
41
}
37
- const top = below ? "calc(100% + 0 .5rem)" : "auto"
38
- const bottom = below ? "auto" : "calc(100% + 1rem) "
42
+ const topClass = below ? "top-[ calc(100%_+_0 .5rem)] " : "top- auto"
43
+ const bottomClass = below ? "bottom- auto" : "bottom-[ calc(100%_+_1rem)] "
39
44
const y = below ? [ 0 , 20 , 0 ] : [ 0 , - 20 , 0 ]
40
- const direction = below ? "column-reverse" : "column"
41
- const transformOrigin = below ? { bottom : 0 } : { top : 0 }
45
+ const directionClass = below ? "flex-col-reverse" : "flex-col"
42
46
const rotate = below ? 180 : 0
43
47
return visible ? (
44
48
< MotionFlex
49
+ className = { cn (
50
+ "absolute inset-x-0 justify-center text-primary" ,
51
+ topClass ,
52
+ bottomClass
53
+ ) }
45
54
animate = { { opacity : [ 0 , 1 ] } } // Fade in once
46
- position = "absolute"
47
- top = { top }
48
- justify = "center"
49
- bottom = { bottom }
50
- insetInline = { 0 }
51
- color = "primary.base"
52
55
data-testid = "click-animation-el"
53
56
>
54
57
< MotionFlex
55
- direction = { direction }
56
- alignItems = "center"
58
+ className = { cn ( "items-center" , directionClass ) }
57
59
animate = { { y } } // Slide up and down
58
60
transition = { transition }
59
61
>
60
- < Text fontSize = "xs" fontStyle = "italic" textTransform = "lowercase" m = { 0 } >
61
- { children }
62
- </ Text >
62
+ < p className = "m-0 text-xs lowercase italic" > { children } </ p >
63
63
< DownArrowLong
64
- transformOrigin = { transformOrigin }
65
64
initial = { { scaleY : 1 , rotate } }
66
65
animate = { { scaleY : [ 1 , 1.25 , 1 ] } } // Arrow scales up and down
67
66
transition = { transition }
0 commit comments