Skip to content

Commit 02bd0ee

Browse files
authored
Merge pull request #14808 from TylerAPfledderer/feat/shadcn-migrate-simulator-create-account-screen
[ShadCN]: Migrate CreateAccount Screen
2 parents 0cb717e + fbba1d2 commit 02bd0ee

18 files changed

+412
-307
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import type { Decorator } from "@storybook/react"
2+
3+
import { Phone } from "../Phone"
4+
import { Template } from "../Template"
5+
6+
export const PhoneDecorator: Decorator = (Story) => {
7+
return (
8+
<div className="mx-auto mt-8">
9+
<Template>
10+
<Phone>
11+
<Story />
12+
</Phone>
13+
</Template>
14+
</div>
15+
)
16+
}

src/components/Simulator/screens/CreateAccount/GeneratingKeys.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import React, { useEffect, useState } from "react"
22
import { motion } from "framer-motion"
33
import { PiCheckThin } from "react-icons/pi"
4-
import { Flex, Grid, Icon, Spinner, Text } from "@chakra-ui/react"
54

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

7+
import { Flex } from "@/components/ui/flex"
8+
import { Spinner } from "@/components/ui/spinner"
9+
10+
import { cn } from "@/lib/utils/cn"
11+
812
import { ProgressCta } from "../../ProgressCta"
913

