Skip to content

Commit 0ed6557

Browse files
authored
Merge pull request #14226 from kushagrasarathe/migrateHorizontalCard
feat: migrate HorizontalCard to tailwind
2 parents 0a0da82 + 136e3a9 commit 0ed6557

File tree

6 files changed

+39
-40
lines changed

6 files changed

+39
-40
lines changed

src/components/HorizontalCard.tsx

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
import React, { ReactNode } from "react"
2-
import { Box, Flex, FlexProps } from "@chakra-ui/react"
32

43
import { cn } from "@/lib/utils/cn"
54

65
import Emoji from "./Emoji"
7-
import Text from "./OldText"
86

9-
export type HorizontalCardProps = Omit<FlexProps, "title"> & {
7+
export interface HorizontalCardProps
8+
extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
109
emoji: string
10+
emojiClassName?: string
1111
title?: ReactNode
1212
description: ReactNode
13+
children?: ReactNode
1314
}
1415

1516
const HorizontalCard = ({
1617
emoji,
18+
emojiClassName,
1719
title,
1820
description,
1921
children,
2022
className,
21-
...rest
22-
}: HorizontalCardProps) => (
23-
<Flex borderRadius="base" {...rest}>
24-
<Emoji className={cn("text-5xl", className)} text={emoji} />
25-
<Box flexGrow="0" flexShrink="1" flexBasis="75%" ms="8">
26-
<Text fontSize="lg">{title}</Text>
27-
<Text mt="-4" mb="2">
28-
{description}
29-
</Text>
30-
<>{children}</>
31-
</Box>
32-
</Flex>
33-
)
23+
...props
24+
}: HorizontalCardProps) => {
25+
return (
26+
<div className={cn("flex items-center gap-8", className)} {...props}>
27+
<Emoji text={emoji} className={cn("text-5xl", emojiClassName)} />
28+
<div className="flex-shrink flex-grow-0 basis-3/4 space-y-2">
29+
<p className="text-lg">{title}</p>
30+
<p>{description}</p>
31+
{children}
32+
</div>
33+
</div>
34+
)
35+
}
3436

3537
export default HorizontalCard

src/components/Stat/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ const Stat = ({ tooltipProps, value, label, isError }: StatProps) => {
5656
)
5757
}
5858

59-
export default Stat
59+
export default Stat

src/pages/eth.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
3434
import Translation from "@/components/Translation"
3535
import { Divider } from "@/components/ui/divider"
3636

37+
import { cn } from "@/lib/utils/cn"
3738
import { existsNamespace } from "@/lib/utils/existsNamespace"
3839
import { getLastDeployDate } from "@/lib/utils/getLastDeployDate"
3940
import { getLocaleTimestamp } from "@/lib/utils/time"
@@ -212,9 +213,12 @@ const CardContainer = (props: FlexProps) => (
212213
)
213214

214215
const TokenCard = (props: ComponentProps<typeof HorizontalCard>) => (
215-
<HorizontalCard minW="full" my={2} mx={0} borderRadius={0} {...props} />
216+
<HorizontalCard
217+
className={cn("mx-0 my-2 min-w-full rounded-none", props.className)}
218+
emojiClassName="text-[5rem]"
219+
{...props}
220+
/>
216221
)
217-
218222
const TextDivider = () => (
219223
<Box
220224
w="10%"
@@ -554,7 +558,6 @@ const EthPage = () => {
554558
emoji={token.emoji}
555559
title={token.title}
556560
description={token.description}
557-
className="text-[5rem]"
558561
/>
559562
))}
560563
</RightColumn>

src/pages/gas.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ const GasPage = () => {
298298
key={benefit.emoji}
299299
emoji={benefit.emoji}
300300
description={benefit.description}
301-
className="text-5xl"
302-
align="center"
303301
/>
304302
</Box>
305303
))}

src/pages/stablecoins.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,17 +456,21 @@ const StablecoinsPage = ({ markets, marketsHasError }) => {
456456
me={{ base: 0, lg: 8 }}
457457
mb={8}
458458
>
459-
<Box w="full" margin={{ base: "auto 0", lg: "0 2rem 0" }}>
459+
<Flex
460+
w="full"
461+
margin={{ base: "auto 0", lg: "0 2rem 0" }}
462+
direction="column"
463+
gap={2}
464+
>
460465
{tokens.map((token, index) => (
461466
<Box key={index} minWidth="full" my={2}>
462467
<HorizontalCard
463468
emoji={token.emoji}
464469
description={token.description}
465-
className="text-5xl"
466470
/>
467471
</Box>
468472
))}
469-
</Box>
473+
</Flex>
470474
<GhostCard className="me-0 mt-16 max-w-[640px] lg:me-8 lg:mt-2">
471475
<Emoji text=":pizza:" className="text-5xl" />
472476
<H3>{t("page-stablecoins-bitcoin-pizza")}</H3>

src/pages/wallets/index.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ export const StyledCard = (props: ComponentPropsWithRef<typeof Card>) => (
117117
)
118118
const ChecklistItem = (props: HorizontalCardProps) => (
119119
<HorizontalCard
120-
border={0}
121-
display="flex"
122-
className="text-2xl"
123-
alignItems="flex-start"
124-
mb={4}
120+
emojiClassName="text-2xl"
121+
className="items-start"
125122
{...props}
126123
/>
127124
)
@@ -359,19 +356,14 @@ const WalletsPage = () => {
359356
<RightColumn mt={{ base: 12, lg: 0 }}>
360357
<H2>{t("page-wallets-types")}</H2>
361358
<Text>{t("page-wallets-types-desc")}</Text>
362-
<Box>
359+
<Box className="flex flex-col gap-2">
363360
{types.map((type, idx) => (
364361
<HorizontalCard
365-
minWidth="100%"
366-
marginTop={2}
367-
marginBottom={2}
368-
ms={0}
369-
me={0}
370362
key={idx}
371363
emoji={type.emoji}
372364
description={type.description}
373-
className="text-[2.5rem]"
374-
alignItems="center"
365+
className="my-0.5 w-[100%]"
366+
emojiClassName="text-[2.5rem]"
375367
/>
376368
))}
377369
</Box>
@@ -447,7 +439,7 @@ const WalletsPage = () => {
447439
<Box lineHeight={1.4} mb={6} color="text300">
448440
<Translation id="page-wallets:page-wallets-stay-safe-desc" />
449441
</Box>
450-
<Box>
442+
<Flex direction="column" gap={4}>
451443
<ChecklistItem
452444
key="0"
453445
emoji=":white_check_mark:"
@@ -480,7 +472,7 @@ const WalletsPage = () => {
480472
title={t("page-wallets-triple-check")}
481473
description={t("page-wallets-triple-check-desc")}
482474
/>
483-
</Box>
475+
</Flex>
484476
</LeftColumn>
485477
<RightColumn mt={{ base: 12, lg: 0 }}>
486478
<H2>{t("page-wallets-tips")}</H2>

0 commit comments

Comments
 (0)