Skip to content

Commit cc05646

Browse files
feat(Simulator/Explanation): migrate to ShadCN
1 parent 37979f9 commit cc05646

File tree

1 file changed

+32
-53
lines changed

1 file changed

+32
-53
lines changed

src/components/Simulator/Explanation.tsx

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from "react"
22
import { motion } from "framer-motion"
33
import { MdArrowBack } from "react-icons/md"
4-
import { Box, Flex, Grid, Heading, Text } from "@chakra-ui/react"
54

65
import type { SimulatorNavProps } from "@/lib/types"
76

8-
import { Button, ButtonLink } from "../Buttons"
7+
import { cn } from "@/lib/utils/cn"
8+
9+
import { Button, ButtonLink } from "../ui/buttons/Button"
10+
import { Flex } from "../ui/flex"
911

1012
import type {
1113
LabelHref,
@@ -43,74 +45,51 @@ export const Explanation = ({
4345
hidden: { opacity: 0 },
4446
}
4547
return (
46-
<Flex direction="column" flex={1} zIndex={1}>
48+
<Flex className="z-[1] flex-1 flex-col">
4749
{/* Back button */}
4850
<Button
49-
as={motion.button}
5051
variant="ghost"
51-
leftIcon={<MdArrowBack size="18px" />}
52-
sx={{ paddingInlineStart: 0 }}
53-
mt={{ base: -6, md: 0 }}
54-
mb={{ base: 2, md: 8 }}
52+
className={cn(
53+
"-mt-6 mb-2 w-fit ps-0 [transition-duration:10ms] md:mb-8 md:mt-0",
54+
step === 0 ? "pointer-events-none" : "pointer-events-auto"
55+
)}
5556
onClick={regressStepper}
56-
pointerEvents={step === 0 ? "none" : "all"}
57-
variants={backButtonVariants}
58-
initial="hidden"
59-
animate={step === 0 ? "hidden" : "visible"}
60-
transitionDuration="10ms"
61-
w="fit-content"
57+
asChild
6258
>
63-
Back
59+
<motion.button
60+
initial="hidden"
61+
variants={backButtonVariants}
62+
animate={step === 0 ? "hidden" : "visible"}
63+
>
64+
<MdArrowBack size="18px" />
65+
Back
66+
</motion.button>
6467
</Button>
65-
<Flex direction={{ base: "row", md: "column" }} gap={{ base: 3, md: 2 }}>
68+
<Flex className="gap-3 md:flex-col md:gap-2">
6669
{/* Step counter */}
67-
<Grid
68-
placeItems="center"
69-
bg="body.light"
70-
borderRadius="lg"
71-
p={2}
72-
w={9}
73-
h={8}
74-
fontSize="xs"
75-
>
76-
<Text as="span" lineHeight={1} fontWeight="bold" m={0}>
70+
<div className="grid h-8 w-9 place-items-center rounded-lg bg-body-light p-2 text-xs">
71+
<span className="font-bold leading-none">
7772
{step + 1}/{totalSteps}
78-
</Text>
79-
</Grid>
73+
</span>
74+
</div>
8075
{/* Header and description */}
81-
<Box>
82-
<Heading
83-
as="h3"
84-
fontSize={{ base: "xl", sm: "2xl", md: "3xl", lg: "4xl" }}
85-
lineHeight={{ base: 8, md: 10 }}
86-
mt={0}
87-
mb={{ base: 4, md: 8 }}
88-
>
76+
<div>
77+
<h3 className="mb-4 mt-0 text-xl leading-8 sm:text-2xl md:mb-8 md:text-3xl md:leading-10 lg:text-4xl">
8978
{header}
90-
</Heading>
79+
</h3>
9180
{description && (
92-
<Box display={{ base: "block", md: "none" }} position="relative">
81+
<div className="relative md:hidden">
9382
<MoreInfoPopover isFirstStep={nav.step === 0}>
94-
<Box>{description}</Box>
83+
<div>{description}</div>
9584
</MoreInfoPopover>
96-
</Box>
85+
</div>
9786
)}
98-
</Box>
87+
</div>
9988
</Flex>
100-
{description && (
101-
<Box display={{ base: "none", md: "block" }}>{description}</Box>
102-
)}
89+
{description && <div className="max-md:hidden">{description}</div>}
10390
{/* Last step navigation buttons */}
10491
{isLastStep && (
105-
<Flex
106-
direction="column"
107-
gap={4}
108-
maxW="300px"
109-
w="full"
110-
mx={{ base: "auto", md: 0 }}
111-
mt={4}
112-
zIndex={-1}
113-
>
92+
<Flex className="z-[-1] mx-auto mt-4 w-full max-w-[300px] flex-col gap-4 md:mx-0">
11493
{nextPathSummary && openPath && nextPathId && (
11594
<PathButton
11695
pathSummary={nextPathSummary}

0 commit comments

Comments
 (0)