Skip to content

Commit 40162af

Browse files
authored
Merge pull request #14764 from JoeChenJ/Shadcn_Migrate_eth.tsx
Shadcn Migrate: eth.tsx
2 parents 4dc5f04 + 10b09f0 commit 40162af

File tree

1 file changed

+64
-133
lines changed

1 file changed

+64
-133
lines changed

src/pages/eth.tsx

Lines changed: 64 additions & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
11
import { GetStaticProps } from "next"
22
import { useTranslation } from "next-i18next"
33
import { serverSideTranslations } from "next-i18next/serverSideTranslations"
4-
import type { ComponentProps } from "react"
5-
import {
6-
Box,
7-
Flex,
8-
type FlexProps,
9-
Heading,
10-
type HeadingProps,
11-
ListItem,
12-
UnorderedList,
13-
} from "@chakra-ui/react"
4+
import type { ComponentProps, HTMLAttributes } from "react"
145

156
import type { BasePageProps, ChildOnlyProp, Lang } from "@/lib/types"
167

178
import ActionCard from "@/components/ActionCard"
18-
import ButtonLink from "@/components/Buttons/ButtonLink"
199
import CalloutBanner from "@/components/CalloutBanner"
2010
import Card from "@/components/Card"
2111
import CardList from "@/components/CardList"
2212
import EthPriceCard from "@/components/EthPriceCard"
2313
import EthVideo from "@/components/EthVideo"
2414
import FeedbackCard from "@/components/FeedbackCard"
2515
import HorizontalCard from "@/components/HorizontalCard"
26-
import { Image } from "@/components/Image"
16+
import { TwImage } from "@/components/Image"
2717
import InfoBanner from "@/components/InfoBanner"
28-
import InlineLink from "@/components/Link"
2918
import MainArticle from "@/components/MainArticle"
30-
import OldHeading from "@/components/OldHeading"
31-
import Text from "@/components/OldText"
3219
import PageMetadata from "@/components/PageMetadata"
3320
import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
3421
import Translation from "@/components/Translation"
22+
import { ButtonLink } from "@/components/ui/buttons/Button"
3523
import { Divider } from "@/components/ui/divider"
24+
import { Flex, VStack } from "@/components/ui/flex"
25+
import InlineLink from "@/components/ui/Link"
26+
import { ListItem, UnorderedList } from "@/components/ui/list"
3627

3728
import { cn } from "@/lib/utils/cn"
3829
import { existsNamespace } from "@/lib/utils/existsNamespace"
@@ -46,166 +37,119 @@ import defi from "@/public/images/finance_transparent.png"
4637
import ethereum from "@/public/images/what-is-ethereum.png"
4738

4839
const Page = (props: ChildOnlyProp) => (
49-
<Flex
50-
as={MainArticle}
51-
direction="column"
52-
align="center"
53-
w="full"
54-
my={0}
55-
mx="auto"
40+
<MainArticle
41+
className="mx-auto my-0 flex w-full flex-col items-center"
5642
{...props}
5743
/>
5844
)
5945

6046
const Content = (props: ChildOnlyProp) => (
61-
<Box w="full" px={8} py={4} {...props} />
47+
<div className="w-full px-8 py-4" {...props} />
6248
)
6349

6450
const GrayContainer = (props: ChildOnlyProp) => (
65-
<Box
66-
width="full"
67-
py={16}
68-
mt={8}
69-
background="grayBackground"
70-
boxShadow="inset 0px 1px 0px var(--eth-colors-tableItemBoxShadow)"
51+
<div
52+
className="mt-8 w-full border-t bg-background-highlight py-16 shadow-table-item-box"
7153
{...props}
7254
/>
7355
)
7456

7557
const Intro = (props: ChildOnlyProp) => (
76-
<Box maxW="608px" mb={{ base: 12, sm: 16 }} {...props} />
58+
<div className="mb-12 max-w-[608px] sm:mb-16" {...props} />
7759
)
7860

