Skip to content

Commit 0cb717e

Browse files
authored
Merge pull request #14806 from TylerAPfledderer/feat/simulator-wallet-home-shadcn
[ShadCN]: Migrate Simulator WalletHome
2 parents 3934ca2 + a41e3a6 commit 0cb717e

File tree

12 files changed

+170
-211
lines changed

12 files changed

+170
-211
lines changed
Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react"
22
import { MdContentCopy } from "react-icons/md"
3-
import { Flex, type FlexProps, Icon, Text } from "@chakra-ui/react"
3+
4+
import { Flex, type FlexProps } from "@/components/ui/flex"
45

56
import { FAKE_DEMO_ADDRESS } from "../constants"
67
import { NotificationPopover } from "../NotificationPopover"
@@ -13,21 +14,11 @@ export const AddressPill = ({ ...btnProps }: AddressPillProps) => (
1314
content="Share your address (public identifier) from your own wallet when finished here"
1415
>
1516
<Flex
16-
gap={2}
17-
align="center"
18-
borderRadius="full"
19-
bg="background.highlight"
20-
color="disabled"
21-
border="1px"
22-
borderColor="border"
23-
py={1}
24-
px={2}
25-
alignSelf="center"
26-
fontSize="xs"
17+
className="gap-2 self-center rounded-full border border-border bg-background-highlight px-2 py-1 text-center text-xs text-disabled"
2718
{...btnProps}
2819
>
29-
<Text m={0}>{FAKE_DEMO_ADDRESS}</Text>
30-
<Icon as={MdContentCopy} w={4} fontSize="lg" />
20+
<p>{FAKE_DEMO_ADDRESS}</p>
21+
<MdContentCopy className="w-4 text-lg leading-none" />
3122
</Flex>
3223
</NotificationPopover>
3324
)
Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react"
2-
import { Flex, type FlexProps, Text } from "@chakra-ui/react"
1+
import { Button } from "@/components/ui/buttons/Button"
2+
import { Flex, type FlexProps } from "@/components/ui/flex"
33

4-
import { Button } from "../../Buttons"
4+
import { cn } from "@/lib/utils/cn"
55

