Skip to content

Commit 9116d04

Browse files
committed
Miigrate eth page to Shadcn
1 parent e2fa609 commit 9116d04

File tree

1 file changed

+62
-123
lines changed

1 file changed

+62
-123
lines changed

src/pages/eth.tsx

Lines changed: 62 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,30 @@
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"
15+
import Heading from "@/components/Heading"
2516
import HorizontalCard from "@/components/HorizontalCard"
26-
import { Image } from "@/components/Image"
17+
import { TwImage } from "@/components/Image"
2718
import InfoBanner from "@/components/InfoBanner"
28-
import InlineLink from "@/components/Link"
2919
import MainArticle from "@/components/MainArticle"
30-
import OldHeading from "@/components/OldHeading"
31-
import Text from "@/components/OldText"
3220
import PageMetadata from "@/components/PageMetadata"
3321
import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
3422
import Translation from "@/components/Translation"
23+
import { ButtonLink } from "@/components/ui/buttons/Button"
3524
import { Divider } from "@/components/ui/divider"
25+
import { Flex, VStack } from "@/components/ui/flex"
26+
import InlineLink from "@/components/ui/Link"
27+
import { ListItem, UnorderedList } from "@/components/ui/list"
3628

3729
import { cn } from "@/lib/utils/cn"
3830
import { existsNamespace } from "@/lib/utils/existsNamespace"
@@ -46,34 +38,25 @@ import defi from "@/public/images/finance_transparent.png"
4638
import ethereum from "@/public/images/what-is-ethereum.png"
4739

4840
const Page = (props: ChildOnlyProp) => (
49-
<Flex
50-
as={MainArticle}
51-
direction="column"
52-
align="center"
53-
w="full"
54-
my={0}
55-
mx="auto"
41+
<MainArticle
42+
className="mx-auto my-0 flex w-full flex-col items-center"
5643
{...props}
5744
/>
5845
)
5946

6047
const Content = (props: ChildOnlyProp) => (
61-
<Box w="full" px={8} py={4} {...props} />
48+
<div className="w-full px-8 py-4" {...props} />
6249
)
6350

6451
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)"
52+
<div
53+
className="mt-8 w-full border-t bg-background-highlight py-16 shadow-table-item-box"
7154
{...props}
7255
/>
7356
)
7457

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

