Skip to content

Commit f0fc8b7

Browse files
authored
Merge pull request #14683 from ethereum/card-shadcn
feat: migrate Card to tailwind
2 parents 6686d9a + bdc92da commit f0fc8b7

File tree

14 files changed

+43
-91
lines changed

14 files changed

+43
-91
lines changed

src/components/Card/index.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,44 @@
11
import { ReactNode } from "react"
2-
import { Heading, Stack, StackProps, Text } from "@chakra-ui/react"
32

43
import Emoji from "@/components/Emoji"
54

6-
export type CardProps = Omit<StackProps, "children" | "title"> & {
5+
import { cn } from "@/lib/utils/cn"
6+
7+
export type CardProps = {
78
children?: ReactNode
89
emoji?: string
910
title?: ReactNode
1011
description?: ReactNode
12+
className?: string
1113
}
1214

13-
const Card = ({ emoji, title, description, children, ...props }: CardProps) => (
14-
<Stack
15-
spacing="4"
16-
justifyContent="space-between"
17-
bg="ednBackground"
18-
borderRadius="sm"
19-
border="1px"
20-
borderStyle="solid"
21-
borderColor="lightBorder"
22-
p="6"
15+
const Card = ({
16+
emoji,
17+
title,
18+
description,
19+
children,
20+
className,
21+
...props
22+
}: CardProps) => (
23+
<div
24+
className={cn(
25+
"flex flex-col justify-between space-y-4",
26+
"rounded-sm bg-background-highlight",
27+
"border border-solid",
28+
"p-6",
29+
className
30+
)}
2331
{...props}
2432
>
25-
<Stack spacing="4">
33+
<div className="flex flex-col space-y-4">
2634
{emoji && <Emoji className="text-5xl leading-none" text={emoji} />}
27-
<Stack spacing="8">
28-
{title && (
29-
<Heading as="h3" fontSize="2xl">
30-
{title}
31-
</Heading>
32-
)}
33-
{description && <Text>{description}</Text>}
34-
</Stack>
35-
</Stack>
35+
<div className="flex flex-col space-y-8">
36+
{title && <h3 className="text-2xl leading-[1.4]">{title}</h3>}
37+
{description && <p>{description}</p>}
38+
</div>
39+
</div>
3640
{children}
37-
</Stack>
41+
</div>
3842
)
3943

4044
export default Card

src/components/Trilemma/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ const Trilemma = () => {
3535
{t("page-roadmap-vision-trilemma-modal-tip")}:
3636
</p>
3737
</VStack>
38-
<Card {...cardDetail} minH="300px" hideBelow="lg" mt="6" />
38+
<Card {...cardDetail} className="mt-6 hidden min-h-[300px] lg:block" />
3939
</Stack>
4040
<Sheet open={mobileModalOpen} onOpenChange={handleModalClose}>
4141
<SheetContent side="bottom" className="rounded-t-[16px]">
42-
<Card {...cardDetail} background="none" border="none" my="8" />
42+
<Card {...cardDetail} className="my-8 border-none bg-transparent" />
4343
<SheetClose className="absolute right-3 top-5">
4444
<span className="sr-only">Close</span>
4545
<svg

src/layouts/md/Translatathon.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ const EmojiCard = ({ emoji, title, description }) => (
7575
emoji={emoji}
7676
title={title}
7777
description={description}
78-
flex="1 1 30%"
79-
p={6}
78+
className="flex-[1_1_30%] p-6"
8079
/>
8180
)
8281

src/pages/bug-bounty.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ const StyledCardContainer = (props: ChildOnlyProp) => (
254254
)
255255

256256
const StyledCard = ({ children, ...props }) => (
257-
<Card flex="1 1 464px" m="4" p="6" justifyContent="flex-start" {...props}>
257+
<Card className="m-4 flex-[1_1_464px] justify-start p-6" {...props}>
258258
{children}
259259
</Card>
260260
)
@@ -473,7 +473,7 @@ const BugBountiesPage = () => {
473473
title={t("page-upgrades-bug-bounty-meta-title")}
474474
description={t("page-upgrades-bug-bounty-meta-description")}
475475
/>
476-
{ /* TODO: Remove on the 25th of January */ }
476+
{/* TODO: Remove on the 25th of January */}
477477
<BugBountyBanner />
478478
<Content>
479479
<HeroCard>

src/pages/community.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,7 @@ const CommunityPage = () => {
251251
<CardContainer>
252252
{whyGetInvolvedCards.map((card, idx) => (
253253
<Card
254-
m={4}
255-
p={6}
256-
flex="1 0 30%"
257-
minW="280px"
258-
maxW={{ base: "full", md: "46%", lg: "31%" }}
254+
className="m-4 min-w-[280px] max-w-full flex-[1_0_30%] p-6 md:max-w-[46%] lg:max-w-[31%]"
259255
key={idx}
260256
emoji={card.emoji}
261257
title={card.title}

src/pages/dapps.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1821,7 +1821,7 @@ const DappsPage = () => {
18211821
{(categories[selectedCategory].benefits || []).map(
18221822
(art, idx) => (
18231823
<Card
1824-
textAlign="center"
1824+
className="text-center"
18251825
key={idx}
18261826
emoji={art.emoji}
18271827
title={art.title}

src/pages/developers/index.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
SimpleGrid,
1111
Stack,
1212
TextProps,
13-
useColorModeValue,
1413
} from "@chakra-ui/react"
1514

1615
import { BasePageProps, ChildOnlyProp, Lang } from "@/lib/types"
@@ -115,21 +114,10 @@ const IntroColumn = (props: ChildOnlyProp) => (
115114
)
116115

117116
const StyledCard = (props: CardProps) => {
118-
const tableBoxShadow = useColorModeValue("tableBox.light", "tableBox.dark")
119-
120117
return (
121118
<Card
122-
boxShadow={tableBoxShadow}
123-
m={4}
124-
p={6}
119+
className={`m-4 p-6 shadow-[0px_1px_3px_rgba(0,0,0,0.1)] transition-transform duration-100 hover:scale-105 hover:rounded hover:bg-background-highlight hover:shadow-[0px_8px_17px_rgba(0,0,0,0.15)] dark:shadow-[0px_1px_3px_rgba(60,60,60,0.1)]`}
125120
{...props}
126-
_hover={{
127-
borderRadius: "4px",
128-
boxShadow: "0px 8px 17px rgba(0, 0, 0, 0.15)",
129-
background: "tableBackgroundHover",
130-
transition: "transform 0.1s",
131-
transform: "scale(1.02)",
132-
}}
133121
/>
134122
)
135123
}

src/pages/eth.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,7 @@ const Intro = (props: ChildOnlyProp) => (
7878

7979
const StyledCard = (props: ComponentProps<typeof Card>) => (
8080
<Card
81-
m={4}
82-
p={6}
83-
flex="1 0 30%"
84-
minW="280px"
85-
maxW={{ base: "full", md: "46%", lg: "31%" }}
81+
className="m-4 min-w-[280px] max-w-full flex-[1_0_30%] p-6 md:max-w-[46%] lg:max-w-[31%]"
8682
{...props}
8783
/>
8884
)

src/pages/gas.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,7 @@ const Page = (props: FlexProps) => (
7070

7171
export const StyledCard = (props: ComponentPropsWithRef<typeof Card>) => (
7272
<Card
73-
flex="1 1 30%"
74-
minW="280px"
75-
maxW={{ base: "full", lg: "46%" }}
76-
p={6}
73+
className="min-w-[280px] max-w-full flex-[1_0_30%] p-6 md:max-w-[46%]"
7774
{...props}
7875
/>
7976
)

src/pages/learn.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,7 @@ import whatIsEth from "@/public/images/what-is-ethereum.png"
4949

5050
// TODO: Migrate the original Card component before updating this
5151
const Card = ({ children, ...props }: OriginalCardProps) => (
52-
<OriginalCard
53-
justifyContent="space-between"
54-
sx={{
55-
h3: {
56-
mt: 0,
57-
},
58-
}}
59-
{...props}
60-
>
52+
<OriginalCard className="justify-between [&_h3]:mt-0" {...props}>
6153
{children}
6254
</OriginalCard>
6355
)
@@ -447,8 +439,7 @@ const LearnPage = () => {
447439
</>
448440
</Card>
449441
<Card
450-
justifyContent="start"
451-
bg="cardGradient"
442+
className="justify-start bg-gradient-main"
452443
title={t("emerging-use-cases-title")}
453444
description={t("emerging-use-cases-description")}
454445
>

0 commit comments

Comments
 (0)