1014
import {
@@ -48,16 +52,17 @@ export const GeneratingKeys = ({
4852
}, [loading])
4953

5054
return (
51-
<Grid placeItems="center" h="full" bg="background.highlight">
52-
<Flex direction="column" alignItems="center" gap={4}>
55+
<div className="grid h-full place-items-center bg-background-highlight">
56+
<Flex className="flex-col items-center gap-4">
5357
{loading ? (
5458
<motion.div
5559
key="spinner"
5660
initial={{ opacity: 0 }}
5761
animate={{ opacity: 1 }}
5862
transition={{ duration: 0.5 }}
63+
data-testid="loading-spinner"
5964
>
60-
<Spinner w={SPINNER_SIZE} h={SPINNER_SIZE} />
65+
<Spinner className={SPINNER_SIZE} />
6166
</motion.div>
6267
) : (
6368
<motion.div
@@ -66,36 +71,32 @@ export const GeneratingKeys = ({
6671
animate={{ scale: 1 }}
6772
transition={{ type: "spring", delay: 0.25 }}
6873
>
69-
<Icon
70-
as={PiCheckThin}
71-
w={SPINNER_SIZE}
72-
h={SPINNER_SIZE}
73-
transform="rotate(-10deg)"
74-
/>
74+
<PiCheckThin className={cn(SPINNER_SIZE, "-rotate-[10deg]")} />
7575
</motion.div>
7676
)}
7777

78-
<Text textAlign="center" px={{ base: 4, md: 8 }}>
78+
<p className="px-4 text-center md:px-8">
7979
{loading
8080
? "Generating example recovery phrase"
8181
: "Example account created"}
82-
</Text>
82+
</p>
8383
{complete && (
8484
<motion.div
8585
initial={{ opacity: 0 }}
8686
animate={{ opacity: 1 }}
8787
transition={{ duration: BUTTON_FADE_DURATION * 1e-3 }}
88-
style={{ position: "absolute", bottom: 0, width: "100%" }}
88+
className="absolute bottom-0 w-full"
8989
>
9090
<ProgressCta
9191
className="inset-x-0"
9292
progressStepper={progressStepper}
93+
data-testid="generating-keys-cta"
9394
>
9495
{ctaLabel}
9596
</ProgressCta>
9697
</motion.div>
9798
)}
9899
</Flex>
99-
</Grid>
100+
</div>
100101
)
101102
}
Lines changed: 24 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,55 @@
1-
import React from "react"
1+
import { type HTMLAttributes } from "react"
22
import { AnimatePresence, motion } from "framer-motion"
33
import { MdArrowDownward } from "react-icons/md"
4-
import { Box, Grid, GridProps, Icon, useColorModeValue } from "@chakra-ui/react"
54

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

7+
import { cn } from "@/lib/utils/cn"
8+
89
import { EthGlyphIcon } from "../../icons"
910

10-
type HomeScreenProps = GridProps & SimulatorNavProps
11+
type HomeScreenProps = HTMLAttributes<HTMLDivElement> & SimulatorNavProps
1112

1213
export const HomeScreen = ({ nav, ...props }: HomeScreenProps) => {
13-
const gridShadow = useColorModeValue(
14-
"0 0 7px 0 var(--eth-colors-blackAlpha-800)",
15-
"0 0 7px 0 var(--eth-colors-whiteAlpha-800)"
16-
)
17-
1814
const { step } = nav
1915
const ICON_COUNT = 8
20-
const sharedIconStyles = {
21-
w: "full",
22-
aspectRatio: 1,
23-
borderRadius: "xl",
24-
placeItems: "center",
25-
transition:
26-
"background-color 2000ms ease-in-out, border 200ms ease-in--out",
27-
border: "2px solid transparent",
28-
} as const
16+
const sharedIconClasses =
17+
"w-full aspect-square rounded-xl place-items-center duration-200 transition-[border,background-color] border-2 border-transparent"
2918
return (
30-
<Grid
31-
px={6}
32-
py={8}
33-
w="full"
34-
gap={5}
35-
templateColumns="repeat(4, 1fr)"
36-
{...props}
37-
>
19+
<div className="grid w-full grid-cols-4 gap-5 px-6 py-8" {...props}>
3820
{Array(ICON_COUNT)
3921
.fill(0)
4022
.map((_, i) => (
41-
<Box key={i} {...sharedIconStyles} bg="body.light" />
23+
<div key={i} className={cn("bg-body-light", sharedIconClasses)} />
4224
))}
4325
<AnimatePresence>
4426
{step === 1 ? (
45-
<Grid
46-
as={motion.button}
27+
<motion.button
28+
className={cn(
29+
"hover:outline-primary-hover, grid border-body bg-body shadow-md duration-300 hover:outline hover:outline-2 hover:outline-offset-2",
30+
sharedIconClasses
31+
)}
4732
initial={{ opacity: 0 }}
4833
animate={{ opacity: 1 }}
4934
exit={{ opacity: 0 }}
50-
{...sharedIconStyles}
5135
onClick={nav.progressStepper}
52-
transitionDuration="0.3s"
53-
bg="body.base"
54-
borderColor="body.base"
55-
boxShadow={gridShadow}
56-
_hover={{
57-
outline: "2px solid var(--eth-colors-primary-hover)",
58-
outlineOffset: "2px",
59-
}}
6036
>
61-
<Icon
62-
as={EthGlyphIcon}
63-
color="background.base"
64-
fontSize={{ base: "2xl", sm: "3xl" }}
65-
/>
66-
</Grid>
37+
{/* TODO: remove important flag from classes when icons are migrated */}
38+
<EthGlyphIcon className="!size-[1em] !text-2xl !text-background sm:!text-3xl" />
39+
</motion.button>
6740
) : (
68-
<Grid
69-
as={motion.div}
41+
<motion.div
42+
className={cn(
43+
sharedIconClasses,
44+
"grid border-dashed border-disabled bg-background duration-200"
45+
)}
7046
initial={{ opacity: 1 }}
7147
exit={{ opacity: 0 }}
72-
transitionDuration="0.2s"
73-
{...sharedIconStyles}
74-
bg="background.base"
75-
borderStyle="dashed"
76-
borderColor="disabled"
7748
>
78-
<Icon
79-
as={MdArrowDownward}
80-
color="disabled"
81-
fontSize={{ base: "2xl", sm: "3xl" }}
82-
/>
83-
</Grid>
49+
<MdArrowDownward className="!size-[1em] !text-2xl !text-disabled sm:!text-3xl" />
50+
</motion.div>
8451
)}
8552
</AnimatePresence>
86-
</Grid>
53+
</div>
8754
)
8855
}
Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
import React from "react"
2-
import { Box, Text } from "@chakra-ui/react"
3-
41
import { WordList } from "./WordList"
52

63
type InitialWordDisplayProps = {
74
words: Array<string>
85
}
96
export const InitialWordDisplay = ({ words }: InitialWordDisplayProps) => (
10-
<Box bg="background.highlight">
11-
<Box py={8}>
12-
<Text
13-
fontSize={{ base: "xl", md: "2xl" }}
14-
lineHeight={8}
15-
fontWeight="bold"
16-
px={{ base: 4, md: 8 }}
17-
mb={{ base: 0, md: 6 }}
18-
>
7+
<div className="bg-background-highlight">
8+
<div className="py-8">
9+
<p className="px-4 text-xl font-bold leading-8 md:mb-6 md:px-8 md:text-2xl">
1910
Recovery phrase example
20-
</Text>
21-
</Box>
11+
</p>
12+
</div>
2213
<WordList words={words} />
23-
</Box>
14+
</div>
2415
)
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import React, { useState } from "react"
2-
import { Box, Text } from "@chakra-ui/react"
1+
import { useState } from "react"
32

43
import { PhoneScreenProps } from "@/lib/types"
54

@@ -20,17 +19,10 @@ export const InteractiveWordSelector = ({
2019
const { progressStepper } = nav
2120
const [wordsSelected, setWordsSelected] = useState(0)
2221
return (
23-
<Box mt={8}>
24-
<Text
25-
display={{ base: "none", md: "block" }}
26-
fontSize="2xl"
27-
lineHeight={8}
28-
fontWeight="bold"
29-
px={{ base: 4, md: 8 }}
30-
mb={4}
31-
>
22+
<div className="mt-8">
23+
<p className="mb-4 px-4 text-2xl font-bold leading-8 max-md:hidden md:px-8">
3224
Repeat the words
33-
</Text>
25+
</p>
3426
<WordList words={words} wordsSelected={wordsSelected} />
3527
{wordsSelected < words.length ? (
3628
<WordSelectorButtons
@@ -39,8 +31,13 @@ export const InteractiveWordSelector = ({
3931
setWordsSelected={setWordsSelected}
4032
/>
4133
) : (
42-
<ProgressCta progressStepper={progressStepper}>{ctaLabel}</ProgressCta>
34+
<ProgressCta
35+
data-testid="word-selector-cta"
36+
progressStepper={progressStepper}
37+
>
38+
{ctaLabel}
39+
</ProgressCta>
4340
)}
44-
</Box>
41+
</div>
4542
)
4643
}
Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
1-
import React from "react"
21
import { motion } from "framer-motion"
3-
import { Box, Text } from "@chakra-ui/react"
4-
5-
const MotionBox = motion(Box)
62

73
export const RecoveryPhraseNotice = () => (
8-
<MotionBox
4+
<motion.div
5+
className="h-full bg-background-highlight px-4 py-8 text-sm md:px-8 md:text-md [&_p]:mb-4 [&_p]:md:mb-6"
96
initial={{ opacity: 0 }}
107
animate={{ opacity: 1 }}
118
transition={{ duration: 0.25 }}
12-
py={8}
13-
px={{ base: 4, md: 8 }}
14-
h="full"
15-
bg="background.highlight"
16-
fontSize={{ base: "sm", md: "md" }}
17-
sx={{ p: { mb: { base: 4, md: 6 } } }}
189
>
19-
<Text fontSize={{ base: "xl", md: "2xl" }} lineHeight={8} fontWeight="bold">
20-
Recovery phrase
21-
</Text>
22-
<Text>
10+
<p className="text-xl font-bold leading-8 md:text-2xl">Recovery phrase</p>
11+
<p>
2312
Any person knowing this <strong>secret</strong> recovery phrase can make
2413
transactions on behalf of your account.
25-
</Text>
26-
<Text>
27-
Wallet app providers do not have access to your account—only you do.
28-
</Text>
29-
<Text fontWeight="bold">You must back it up safely.</Text>
30-
</MotionBox>
14+
</p>
15+
<p>Wallet app providers do not have access to your account—only you do.</p>
16+
<p className="font-bold">You must back it up safely.</p>
17+
</motion.div>
3118
)
Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
1-
import React from "react"
21
import { motion } from "framer-motion"
3-
import { Flex, Icon, Text } from "@chakra-ui/react"
2+
3+
import { Flex } from "@/components/ui/flex"
44

55
import { EthGlyphIcon } from "../../icons"
66

77
const MotionFlex = motion(Flex)
88

99
export const WelcomeScreen = () => (
1010
<MotionFlex
11-
direction="column"
12-
alignItems="center"
13-
pt={16}
14-
h="full"
15-
bg="background.highlight"
11+
className="h-full flex-col items-center bg-background-highlight pt-16"
1612
initial={{ opacity: 0 }}
1713
animate={{ opacity: 1 }}
1814
transition={{ duration: 0.8 }}
1915
>
20-
<Icon
21-
as={EthGlyphIcon}
22-
color="body.base"
23-
height={{ base: "110px", md: "190px" }}
24-
w="auto"
25-
my={4}
26-
/>
27-
<Text
28-
fontSize="2xl"
29-
textAlign="center"
30-
px={{ base: 4, md: 8 }}
31-
lineHeight={8}
32-
>
16+
{/* TODO: remove important flag from classes when icons are migrated */}
17+
<EthGlyphIcon className="!my-4 !h-[110px] !w-auto !text-body md:!h-[190px]" />
18+
<p className="px-4 text-center text-2xl leading-8 md:px-8">
3319
Welcome to
34-
<Text as="span" display="block" fontWeight="bold">
35-
wallet simulator
36-
</Text>
37-
</Text>
20+
<span className="block font-bold">wallet simulator</span>
21+
</p>
3822
</MotionFlex>
3923
)

0 commit comments

Comments
 (0)