Skip to content

Commit dbed821

Browse files
feat(Simulator/ClickAnimation): migrate to ShadCN
1 parent 4d20859 commit dbed821

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/components/Simulator/ClickAnimation.tsx

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import React, { useEffect, useState } from "react"
1+
import { type ReactNode, useEffect, useState } from "react"
22
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"
48

59
const MotionFlex = motion(Flex)
610

711
const DownArrowLong = motion(
8-
createIcon({
12+
createIconBase({
913
displayName: "DownArrowLong",
1014
viewBox: "0 0 8 24",
11-
defaultProps: { fill: "currentColor" },
12-
path: (
15+
className: "fill-current",
16+
children: (
1317
<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" />
1418
),
1519
})
1620
)
1721

18-
type ClickAnimationProps = Pick<TextProps, "children"> & {
22+
type ClickAnimationProps = {
23+
children: ReactNode
1924
below?: boolean
2025
delay?: number
2126
}
@@ -34,34 +39,28 @@ export const ClickAnimation = ({
3439
times: [0, 0.25, 0.5],
3540
repeat: Infinity,
3641
}
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)]"
3944
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"
4246
const rotate = below ? 180 : 0
4347
return visible ? (
4448
<MotionFlex
49+
className={cn(
50+
"absolute inset-x-0 justify-center text-primary",
51+
topClass,
52+
bottomClass
53+
)}
4554
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"
5255
data-testid="click-animation-el"
5356
>
5457
<MotionFlex
55-
direction={direction}
56-
alignItems="center"
58+
className={cn("items-center", directionClass)}
5759
animate={{ y }} // Slide up and down
5860
transition={transition}
5961
>
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>
6363
<DownArrowLong
64-
transformOrigin={transformOrigin}
6564
initial={{ scaleY: 1, rotate }}
6665
animate={{ scaleY: [1, 1.25, 1] }} // Arrow scales up and down
6766
transition={transition}

0 commit comments

Comments
 (0)