66
type CategoryTabsProps = FlexProps & {
77
categories: Array<string>
@@ -12,31 +12,32 @@ export const CategoryTabs = ({
1212
categories,
1313
activeIndex = 0,
1414
setActiveIndex,
15+
className,
1516
...flexProps
1617
}: CategoryTabsProps) => (
17-
<Flex gap={6} {...flexProps}>
18-
{categories.map((category, index) =>
19-
setActiveIndex ? (
18+
<Flex className={cn("gap-6", className)} {...flexProps}>
19+
{categories.map((category, index) => {
20+
const isActiveIndex = activeIndex === index
21+
const fontWeightClass = isActiveIndex && "font-bold"
22+
return setActiveIndex ? (
2023
<Button
2124
key={category}
2225
variant="ghost"
23-
fontWeight={activeIndex === index ? "bold" : "normal"}
26+
className={cn(
27+
fontWeightClass,
28+
"p-0 pb-2 text-body",
29+
isActiveIndex && "!text-[initial]"
30+
)}
31+
disabled={isActiveIndex}
2432
onClick={() => setActiveIndex(index)}
25-
p={0}
26-
pb={2}
27-
color="body.base"
2833
>
2934
{category}
3035
</Button>
3136
) : (
32-
<Text
33-
mb={2}
34-
key={category}
35-
fontWeight={activeIndex === index ? "bold" : "normal"}
36-
>
37+
<p className={cn(fontWeightClass, "mb-2")} key={category}>
3738
{category}
38-
</Text>
39+
</p>
3940
)
40-
)}
41+
})}
4142
</Flex>
4243
)

src/components/Simulator/WalletHome/NFTList.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react"
2-
import { Box, Flex, type FlexProps, Text } from "@chakra-ui/react"
1+
import { TwImage as Image } from "@/components/Image"
2+
import { Flex, type FlexProps } from "@/components/ui/flex"
33

4-
import { Image } from "@/components/Image"
4+
import { cn } from "@/lib/utils/cn"
55

66
import type { NFT } from "./interfaces"
77

@@ -11,26 +11,21 @@ type NFTListProps = FlexProps & {
1111
nfts: Array<NFT>
1212
}
1313
export const NFTList = ({ nfts, ...flexProps }: NFTListProps) => {
14-
const size = useBreakpointValue({ base: 20, md: 24 })
14+
const size = useBreakpointValue({
15+
base: "max-w-20 max-h-20",
16+
md: "max-w-24 max-h-24",
17+
})
1518
return (
16-
<Flex w="full" gap={4} h="full" flexWrap="wrap" {...flexProps}>
19+
<Flex className="size-full flex-wrap gap-4" {...flexProps}>
1720
{nfts.length ? (
1821
nfts.map(({ title, image }) => (
19-
<Box key={title} w="fit-content">
20-
<Image
21-
src={image}
22-
alt=""
23-
objectFit="contain"
24-
maxW={size}
25-
maxH={size}
26-
/>
27-
<Text fontSize="xs" m={0}>
28-
{title}
29-
</Text>
30-
</Box>
22+
<div key={title} className="w-fit">
23+
<Image src={image} alt="" className={cn("object-contain", size)} />
24+
<p className="text-xs">{title}</p>
25+
</div>
3126
))
3227
) : (
33-
<Text>No NFTs yet!</Text>
28+
<p>No NFTs yet!</p>
3429
)}
3530
</Flex>
3631
)
Lines changed: 32 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,63 @@
1-
import React from "react"
2-
import {
3-
type As,
4-
Box,
5-
Grid,
6-
Icon,
7-
Text,
8-
type TextProps,
9-
} from "@chakra-ui/react"
1+
import { type ReactNode } from "react"
2+
import type { IconType } from "react-icons/lib"
3+
4+
import { Button } from "@/components/ui/buttons/Button"
5+
6+
import { cn } from "@/lib/utils/cn"
107

11-
import { Button } from "../../Buttons"
128
import { ClickAnimation } from "../ClickAnimation"
139
import { PulseAnimation } from "../PulseAnimation"
1410

15-
type SendReceiveButtonProps = Pick<TextProps, "children"> & {
16-
icon: As
11+
type SendReceiveButtonProps = {
12+
icon: IconType
1713
isHighlighted: boolean
1814
isDisabled: boolean
1915
onClick?: () => void
2016
isAnimated?: boolean
17+
children: ReactNode
2118
}
2219

2320
export const SendReceiveButton = ({
2421
children,
25-
icon,
22+
icon: Icon,
2623
isHighlighted,
2724
isDisabled,
2825
onClick,
2926
isAnimated,
3027
}: SendReceiveButtonProps) => (
3128
<Button
3229
variant="ghost"
33-
display="flex"
34-
flexDirection="column"
35-
alignItems="center"
30+
className="group flex-col items-center gap-4"
3631
data-group
37-
isDisabled={isDisabled}
32+
disabled={isDisabled}
3833
onClick={onClick}
39-
gap={4}
4034
>
41-
<Grid
42-
bg="primary.base"
43-
borderRadius="full"
44-
placeItems="center"
45-
w={{ base: 10, md: 16 }}
46-
aspectRatio={1}
47-
_groupHover={{ bg: "primary.hover" }}
48-
_groupDisabled={{
49-
background: isHighlighted ? "primary.base" : "body.light",
50-
}}
51-
position="relative"
35+
<div
36+
className={cn(
37+
"relative grid aspect-square w-10 place-items-center rounded-full bg-primary group-hover:bg-primary-hover md:w-16",
38+
isHighlighted
39+
? "group-disabled:bg-primary"
40+
: "group-disabled:bg-body-light"
41+
)}
5242
>
5343
{!isDisabled && isAnimated && <PulseAnimation type="circle" />}
54-
<Icon
55-
as={icon}
56-
w={{ base: 4, md: 6 }}
57-
h={{ base: 4, md: 6 }}
58-
color="background.base"
59-
/>
60-
</Grid>
61-
<Box position="relative">
62-
<Text
63-
fontWeight="bold"
64-
color="primary.base"
65-
textAlign="center"
66-
m={0}
67-
_groupHover={{ color: "primary.hover" }}
68-
_groupDisabled={{
69-
color: isHighlighted ? "primary.base" : "body.medium",
70-
}}
71-
position="relative"
44+
{/* TODO: Remove important flags from class utils when simulator icons are migrated to tailwind */}
45+
<Icon className="!size-4 !text-background md:!size-6" />
46+
</div>
47+
<div className="relative">
48+
<p
49+
className={cn(
50+
"relative text-center font-bold text-primary group-hover:text-primary-hover",
51+
isHighlighted
52+
? "group-disabled:text-primary"
53+
: "group-disabled:text-body-medium"
54+
)}
7255
>
7356
{children}
74-
</Text>
57+
</p>
7558
{!isDisabled && isAnimated && (
7659
<ClickAnimation below>click!</ClickAnimation>
7760
)}
78-
</Box>
61+
</div>
7962
</Button>
8063
)

src/components/Simulator/WalletHome/SendReceiveButtons.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from "react"
22
import { PiPaperPlaneRightFill } from "react-icons/pi"
3-
import { Flex } from "@chakra-ui/react"
3+
4+
import { Flex } from "@/components/ui/flex"
45

56
import { QrCodeIcon } from "../icons"
67
import type { SimulatorNav } from "../interfaces"
@@ -26,7 +27,7 @@ export const SendReceiveButtons = ({
2627
const highlightSend = !nav || !disableSend
2728
const highlightReceive = !nav || !disableReceive
2829
return (
29-
<Flex justify="space-around" w="full" gap={4}>
30+
<Flex className="w-full justify-around gap-4">
3031
<SendReceiveButton
3132
onClick={nav?.progressStepper}
3233
isDisabled={disableSend}
@@ -39,6 +40,7 @@ export const SendReceiveButtons = ({
3940
onClick={nav?.progressStepper}
4041
isDisabled={disableReceive}
4142
isHighlighted={highlightReceive}
43+
// @ts-expect-error icon component needs to be migrated to use react-icons base
4244
icon={QrCodeIcon}
4345
isAnimated
4446
>
Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
import React from "react"
2-
import { Box, Flex, type FlexProps, Text } from "@chakra-ui/react"
1+
import { Flex } from "@/components/ui/flex"
32

43
import { getMaxFractionDigitsUsd } from "../utils"
54

65
import { TokenBalance } from "./interfaces"
76

8-
type TokenBalanceItemProps = FlexProps & {
7+
type TokenBalanceItemProps = {
98
item: TokenBalance
109
}
11-
export const TokenBalanceItem = ({
12-
item,
13-
...flexProps
14-
}: TokenBalanceItemProps) => {
10+
export const TokenBalanceItem = ({ item }: TokenBalanceItemProps) => {
1511
const { name, ticker, amount, usdConversion, Icon } = item
1612
const usdAmount = amount * usdConversion
1713
const usdValue = Intl.NumberFormat("en-US", {
@@ -24,23 +20,15 @@ export const TokenBalanceItem = ({
2420
maximumFractionDigits: 5,
2521
}).format(amount)
2622
return (
27-
<Flex gap={4} {...flexProps}>
23+
<Flex className="gap-4">
2824
<Icon />
29-
<Text flex={1} fontWeight="medium">
30-
{name}
31-
</Text>
32-
<Box
33-
textAlign="end"
34-
fontSize="sm"
35-
lineHeight={1.5}
36-
fontWeight="bold"
37-
sx={{ p: { m: 0 } }}
38-
>
39-
<Text>{usdValue}</Text>
40-
<Text color="body.medium">
25+
<p className="flex-1 font-medium">{name}</p>
26+
<div className="text-end text-sm font-bold leading-normal [&_p]:m-0">
27+
<p>{usdValue}</p>
28+
<p className="text-body-medium">
4129
{tokenAmount} {ticker}
42-
</Text>
43-
</Box>
30+
</p>
31+
</div>
4432
</Flex>
4533
)
4634
}

src/components/Simulator/WalletHome/TokenBalanceList.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
import React from "react"
2-
import { Flex, type FlexProps } from "@chakra-ui/react"
1+
import { Flex } from "@/components/ui/flex"
32

43
import { type TokenBalance } from "./interfaces"
54
import { TokenBalanceItem } from "./TokenBalanceItem"
65

7-
type TokenBalanceListProps = FlexProps & {
6+
type TokenBalanceListProps = {
87
tokenBalances: Array<TokenBalance>
98
}
10-
export const TokenBalanceList = ({
11-
tokenBalances,
12-
...flexProps
13-
}: TokenBalanceListProps) => {
9+
export const TokenBalanceList = ({ tokenBalances }: TokenBalanceListProps) => {
1410
return (
15-
<Flex direction="column" w="full" gap={4} {...flexProps}>
11+
<Flex className="w-full flex-col gap-4">
1612
{tokenBalances.map((item) => (
1713
<TokenBalanceItem key={item.name} item={item} />
1814
))}

0 commit comments

Comments
 (0)