Skip to content

Commit ef384b5

Browse files
authored
Merge pull request #14862 from TylerAPfledderer/feat/shadcn-migrate-simulator-sendreceive-screen
[ShadCN]: migrate SendReceive Simulator Screen
2 parents 37ba757 + dc76cb7 commit ef384b5

File tree

5 files changed

+238
-166
lines changed

5 files changed

+238
-166
lines changed

src/components/Simulator/screens/SendReceive/ReceivedEther.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export const ReceivedEther = ({
9090
initial={{ opacity: 0 }}
9191
animate={{ opacity: 1 }}
9292
exit={{ opacity: 0 }}
93+
data-testid="received-ether-toast"
9394
>
9495
<MdInfo className="text-xl" />
9596
<p className="m-0 text-xs font-bold">
Lines changed: 34 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import React from "react"
2-
import { Box, Button, Flex, Icon, Text } from "@chakra-ui/react"
2+
3+
import { Button } from "@/components/ui/buttons/Button"
4+
import { Flex, HStack } from "@/components/ui/flex"
5+
6+
import { cn } from "@/lib/utils/cn"
37

48
import { EthTokenIcon } from "../../icons"
59
import { NotificationPopover } from "../../NotificationPopover"
@@ -52,101 +56,67 @@ export const SendEther = ({
5256
}).format(chosenAmount)
5357

5458
return (
55-
<Box h="100%">
56-
<Box px={6} py={8}>
57-
<Text
58-
fontSize={{ base: "xl", md: "2xl" }}
59-
fontWeight="bold"
60-
mb={{ base: 4, md: 6 }}
61-
>
62-
Send
63-
</Text>
64-
<Text mb={{ base: 0, md: 6 }}>How much do you want to send?</Text>
65-
</Box>
66-
<Flex
67-
px={6}
68-
py={{ base: 4, md: 6 }}
69-
borderTop="1px"
70-
borderBottom="1px"
71-
borderColor="background.highlight"
72-
gap={4}
73-
color="body.medium"
74-
fontSize="xs"
75-
>
59+
<div className="h-full">
60+
<div className="px-6 py-8">
61+
<p className="mb-4 text-xl font-bold md:mb-6 md:text-2xl">Send</p>
62+
<p className="md:mb-6">How much do you want to send?</p>
63+
</div>
64+
<Flex className="justify-between gap-4 border-y border-background-highlight px-6 py-4 text-xs text-body-medium md:py-6">
7665
{/* Left side: Displayed send amount */}
7766
<NotificationPopover
7867
title="Example walkthrough"
7968
content="Choose a value below"
8069
side="top"
8170
>
8271
<Flex
83-
alignItems="top"
84-
flex={1}
85-
fontWeight="bold"
86-
color={chosenAmount > 0 ? "body.base" : "disabled"}
72+
className={cn(
73+
"font-bold",
74+
chosenAmount > 0 ? "text-body" : "text-disabled"
75+
)}
8776
>
88-
<Text fontSize="6xl" h="full" lineHeight="1em">
77+
<p className="h-full text-6xl leading-[1em]">
8978
{formatChosenAmount}
90-
</Text>
79+
</p>
9180
</Flex>
9281
</NotificationPopover>
9382
{/* Right side */}
94-
<Flex direction="column" alignItems="end">
83+
<Flex className="flex-col items-end">
9584
<NotificationPopover
9685
side="top"
9786
title="Example walkthrough"
9887
content="In this walkthrough you can only send ETH, but in real wallet you can send different tokens as well"
9988
>
10089
{/* Token selector pill */}
101-
<Flex
102-
px={2}
103-
py={1}
104-
mb={4}
105-
borderRadius="full"
106-
bg="body.light"
107-
alignItems="center"
108-
>
109-
<Icon as={EthTokenIcon} fontSize="xl" me={1.5} />
110-
<Text fontWeight="bold" m={0} color="body.base">
111-
ETH
112-
</Text>
113-
</Flex>
90+
<HStack className="mb-4 gap-0 rounded-full bg-body-light px-2 py-1">
91+
{/* TODO: remove flags and `size` class when icon is migrated */}
92+
<EthTokenIcon className="!me-1.5 !size-[1em] !text-xl" />
93+
<p className="m-0 font-bold text-body">ETH</p>
94+
</HStack>
11495
</NotificationPopover>
11596
{/* Balances */}
116-
<Text fontWeight="bold" m={0} lineHeight={1}>
117-
Balance: {usdAmount}
118-
</Text>
119-
<Text m={0}>
97+
<p className="font-bold leading-none">Balance: {usdAmount}</p>
98+
<p>
12099
<>{ethAmount} ETH</>
121-
</Text>
100+
</p>
122101
</Flex>
123102
</Flex>
124-
<Box bg="background.highlight" h="full">
125-
<Flex
126-
flexWrap="nowrap"
127-
justify="space-between"
128-
px={6}
129-
py={6}
130-
fontWeight="bold"
131-
bg="background.highlight"
132-
position="relative"
133-
>
103+
<div className="h-full bg-background-highlight">
104+
<Flex className="relative flex-nowrap justify-between bg-background-highlight p-6 font-bold">
134105
{/* Amount buttons */}
135106
{AMOUNTS.map((amount, i) => (
136107
<Button
137108
key={i}
138109
onClick={() => handleSelection(amount)}
139-
borderRadius="10px"
140-
bg={amount === chosenAmount ? "primary.hover" : "primary.base"}
141-
fontWeight="bold"
142-
textTransform="uppercase"
143-
fontSize="sm"
110+
className={cn(
111+
"rounded-[10px] text-sm font-bold uppercase",
112+
amount === chosenAmount ? "bg-primary-hover" : "bg-primary"
113+
)}
144114
>
145115
{formatButtonLabel(amount)}
146116
</Button>
147117
))}
148118
</Flex>
149-
</Box>
150-
</Box>
119+
</div>
120+
</div>
151121
)
152122
}

src/components/Simulator/screens/SendReceive/SendSummary.tsx

Lines changed: 32 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import React from "react"
2-
import { Box, Flex, Text } from "@chakra-ui/react"
2+
3+
import { Flex } from "@/components/ui/flex"
4+
5+
import { cn } from "@/lib/utils/cn"
36

47
import { ETH_TRANSFER_FEE } from "../../constants"
58
import { getMaxFractionDigitsUsd } from "../../utils"
@@ -29,77 +32,52 @@ export const SendSummary = ({
2932
return (
3033
<>
3134
{/* Top section */}
32-
<Box py={{ base: 6, md: 8 }} px={6}>
33-
<Text
34-
fontSize={{ base: "xl", md: "2xl" }}
35-
fontWeight="bold"
36-
mb={{ base: 4, md: 8 }}
37-
>
35+
<div className="px-6 py-6 md:py-8">
36+
<p className="mb-4 text-xl font-bold md:mb-8 md:text-2xl">
3837
You are sending
39-
</Text>
38+
</p>
4039
<Flex
41-
alignItems="top"
42-
flex={1}
43-
fontWeight="bold"
44-
color={chosenAmount > 0 ? "body.base" : "inherit"}
45-
mb={{ base: 0, md: 2 }}
40+
className={cn(
41+
"flex-1 font-bold md:mb-2",
42+
chosenAmount > 0 ? "text-body" : "text-inherit"
43+
)}
4644
>
47-
<Text
48-
fontSize={{ base: "5xl", md: "6xl" }}
49-
h="full"
50-
lineHeight="1em"
51-
m={0}
52-
>
45+
<p className="h-full text-5xl leading-[1em] md:text-6xl">
5346
{formatChosenAmount}
54-
</Text>
47+
</p>
5548
</Flex>
56-
<Text fontSize="xs" color="body.medium" m={0}>
49+
<p className="text-xs text-body-medium">
5750
{formatEth(chosenAmount / ethPrice)} ETH
58-
</Text>
59-
</Box>
51+
</p>
52+
</div>
6053
{/* Bottom section */}
61-
<Flex
62-
py={{ base: 4, md: 8 }}
63-
px={6}
64-
bg="background.highlight"
65-
h="full"
66-
gap={{ base: 3, md: 6 }}
67-
direction="column"
68-
sx={{ p: { m: 0 } }}
69-
fontSize={{ base: "sm", md: "md" }}
70-
>
71-
<Box>
72-
<Text>To</Text>
73-
<Text fontWeight="bold">{recipient}</Text>
74-
</Box>
75-
<Box>
76-
<Text>Arrival time</Text>
77-
<Text fontWeight="bold">est. about 12 seconds</Text>
78-
</Box>
79-
<Box>
80-
<Text>Network fees</Text>
81-
<Text m={0} fontWeight="bold">
54+
<Flex className="h-full flex-col gap-3 bg-background-highlight px-6 py-4 text-sm md:gap-6 md:py-8 md:text-md">
55+
<div>
56+
<p>To</p>
57+
<p className="font-bold">{recipient}</p>
58+
</div>
59+
<div>
60+
<p>Arrival time</p>
61+
<p className="font-bold">est. about 12 seconds</p>
62+
</div>
63+
<div>
64+
<p>Network fees</p>
65+
<p className="font-bold">
8266
{Intl.NumberFormat("en", {
8367
maximumFractionDigits: getMaxFractionDigitsUsd(usdFee),
8468
style: "currency",
8569
currency: "USD",
8670
notation: "compact",
8771
}).format(usdFee)}
88-
<Text
89-
as="span"
90-
color="body.medium"
91-
fontSize="xs"
92-
fontWeight="normal"
93-
ms={2}
94-
>
72+
<span className="ms-2 text-xs font-normal text-body-medium">
9573
(
9674
{Intl.NumberFormat("en", {
9775
maximumFractionDigits: 6,
9876
}).format(ETH_TRANSFER_FEE)}{" "}
9977
ETH)
100-
</Text>
101-
</Text>
102-
</Box>
78+
</span>
79+
</p>
80+
</div>
10381
</Flex>
10482
</>
10583
)

src/components/Simulator/screens/SendReceive/Success.tsx

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
1-
import React, { useEffect, useState } from "react"
1+
import { useEffect, useState } from "react"
22
import { AnimatePresence, motion } from "framer-motion"
33
import { PiCheckThin } from "react-icons/pi"
4-
import { Flex, Icon, Spinner, Text } from "@chakra-ui/react"
4+
5+
import { Flex, VStack } from "@/components/ui/flex"
6+
import { Spinner } from "@/components/ui/spinner"
7+
8+
import { cn } from "@/lib/utils/cn"
59

610
import { getMaxFractionDigitsUsd } from "../../utils"
711
import { WalletHome } from "../../WalletHome"
812
import type { TokenBalance } from "../../WalletHome/interfaces"
913

10-
const ICON_SIZE = "4.5rem" as const
14+
const ICON_SIZE = "text-[4.5rem]"
1115

1216
type SuccessProps = {
1317
tokenBalances: Array<TokenBalance>
@@ -72,55 +76,50 @@ export const Success = ({
7276
</motion.div>
7377
) : (
7478
<Flex
75-
animate={{ opacity: [0, 1] }}
76-
exit={{ opacity: 0 }}
77-
key="success-fade-out"
78-
as={motion.div}
79-
justify="center"
80-
h="full"
81-
bg="background.highlight"
82-
pt={{ base: 24, md: 0 }}
83-
alignItems={{ base: "start", md: "center" }}
79+
className="h-full justify-center bg-background-highlight max-md:pt-24 md:items-center"
80+
asChild
8481
>
85-
<Flex direction="column" alignItems="center" pt={8} gap={4}>
86-
{txPending ? (
87-
<motion.div
88-
key="spinner"
89-
initial={{ opacity: 0 }}
90-
animate={{ opacity: 1 }}
91-
transition={{ duration: 0.5 }}
92-
>
93-
<Spinner w={ICON_SIZE} h={ICON_SIZE} />
94-
</motion.div>
95-
) : (
96-
<motion.div
97-
key="checkmark"
98-
initial={{ scale: 0 }}
99-
animate={{ scale: 1 }}
100-
transition={{ type: "spring", delay: 0.25 }}
101-
>
102-
<Icon
103-
as={PiCheckThin}
104-
w={ICON_SIZE}
105-
h={ICON_SIZE}
106-
transform="rotate(-10deg)"
107-
/>
108-
</motion.div>
109-
)}
110-
<Text textAlign="center" px={{ base: 4, md: 8 }}>
82+
<motion.div
83+
animate={{ opacity: [0, 1] }}
84+
exit={{ opacity: 0 }}
85+
key="success-fade-out"
86+
>
87+
<VStack className="gap-4 pt-8">
11188
{txPending ? (
112-
"Sending transaction"
89+
<motion.div
90+
key="spinner"
91+
initial={{ opacity: 0 }}
92+
animate={{ opacity: 1 }}
93+
transition={{ duration: 0.5 }}
94+
>
95+
<Spinner className={ICON_SIZE} />
96+
</motion.div>
11397
) : (
114-
<Text as="span">
115-
You sent{" "}
116-
<strong>
117-
<>{sentEthValue} ETH</>
118-
</strong>{" "}
119-
({usdValue}) to <strong>{recipient}</strong>
120-
</Text>
98+
<motion.div
99+
key="checkmark"
100+
initial={{ scale: 0 }}
101+
animate={{ scale: 1 }}
102+
transition={{ type: "spring", delay: 0.25 }}
103+
data-testid="success-icon"
104+
>
105+
<PiCheckThin className={cn(ICON_SIZE, "-rotate-[10deg]")} />
106+
</motion.div>
121107
)}
122-
</Text>
123-
</Flex>
108+
<p className="px-4 text-center md:px-8">
109+
{txPending ? (
110+
"Sending transaction"
111+
) : (
112+
<span>
113+
You sent{" "}
114+
<strong>
115+
<>{sentEthValue} ETH</>
116+
</strong>{" "}
117+
({usdValue}) to <strong>{recipient}</strong>
118+
</span>
119+
)}
120+
</p>
121+
</VStack>
122+
</motion.div>
124123
</Flex>
125124
)}
126125
</AnimatePresence>

0 commit comments

Comments
 (0)