Skip to content

Commit b8f1fde

Browse files
committed
refactor: single-use component usage
fix: common namespace string; fix: duplicate usage of MainArticle (not allowed; contains `id`); fix: inconsistent spacing
1 parent 3c618cf commit b8f1fde

File tree

1 file changed

+25
-61
lines changed

1 file changed

+25
-61
lines changed

app/[locale]/developers/page.tsx

Lines changed: 25 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HTMLAttributes, ReactNode } from "react"
1+
import { ReactNode } from "react"
22
import { getTranslations } from "next-intl/server"
33

44
import { Lang } from "@/lib/types"
@@ -11,63 +11,22 @@ import HubHero from "@/components/Hero/HubHero"
1111
import { Image } from "@/components/Image"
1212
import MainArticle from "@/components/MainArticle"
1313
import { ButtonLink } from "@/components/ui/buttons/Button"
14-
import { Flex, Stack, VStack } from "@/components/ui/flex"
14+
import { Stack, VStack } from "@/components/ui/flex"
1515
import InlineLink from "@/components/ui/Link"
1616

17-
import { cn } from "@/lib/utils/cn"
1817
import { getMetadata } from "@/lib/utils/metadata"
1918

2019
import SpeedRunEthereumImage from "@/public/images/dev-tools/speed-run-ethereum-banner.png"
2120
import DevelopersImage from "@/public/images/developers-eth-blocks.png"
2221
import DogeImage from "@/public/images/doge-computer.png"
2322
import HeroImage from "@/public/images/heroes/developers-hub-hero.jpg"
2423

25-
const Page = (props: ChildOnlyProp) => (
26-
<VStack className="mx-auto my-0 w-full" {...props} />
27-
)
28-
29-
const GrayContainer = (props: ChildOnlyProp) => (
30-
<div
31-
className="mt-8 w-full border-t bg-background-highlight px-0 py-16 shadow-table-item-box"
32-
{...props}
33-
/>
34-
)
35-
36-
const Content = (props: ChildOnlyProp) => (
37-
<MainArticle className="w-full px-8 py-4" {...props} />
38-
)
39-
40-
const Subtitle = ({
41-
className,
42-
...props
43-
}: HTMLAttributes<HTMLHeadingElement>) => (
44-
<p className={cn("leading-xs text-body-medium", className)} {...props} />
45-
)
46-
47-
const MonoSubtitle = (props: ChildOnlyProp) => (
48-
<h2 className="mb-0 mt-12" {...props} />
49-
)
50-
5124
const H2 = (props: ChildOnlyProp) => <h2 className="mb-8 mt-12" {...props} />
5225

5326
const H3 = (props: ChildOnlyProp) => <h3 className="mb-8 mt-10" {...props} />
5427

5528
const Text = (props: ChildOnlyProp) => <p className="mb-6" {...props} />
5629

57-
const TwoColumnContent = (props: ChildOnlyProp) => (
58-
<Flex
59-
className="w-full flex-col items-start justify-between lg:flex-row lg:items-center"
60-
{...props}
61-
/>
62-
)
63-
64-
const ThreeColumnContent = (props: ChildOnlyProp) => (
65-
<Flex
66-
className="flex-col items-start justify-between px-8 py-0 lg:flex-row"
67-
{...props}
68-
/>
69-
)
70-
7130
const Column = (props: ChildOnlyProp) => (
7231
<div className="mb-6 me-8 w-full flex-1 basis-1/3" {...props} />
7332
)
@@ -99,6 +58,10 @@ const DevelopersPage = async ({
9958
locale,
10059
namespace: "page-developers-index",
10160
})
61+
const tCommon = await getTranslations({
62+
locale,
63+
namespace: "common",
64+
})
10265

10366
const paths: DevelopersPath[] = [
10467
{
@@ -132,18 +95,19 @@ const DevelopersPage = async ({
13295
]
13396

13497
return (
135-
<Page>
98+
<VStack className="mx-auto my-0 w-full">
13699
<HubHero
137100
heroImg={HeroImage}
138101
header={`${t("page-developers-title-1")} ${t(
139102
"page-developers-title-2"
140103
)} ${t("page-developers-title-3")}`}
141-
title={t("common:developers")}
104+
title={tCommon("developers")}
142105
description={t("page-developers-subtitle")}
143106
/>
144-
<Content>
145-
<MonoSubtitle>{t("page-developers-get-started")}</MonoSubtitle>
146-
<div className="-mx-4 mb-12 mt-8 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4">
107+
<MainArticle className="w-full space-y-12 px-8 py-4">
108+
<h2 className="-mb-4 mt-12">{t("page-developers-get-started")}</h2>
109+
110+
<div className="-mx-4 grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4">
147111
{paths.map((path, idx) => (
148112
<Card
149113
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)]`}
@@ -157,7 +121,7 @@ const DevelopersPage = async ({
157121
))}
158122
</div>
159123

160-
<div className="relative xl:mb-12" data-label="speedrunethereum-banner">
124+
<div className="relative" data-label="speedrunethereum-banner">
161125
<Image
162126
className="h-[450px] xl:h-auto"
163127
src={SpeedRunEthereumImage}
@@ -177,12 +141,12 @@ const DevelopersPage = async ({
177141
</Stack>
178142
</div>
179143

180-
<TwoColumnContent>
144+
<div className="flex w-full flex-col items-start justify-between lg:flex-row lg:items-center">
181145
<IntroColumn>
182146
<H2>{t("page-developers-about")}</H2>
183-
<Subtitle className="mb-6">
147+
<p className="mb-6 leading-xs text-body-medium">
184148
{t("page-developers-about-desc")}
185-
</Subtitle>
149+
</p>
186150
<Text>{t("page-developers-about-desc-2")}</Text>
187151
<Text>
188152
{t("page-developers-feedback")}{" "}
@@ -204,14 +168,14 @@ const DevelopersPage = async ({
204168
</ButtonLink>
205169
</div>
206170
</CalloutSSR>
207-
</TwoColumnContent>
208-
</Content>
209-
<GrayContainer>
210-
<Content>
171+
</div>
172+
</MainArticle>
173+
<div className="mt-8 w-full border-t bg-background-highlight px-0 py-16 shadow-table-item-box">
174+
<div className="w-full scroll-mt-24 px-8 py-4">
211175
<H2>{t("page-developers-explore-documentation")}</H2>
212-
</Content>
176+
</div>
213177

214-
<ThreeColumnContent>
178+
<div className="flex flex-col items-start justify-between px-8 py-0 lg:flex-row">
215179
<Column>
216180
<H3>{t("page-developers-docs-introductions")}</H3>
217181
<InlineLink href="/developers/docs/intro-to-ethereum/">
@@ -358,10 +322,10 @@ const DevelopersPage = async ({
358322
{t("page-developers-data-structures-and-encoding-desc")}
359323
</Text>
360324
</RightColumn>
361-
</ThreeColumnContent>
362-
</GrayContainer>
325+
</div>
326+
</div>
363327
<FeedbackCard />
364-
</Page>
328+
</VStack>
365329
)
366330
}
367331

0 commit comments

Comments
 (0)