7962
const StyledCard = (props: ComponentProps<typeof Card>) => (
@@ -88,13 +71,7 @@ const StyledCard = (props: ComponentProps<typeof Card>) => (
8871
)
8972

9073
const Slogan = (props: ChildOnlyProp) => (
91-
<Text
92-
textStyle="normal"
93-
fontWeight="normal"
94-
fontSize="2rem"
95-
lineHeight={1.4}
96-
{...props}
97-
/>
74+
<h3 className="mb-6 leading-xs" {...props} />
9875
)
9976

10077
const Title = (props: ChildOnlyProp) => (
@@ -112,104 +89,79 @@ const Title = (props: ChildOnlyProp) => (
11289
)
11390

11491
const Subtitle = (props: ChildOnlyProp) => (
115-
<Text fontSize="xl" lineHeight={1.4} color="text200" {...props} />
92+
<Text className="leading-xs text-body-medium" {...props} />
93+
)
94+
95+
const Text = ({ className, ...props }: HTMLAttributes<HTMLHeadingElement>) => (
96+
<p className={cn("mb-6", className)} {...props} />
11697
)
11798

118-
export const TwoColumnContent = (props: FlexProps) => (
99+
export const TwoColumnContent = ({
100+
className,
101+
...props
102+
}: HTMLAttributes<HTMLHeadingElement>) => (
119103
<Flex
120-
w="full"
121-
direction={{ base: "column", lg: "row" }}
122-
justify="space-between"
123-
p={8}
124-
mb={12}
104+
className={cn(
105+
"mb-12 w-full flex-col justify-between p-8 lg:flex-row",
106+
className
107+
)}
125108
{...props}
126109
/>
127110
)
128111

129112
export const LeftColumn = (props: ChildOnlyProp) => (
130-
<Box
131-
flex="0 0 50%"
132-
maxW={{ base: "full", lg: "75%" }}
133-
me={{ lg: 16 }}
113+
<div
114+
className="max-w-full flex-none basis-1/2 lg:me-16 lg:max-w-[75%]"
134115
{...props}
135116
/>
136117
)
137118

138119
export const RightColumn = (props: ChildOnlyProp) => (
139120
<Flex
140-
flex="0 1 50%"
141-
direction="column"
142-
justify="center"
143-
maxW={{ base: "full", lg: "75%" }}
144-
mt={{ base: 12, lg: 0 }}
121+
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%]"
145122
{...props}
146123
/>
147124
)
148125

149126
const SubtitleTwo = (props: ChildOnlyProp) => (
150-
<Text fontSize="xl" lineHeight={1.4} color="text300" mb={8} {...props} />
127+
<Text className="mb-8 leading-xs text-body-menu-medium" {...props} />
151128
)
152129

153130
const HeroContainer = (props: ChildOnlyProp) => (
154131
<Flex
155-
align="center"
156-
justify="space-between"
157-
direction={{ base: "column-reverse", md: "row" }}
132+
className="flex-col-reverse items-center justify-between md:flex-row"
158133
{...props}
159134
/>
160135
)
161136

162137
const Hero = (props: ChildOnlyProp) => (
163-
<Box
164-
flex="1 1 100%"
165-
maxW="800px"
166-
bgSize="cover"
167-
bgRepeat="no-repeat"
168-
ms={{ base: 0, md: 8 }}
138+
<div
139+
className="ms-0 max-w-[800px] flex-1 basis-full bg-cover bg-no-repeat md:ms-8"
169140
{...props}
170141
/>
171142
)
172143

173144
const Header = (props: ChildOnlyProp) => (
174-
<Box
175-
as="header"
176-
flex="1 1 50%"
177-
minW="300px"
178-
mt={{ base: 6, md: 32 }}
179-
{...props}
180-
/>
145+
<div className="mt-6 min-w-[300px] flex-1 basis-1/2 md:mt-32" {...props} />
181146
)
182147

183-
const H2 = (prop: HeadingProps) => (
184-
<OldHeading
185-
fontSize={{ base: "2xl", md: "2rem" }}
186-
lineHeight={1.4}
187-
mt={0}
188-
{...prop}
189-
/>
148+
const H2 = (props: ChildOnlyProp) => (
149+
<h2 className="mb-8 mt-0 leading-xs" {...props} />
190150
)
191151

192-
const H3 = (props: HeadingProps) => (
193-
<OldHeading
194-
as="h3"
195-
fontSize={{ base: "xl", md: "2xl" }}
196-
lineHeight={1.4}
197-
{...props}
198-
/>
152+
const H3 = (props: ChildOnlyProp) => (
153+
<h3 className="mb-8 mt-10 leading-xs" {...props} />
199154
)
200155

201-
const H4 = (props: HeadingProps) => (
202-
<OldHeading
203-
as="h4"
204-
fontSize={{ base: "md", md: "xl" }}
205-
fontWeight={600}
206-
lineHeight={1.4}
207-
{...props}
208-
/>
156+
const H4 = (props: ChildOnlyProp) => (
157+
<h4 className="my-8 leading-xs" {...props} />
209158
)
210159

211-
const CardContainer = (props: FlexProps) => (
212-
<Flex wrap="wrap" mx={-4} {...props} />
160+
const CardContainer = ({
161+
className,
162+
...props
163+
}: HTMLAttributes<HTMLHeadingElement>) => (
164+
<Flex className={cn("-mx-4 flex-wrap", className)} {...props} />
213165
)
214166

215167
const TokenCard = (props: ComponentProps<typeof HorizontalCard>) => (
@@ -220,24 +172,11 @@ const TokenCard = (props: ComponentProps<typeof HorizontalCard>) => (
220172
/>
221173
)
222174
const TextDivider = () => (
223-
<Box
224-
w="10%"
225-
h="1px"
226-
bg="searchResultBackground"
227-
my={8}
228-
alignSelf={{ lg: "flex-start" }}
229-
/>
175+
<div className="my-8 w-[10%] bg-search-background lg:items-start" />
230176
)
231177

232178
const CentralColumn = (props: ChildOnlyProp) => (
233-
<Flex
234-
direction="column"
235-
align="center"
236-
maxW="960px"
237-
my={16}
238-
mx="auto"
239-
{...props}
240-
/>
179+
<VStack className="mx-auto my-16 max-w-[960px]" {...props} />
241180
)
242181

243182
const CentralActionCard = (props: ComponentProps<typeof ActionCard>) => (
@@ -379,7 +318,7 @@ const EthPage = () => {
379318
</ButtonLink>
380319
</Header>
381320
<Hero>
382-
<Image
321+
<TwImage
383322
src={eth}
384323
// TODO: adjust value when the old theme breakpoints are removed (src/theme.ts)
385324
sizes="(max-width: 768px) 100vw, 800px"
@@ -394,7 +333,7 @@ const EthPage = () => {
394333
<Intro>
395334
<Text>{t("page-eth-description")} </Text>
396335
</Intro>
397-
<CardContainer mb={8}>
336+
<CardContainer className="mb-8">
398337
{benefits.map((benefits, idx) => (
399338
<StyledCard
400339
key={idx}
@@ -405,7 +344,7 @@ const EthPage = () => {
405344
))}
406345
</CardContainer>
407346
<InfoBanner emoji=":wave:" shouldCenter>
408-
<Text as="b">{t("page-eth-buy-some")}</Text>{" "}
347+
<b>{t("page-eth-buy-some")}</b>{" "}
409348
<Translation id="page-eth:page-eth-buy-some-desc" />{" "}
410349
<InlineLink href="/what-is-ethereum/">
411350
{t("page-eth-more-on-ethereum-link")}
@@ -419,13 +358,13 @@ const EthPage = () => {
419358
<H2>{t("page-eth-whats-unique")}</H2>
420359
<Text>{t("page-eth-whats-unique-desc")}</Text>
421360
<EthVideo />
422-
<Box>
361+
<div>
423362
<H4>{t("page-eth-fuels")}</H4>
424363
<Text>{t("page-eth-fuels-desc")}</Text>
425364
<Text>{t("page-eth-fuels-desc-2")}</Text>
426365
<Text>
427366
<Translation id="page-eth:page-eth-fuels-desc-3" />{" "}
428-
<Text as="strong">{t("page-eth-powers-ethereum")}</Text>
367+
<b>{t("page-eth-powers-ethereum")}</b>
429368
{t("page-eth-period")}
430369
</Text>
431370
<Text>
@@ -434,15 +373,15 @@ const EthPage = () => {
434373
{t("page-eth-fuels-more-staking")}
435374
</InlineLink>
436375
</Text>
437-
</Box>
376+
</div>
438377
<CentralActionCard
439378
href="/what-is-ethereum/"
440379
title={t("page-eth-whats-ethereum")}
441380
description={t("page-eth-whats-ethereum-desc")}
442381
image={ethereum}
443382
/>
444383
<TextDivider />
445-
<Box>
384+
<div>
446385
<H4>{t("page-eth-underpins")}</H4>
447386
<Text>
448387
<Translation id="page-eth:page-eth-underpins-desc" />
@@ -457,9 +396,9 @@ const EthPage = () => {
457396
<InfoBanner isWarning>
458397
<Translation id="page-eth:page-eth-weth" />
459398
</InfoBanner>
460-
</Box>
399+
</div>
461400
<TextDivider />
462-
<Box>
401+
<div>
463402
<H4>{t("page-eth-uses")}</H4>
464403
<Text>{t("page-eth-uses-desc")}</Text>
465404
<Text>{t("page-eth-uses-desc-2")} </Text>
@@ -489,7 +428,7 @@ const EthPage = () => {
489428
{t("page-eth-uses-desc-6")}
490429
</ListItem>
491430
</UnorderedList>
492-
</Box>
431+
</div>
493432
<Divider />
494433
</CentralColumn>
495434
<CalloutBanner
@@ -500,11 +439,11 @@ const EthPage = () => {
500439
alt={t("page-eth-cat-img-alt")}
501440
imageWidth={300}
502441
>
503-
<Box>
442+
<div>
504443
<ButtonLink href="/get-eth/">
505444
{t("page-eth-get-eth-btn")}
506445
</ButtonLink>
507-
</Box>
446+
</div>
508447
</CalloutBanner>
509448
</Content>
510449

@@ -521,12 +460,12 @@ const EthPage = () => {
521460
<CardList items={cardListContent} />
522461
</RightColumn>
523462
</TwoColumnContent>
524-
<TwoColumnContent id="tokens" align="flex-start">
463+
<TwoColumnContent className="items-start" id="tokens">
525464
<LeftColumn>
526465
<H3>{t("page-eth-not-only-crypto")}</H3>
527466
<Text>{t("page-eth-not-only-crypto-desc")} </Text>
528467
<Text>{t("page-eth-not-only-crypto-desc-2")}</Text>
529-
<H4 fontWeight="normal">{t("page-eth-more-on-tokens")}</H4>
468+
<H4>{t("page-eth-more-on-tokens")}</H4>
530469
<CardList items={tokenLinks} />
531470
</LeftColumn>
532471
<RightColumn>

0 commit comments

Comments
 (0)