7961
const StyledCard = (props: ComponentProps<typeof Card>) => (
8062
<Card
81-
className="m-4 min-w-[280px] max-w-full flex-[1_0_30%] p-6 md:max-w-[46%] lg:max-w-[31%]"
63+
className="m-4 min-w-[280px] max-w-full flex-[1_0_30%] bg-background p-6 md:max-w-[46%] lg:max-w-[31%]"
8264
{...props}
8365
/>
8466
)
8567

8668
const Slogan = (props: ChildOnlyProp) => (
87-
<Text
88-
textStyle="normal"
89-
fontWeight="normal"
90-
fontSize="2rem"
91-
lineHeight={1.4}
92-
{...props}
93-
/>
69+
<h3 className="mb-6 leading-xs" {...props} />
9470
)
9571

9672
const Title = (props: ChildOnlyProp) => (
97-
<Heading
98-
as="h1"
99-
fontSize="sm"
100-
lineHeight={1.4}
101-
letterSpacing="0.04em"
102-
fontWeight="500"
103-
mb={4}
104-
textTransform="uppercase"
105-
color="textTableOfContents"
73+
<h1
74+
className="mb-4 mt-0 text-md font-normal uppercase !leading-xs"
10675
{...props}
10776
/>
10877
)
10978

11079
const Subtitle = (props: ChildOnlyProp) => (
111-
<Text fontSize="xl" lineHeight={1.4} color="text200" {...props} />
80+
<Text className="mb-0 leading-xs text-body-medium" {...props} />
81+
)
82+
83+
const Text = ({ className, ...props }: HTMLAttributes<HTMLHeadingElement>) => (
84+
<p className={cn("mb-6", className)} {...props} />
11285
)
11386

