Skip to content

Commit cf716db

Browse files
authored
Merge pull request #14861 from TylerAPfledderer/feat/shadcn-connectweb3-simulator-screen
[ShadCN]: migrate ConnectWeb3 Simulator Screen
2 parents 5976eb4 + 10950d0 commit cf716db

File tree

6 files changed

+174
-207
lines changed

6 files changed

+174
-207
lines changed

src/components/Simulator/screens/ConnectWeb3/Browser.tsx

Lines changed: 23 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import React, { useEffect, useState } from "react"
1+
import React, { type HTMLAttributes, useEffect, useState } from "react"
22
import { motion } from "framer-motion"
33
import { BsTriangle } from "react-icons/bs"
44
import { IoEllipsisHorizontalSharp } from "react-icons/io5"
55
import { PiMagnifyingGlass } from "react-icons/pi"
66
import { TbWorldWww } from "react-icons/tb"
7-
import { Box, Flex, type FlexProps, Icon, Text } from "@chakra-ui/react"
7+
8+
import { Flex, HStack } from "@/components/ui/flex"
89

910
import { BASE_ANIMATION_DELAY_SEC } from "../../constants"
1011
import { NotificationPopover } from "../../NotificationPopover"
1112

1213
import { EXAMPLE_APP_URL } from "./constants"
1314

14-
type BrowserProps = FlexProps
15+
type BrowserProps = HTMLAttributes<HTMLDivElement>
1516

1617
export const Browser = ({ ...props }: BrowserProps) => {
1718
const [typing, setTyping] = useState(false)
@@ -35,67 +36,45 @@ export const Browser = ({ ...props }: BrowserProps) => {
3536
}
3637

3738
return (
38-
<Flex direction="column" h="full" bg="body.light" {...props}>
39-
<Box bg="background.highlight" w="full" px={3} pt={9} pb={3}>
39+
<Flex className="h-full flex-col bg-body-light" {...props}>
40+
<div className="w-full bg-background-highlight px-3 pb-3 pt-9">
4041
<NotificationPopover
4142
title="Example walkthrough"
4243
content="Try logging into a real app with your wallet when finished here"
4344
>
44-
<Flex
45-
bg="background.base"
46-
borderRadius="base"
47-
px={3}
48-
py={2}
49-
align="center"
50-
color="disabled"
51-
cursor="default"
52-
>
53-
<Box
54-
borderInlineEnd="1px"
55-
borderColor="background.highlight"
56-
flex={1}
57-
>
45+
<HStack className="cursor-default gap-0 rounded bg-background px-3 py-2 text-disabled">
46+
<div className="flex-1 border-e border-background-highlight">
5847
{typing ? (
59-
<Text
60-
as={motion.p}
48+
<motion.p
49+
className="text-body-medium"
6150
variants={sentence}
6251
initial="hidden"
6352
animate="visible"
64-
color="body.medium"
6553
>
6654
{EXAMPLE_APP_URL.split("").map((char, index) => (
6755
<motion.span key={char + "-" + index} variants={letter}>
6856
{char}
6957
</motion.span>
7058
))}
71-
</Text>
59+
</motion.p>
7260
) : (
73-
<Text>Search or enter website</Text>
61+
<p>Search or enter website</p>
7462
)}
75-
</Box>
76-
<Icon as={TbWorldWww} ms={3} />
77-
</Flex>
63+
</div>
64+
<TbWorldWww className="ms-3" />
65+
</HStack>
7866
</NotificationPopover>
79-
</Box>
67+
</div>
8068

81-
<Flex flex={1} justify="center" pt={{ base: 20, md: 24 }}>
82-
<Icon as={TbWorldWww} fontSize="8xl" strokeWidth="1" color="disabled" />
69+
<Flex className="flex-1 justify-center pt-20 md:pt-24">
70+
<TbWorldWww className="stroke-1 text-8xl text-disabled" />
8371
</Flex>
8472

85-
<Flex
86-
bg="background.highlight"
87-
w="full"
88-
px={3}
89-
pb={9}
90-
pt={4}
91-
justify="space-around"
92-
fontSize="xl"
93-
color="disabled"
94-
>
95-
<Icon as={BsTriangle} transform="rotate(-90deg)" />
96-
<Icon as={BsTriangle} transform="rotate(90deg)" />
97-
<Icon as={PiMagnifyingGlass} />
98-
<Icon as={IoEllipsisHorizontalSharp} />
73+
<Flex className="w-full justify-around bg-background-highlight px-3 pb-9 pt-4 text-xl text-disabled">
74+
<BsTriangle className="-rotate-90" />
75+
<BsTriangle className="rotate-90" />
76+
<PiMagnifyingGlass />
77+
<IoEllipsisHorizontalSharp />
9978
</Flex>
10079
</Flex>
10180
)

src/components/Simulator/screens/ConnectWeb3/Slider.tsx

Lines changed: 26 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,75 @@
1-
import React from "react"
1+
import { type ReactNode } from "react"
22
import { motion } from "framer-motion"
33
import { PiCheckThin } from "react-icons/pi"
4-
import { Box, Flex, Grid, Icon, Text, TextProps } from "@chakra-ui/react"
4+
5+
import { HStack, VStack } from "@/components/ui/flex"
56

67
import { EthGlyphIcon } from "../../icons"
78

8-
type SliderProps = Pick<TextProps, "children"> & {
9+
type SliderProps = {
910
isConnected: boolean
1011
displayUrl: string
12+
children: ReactNode
1113
}
1214
export const Slider = ({ isConnected, displayUrl, children }: SliderProps) => {
13-
const ICON_SIZE = "4.5rem" as const
1415
return (
1516
<>
16-
<Box
17+
<motion.div
1718
key="backdrop"
18-
as={motion.div}
19-
position="absolute"
20-
inset={0}
21-
bg="blackAlpha.300"
22-
backdropFilter="blur(2px)"
19+
className="absolute inset-0 bg-black/15 backdrop-blur-[2px]"
2320
initial={{ opacity: 0 }}
2421
animate={{ opacity: 1 }}
2522
exit={{ opacity: 0 }}
2623
/>
2724
<motion.div
2825
key="slider"
29-
style={{ position: "absolute", height: "360px", width: "100%" }}
26+
className="absolute h-[360px] w-full"
3027
initial={{ bottom: "-100%" }}
3128
animate={{ bottom: 0 }}
3229
exit={{ bottom: "-100%" }}
3330
transition={{ duration: 0.75, ease: "easeOut" }}
31+
data-testid="slider-box"
3432
>
35-
<Flex
36-
direction="column"
37-
alignItems="center"
38-
px={6}
39-
py={8}
40-
h="full"
41-
w="full"
42-
bg="background.base"
43-
borderTopRadius="2xl"
44-
>
33+
<VStack className="size-full gap-0 rounded-t-2xl bg-background px-6 py-8">
4534
{isConnected ? (
46-
<Flex direction="column" alignItems="center" pt={8} gap={4}>
35+
<VStack className="gap-4 pt-8">
4736
<motion.div
4837
key="checkmark"
4938
initial={{ scale: 0 }}
5039
animate={{ scale: 1 }}
5140
transition={{ type: "spring", delay: 0.25 }}
5241
>
53-
<Icon
54-
as={PiCheckThin}
55-
w={ICON_SIZE}
56-
h={ICON_SIZE}
57-
transform="rotate(-10deg)"
58-
/>
42+
<PiCheckThin className="-rotate-[10deg] text-[4.5rem]" />
5943
</motion.div>
6044
<motion.div
6145
key="text"
6246
initial={{ opacity: 0 }}
6347
animate={{ opacity: 1 }}
6448
transition={{ delay: 0.15 }}
6549
>
66-
<Text textAlign="center" px={{ base: 4, md: 8 }}>
50+
<p className="px-4 text-center md:px-8">
6751
You&apos;re logged in!
68-
</Text>
52+
</p>
6953
</motion.div>
70-
</Flex>
54+
</VStack>
7155
) : (
7256
<>
73-
<Text textAlign="center" fontWeight="bold" fontSize="lg" mb={4}>
57+
<p className="mb-4 text-center text-lg font-bold">
7458
Connect account?
75-
</Text>
59+
</p>
7660
{/* URL Pill */}
77-
<Flex
78-
bg="blackAlpha.200"
79-
px={2}
80-
py={1}
81-
borderRadius="full"
82-
fontSize="xs"
83-
alignItems="center"
84-
gap={2}
85-
mb={6}
86-
>
87-
<Grid
88-
borderRadius="full"
89-
bg="body.base"
90-
w={5}
91-
h={5}
92-
placeItems="center"
93-
>
94-
<Icon
95-
as={EthGlyphIcon}
96-
color="background.base"
97-
fontSize="sm"
98-
/>
99-
</Grid>
100-
<Text mb={0} me={0.5}>
101-
{displayUrl}
102-
</Text>
103-
</Flex>
61+
<HStack className="mb-6 rounded-full bg-black/5 px-2 py-1 text-xs">
62+
<div className="grid size-5 place-items-center rounded-full bg-body">
63+
{/* TODO: Remove important flags and `size` class when icon is migrated */}
64+
<EthGlyphIcon className="!size-[1em] !text-sm !text-background" />
65+
</div>
66+
<p className="me-0.5">{displayUrl}</p>
67+
</HStack>
10468
{/* Information */}
105-
<Text>{children}</Text>
69+
<p>{children}</p>
10670
</>
10771
)}
108-
</Flex>
72+
</VStack>
10973
</motion.div>
11074
</>
11175
)
Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,52 @@
1-
import React from "react"
1+
import React, { type HTMLAttributes } from "react"
22
import { GrMenu } from "react-icons/gr"
3-
import {
4-
Box,
5-
type BoxProps,
6-
Flex,
7-
Icon,
8-
Text,
9-
useColorModeValue,
10-
} from "@chakra-ui/react"
3+
4+
import { HStack } from "@/components/ui/flex"
5+
6+
import { cn } from "@/lib/utils/cn"
117

128
import { FAKE_DEMO_ADDRESS } from "../../constants"
139
import { EthGlyphIcon } from "../../icons"
1410
import { NotificationPopover } from "../../NotificationPopover"
1511

16-
type Web3AppProps = BoxProps & {
12+
type Web3AppProps = HTMLAttributes<HTMLDivElement> & {
1713
displayUrl: string
1814
appName?: string
1915
}
2016
export const Web3App = ({
2117
displayUrl,
2218
appName,
2319
children,
24-
...boxProps
20+
className,
21+
...rest
2522
}: Web3AppProps) => {
26-
const bg = useColorModeValue("#e8e8e8", "#171717")
27-
2823
return (
29-
<Box h="full" w="full" bg="background.highlight" {...boxProps}>
30-
<Box p={1} bg={bg}>
31-
<Text textAlign="center" fontSize="xs" m={0}>
32-
{displayUrl}
33-
</Text>
34-
</Box>
24+
<div
25+
className={cn("size-full bg-background-highlight", className)}
26+
{...rest}
27+
>
28+
<div className="bg-[#e8e8e8] p-1 dark:bg-[#171717]">
29+
<p className="text-center text-xs">{displayUrl}</p>
30+
</div>
3531
<NotificationPopover
3632
title="Example walkthrough"
3733
content="Try out a real Ethereum application when finished here"
3834
>
39-
<Flex p={6} fontSize="4xl" gap={3} alignItems="center">
40-
<Icon as={EthGlyphIcon} />
41-
<Box flex={1} cursor="default">
35+
<HStack className="gap-3 p-6 text-4xl">
36+
{/* TODO: Remove 'size' class when icon is migrated */}
37+
<EthGlyphIcon className="!size-[1em]" />
38+
<div className="flex-1 cursor-default">
4239
{appName && (
4340
<>
44-
<Text fontSize="md" fontWeight="bold">
45-
{appName}
46-
</Text>
47-
<Text fontSize="sm">{FAKE_DEMO_ADDRESS}</Text>
41+
<p className="text-md font-bold">{appName}</p>
42+
<p className="text-sm">{FAKE_DEMO_ADDRESS}</p>
4843
</>
4944
)}
50-
</Box>
51-
<Icon as={GrMenu} sx={{ path: { stroke: "body.base" } }} />
52-
</Flex>
45+
</div>
46+
<GrMenu className="[&>path]:stroke-body" />
47+
</HStack>
5348
</NotificationPopover>
5449
{children}
55-
</Box>
50+
</div>
5651
)
5752
}

0 commit comments

Comments
 (0)