114-
export const TwoColumnContent = (props: FlexProps) => (
87+
export const TwoColumnContent = ({
88+
className,
89+
...props
90+
}: HTMLAttributes<HTMLHeadingElement>) => (
11591
<Flex
116-
w="full"
117-
direction={{ base: "column", lg: "row" }}
118-
justify="space-between"
119-
p={8}
120-
mb={12}
92+
className={cn(
93+
"mb-12 w-full flex-col justify-between p-8 lg:flex-row",
94+
className
95+
)}
12196
{...props}
12297
/>
12398
)
12499

125100
export const LeftColumn = (props: ChildOnlyProp) => (
126-
<Box
127-
flex="0 0 50%"
128-
maxW={{ base: "full", lg: "75%" }}
129-
me={{ lg: 16 }}
101+
<div
102+
className="max-w-full flex-none basis-1/2 lg:me-16 lg:max-w-[75%]"
130103
{...props}
131104
/>
132105
)
133106

134107
export const RightColumn = (props: ChildOnlyProp) => (
135108
<Flex
136-
flex="0 1 50%"
137-
direction="column"
138-
justify="center"
139-
maxW={{ base: "full", lg: "75%" }}
140-
mt={{ base: 12, lg: 0 }}
109+
className="mt-12 max-w-full flex-shrink flex-grow-0 basis-1/2 flex-col justify-center lg:mt-0 lg:max-w-[75%]"
141110
{...props}
142111
/>
143112
)
144113

145114
const SubtitleTwo = (props: ChildOnlyProp) => (
146-
<Text fontSize="xl" lineHeight={1.4} color="text300" mb={8} {...props} />
115+
<Text className="mb-8 leading-xs text-body-menu-medium" {...props} />
147116
)
148117

149118
const HeroContainer = (props: ChildOnlyProp) => (
150119
<Flex
151-
align="center"
152-
justify="space-between"
153-
direction={{ base: "column-reverse", md: "row" }}
120+
className="flex-col-reverse items-center justify-between md:flex-row"
154121
{...props}
155122
/>
156123
)
157124

158125
const Hero = (props: ChildOnlyProp) => (
159-
<Box
160-
flex="1 1 100%"
161-
maxW="800px"
162-
bgSize="cover"
163-
bgRepeat="no-repeat"
164-
ms={{ base: 0, md: 8 }}
126+
<div
127+
className="ms-0 max-w-[800px] flex-1 basis-full bg-cover bg-no-repeat md:ms-8"
165128
{...props}
166129
/>
167130
)
168131

169132
const Header = (props: ChildOnlyProp) => (
170-
<Box
171-
as="header"
172-
flex="1 1 50%"
173-
minW="300px"
174-
mt={{ base: 6, md: 32 }}
175-
{...props}
176-
/>
133+
<div className="mt-6 min-w-[300px] flex-1 basis-1/2 md:mt-32" {...props} />
177134
)
178135

179-
const H2 = (prop: HeadingProps) => (
180-
<OldHeading
181-
fontSize={{ base: "2xl", md: "2rem" }}
182-
lineHeight={1.4}
183-
mt={0}
184-
{...prop}
185-
/>
136+
const H2 = (props: ChildOnlyProp) => (
137+
<h2 className="mb-8 mt-0 leading-xs" {...props} />
186138
)
187139

188-
const H3 = (props: HeadingProps) => (
189-
<OldHeading
190-
as="h3"
191-
fontSize={{ base: "xl", md: "2xl" }}
192-
lineHeight={1.4}
193-
{...props}
194-
/>
140+
const H3 = (props: ChildOnlyProp) => (
141+
<h3 className="mb-8 mt-10 leading-xs" {...props} />
195142
)
196143

197-
const H4 = (props: HeadingProps) => (
198-
<OldHeading
199-
as="h4"
200-
fontSize={{ base: "md", md: "xl" }}
201-
fontWeight={600}
202-
lineHeight={1.4}
203-
{...props}
204-
/>
144+
const H4 = (props: ChildOnlyProp) => (
145+
<h4 className="my-8 leading-xs" {...props} />
205146
)
206147

207-
const CardContainer = (props: FlexProps) => (
208-
<Flex wrap="wrap" mx={-4} {...props} />
148+
const CardContainer = ({
149+
className,
150+
...props
151+
}: HTMLAttributes<HTMLHeadingElement>) => (
152+
<Flex className={cn("-mx-4 flex-wrap", className)} {...props} />
209153
)
210154

211155
const TokenCard = (props: ComponentProps<typeof HorizontalCard>) => (
@@ -216,24 +160,11 @@ const TokenCard = (props: ComponentProps<typeof HorizontalCard>) => (
216160
/>
217161
)
218162
const TextDivider = () => (
219-
<Box
220-
w="10%"
221-
h="1px"
222-
bg="searchResultBackground"
223-
my={8}
224-
alignSelf={{ lg: "flex-start" }}
225-
/>
163+
<div className="my-8 w-[10%] bg-search-background lg:items-start" />
226164
)
227165

228166
const CentralColumn = (props: ChildOnlyProp) => (
229-
<Flex
230-
direction="column"
231-
align="center"
232-
maxW="960px"
233-
my={16}
234-
mx="auto"
235-
{...props}
236-
/>
167+
<VStack className="mx-auto my-16 max-w-[960px]" {...props} />
237168
)
238169

239170
const CentralActionCard = (props: ComponentProps<typeof ActionCard>) => (
@@ -375,7 +306,7 @@ const EthPage = () => {
375306
</ButtonLink>
376307
</Header>
377308
<Hero>
378-
<Image
309+
<TwImage
379310
src={eth}
380311
// TODO: adjust value when the old theme breakpoints are removed (src/theme.ts)
381312
sizes="(max-width: 768px) 100vw, 800px"
@@ -390,7 +321,7 @@ const EthPage = () => {
390321
<Intro>
391322
<Text>{t("page-eth-description")} </Text>
392323
</Intro>
393-
<CardContainer mb={8}>
324+
<CardContainer className="mb-8">
394325
{benefits.map((benefits, idx) => (
395326
<StyledCard
396327
key={idx}
@@ -401,7 +332,7 @@ const EthPage = () => {
401332
))}
402333
</CardContainer>
403334
<InfoBanner emoji=":wave:" shouldCenter>
404-
<Text as="b">{t("page-eth-buy-some")}</Text>{" "}
335+
<b>{t("page-eth-buy-some")}</b>{" "}
405336
<Translation id="page-eth:page-eth-buy-some-desc" />{" "}
406337
<InlineLink href="/what-is-ethereum/">
407338
{t("page-eth-more-on-ethereum-link")}
@@ -415,13 +346,13 @@ const EthPage = () => {
415346
<H2>{t("page-eth-whats-unique")}</H2>
416347
<Text>{t("page-eth-whats-unique-desc")}</Text>
417348
<EthVideo />
418-
<Box>
349+
<div>
419350
<H4>{t("page-eth-fuels")}</H4>
420351
<Text>{t("page-eth-fuels-desc")}</Text>
421352
<Text>{t("page-eth-fuels-desc-2")}</Text>
422353
<Text>
423354
<Translation id="page-eth:page-eth-fuels-desc-3" />{" "}
424-
<Text as="strong">{t("page-eth-powers-ethereum")}</Text>
355+
<b>{t("page-eth-powers-ethereum")}</b>
425356
{t("page-eth-period")}
426357
</Text>
427358
<Text>
@@ -430,15 +361,15 @@ const EthPage = () => {
430361
{t("page-eth-fuels-more-staking")}
431362
</InlineLink>
432363
</Text>
433-
</Box>
364+
</div>
434365
<CentralActionCard
435366
href="/what-is-ethereum/"
436367
title={t("page-eth-whats-ethereum")}
437368
description={t("page-eth-whats-ethereum-desc")}
438369
image={ethereum}
439370
/>
440371
<TextDivider />
441-
<Box>
372+
<div>
442373
<H4>{t("page-eth-underpins")}</H4>
443374
<Text>
444375
<Translation id="page-eth:page-eth-underpins-desc" />
@@ -453,9 +384,9 @@ const EthPage = () => {
453384
<InfoBanner isWarning>
454385
<Translation id="page-eth:page-eth-weth" />
455386
</InfoBanner>
456-
</Box>
387+
</div>
457388
<TextDivider />
458-
<Box>
389+
<div>
459390
<H4>{t("page-eth-uses")}</H4>
460391
<Text>{t("page-eth-uses-desc")}</Text>
461392
<Text>{t("page-eth-uses-desc-2")} </Text>
@@ -485,7 +416,7 @@ const EthPage = () => {
485416
{t("page-eth-uses-desc-6")}
486417
</ListItem>
487418
</UnorderedList>
488-
</Box>
419+
</div>
489420
<Divider />
490421
</CentralColumn>
491422
<CalloutBanner
@@ -496,11 +427,11 @@ const EthPage = () => {
496427
alt={t("page-eth-cat-img-alt")}
497428
imageWidth={300}
498429
>
499-
<Box>
430+
<div>
500431
<ButtonLink href="/get-eth/">
501432
{t("page-eth-get-eth-btn")}
502433
</ButtonLink>
503-
</Box>
434+
</div>
504435
</CalloutBanner>
505436
</Content>
506437

@@ -517,12 +448,12 @@ const EthPage = () => {
517448
<CardList items={cardListContent} />
518449
</RightColumn>
519450
</TwoColumnContent>
520-
<TwoColumnContent id="tokens" align="flex-start">
451+
<TwoColumnContent className="items-start" id="tokens">
521452
<LeftColumn>
522453
<H3>{t("page-eth-not-only-crypto")}</H3>
523454
<Text>{t("page-eth-not-only-crypto-desc")} </Text>
524455
<Text>{t("page-eth-not-only-crypto-desc-2")}</Text>
525-
<H4 fontWeight="normal">{t("page-eth-more-on-tokens")}</H4>
456+
<H4>{t("page-eth-more-on-tokens")}</H4>
526457
<CardList items={tokenLinks} />
527458
</LeftColumn>
528459
<RightColumn>

0 commit comments

Comments
 (0)