Skip to content

Commit e42088b

Browse files
authored
Merge pull request #166 from ethereum/community-page
feat: Community page
2 parents a353df1 + 72b7da7 commit e42088b

File tree

15 files changed

+630
-134
lines changed

15 files changed

+630
-134
lines changed

src/components/Hero/ContentHero/ContentHero.stories.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ import ContentHeroComponent, { ContentHeroProps } from "."
55

66
type ContentHeroType = typeof ContentHeroComponent
77

8+
import contentHeroImg from "../../../../public/mainnet.png"
9+
810
const meta = {
911
title: "Organisms / Layouts / Hero",
1012
component: ContentHeroComponent,
1113
parameters: {
1214
layout: "none",
1315
},
1416
argTypes: {
15-
heroImgSrc: {
17+
heroImg: {
1618
table: {
1719
disable: true,
1820
},
@@ -22,9 +24,6 @@ const meta = {
2224

2325
export default meta
2426

25-
// TODO: Double-check correct way to mock Next.js image data
26-
const mockImgData = "/mainnet.png"
27-
2827
export const ContentHero: StoryObj = {
2928
render: () => {
3029
// eslint-disable-next-line react-hooks/rules-of-hooks
@@ -52,7 +51,7 @@ export const ContentHero: StoryObj = {
5251
return (
5352
<ContentHeroComponent
5453
breadcrumbs={{ slug: "/en/run-a-node/" }}
55-
heroImgSrc={mockImgData}
54+
heroImg={contentHeroImg}
5655
title={t("hero-header")}
5756
description={t("hero-subtitle")}
5857
buttons={buttons}
Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,54 @@
11
import { Box, Heading, HStack, SimpleGrid, Stack, Text } from "@chakra-ui/react"
22

3-
import type { CommonHeroProps } from "@/lib/types"
3+
import { CommonHeroProps } from "@/lib/types"
44

5-
import Breadcrumbs, { type BreadcrumbsProps } from "@/components/Breadcrumbs"
6-
import { CallToAction } from "@/components/Hero/CallToAction"
5+
import Breadcrumbs, { BreadcrumbsProps } from "@/components/Breadcrumbs"
76
import { Image } from "@/components/Image"
87

8+
import { CallToAction } from "../CallToAction"
9+
910
export interface ContentHeroProps extends Omit<CommonHeroProps, "header"> {
1011
breadcrumbs: BreadcrumbsProps
1112
}
1213

13-
const ContentHero = ({
14-
breadcrumbs,
15-
heroImgSrc,
16-
buttons,
17-
title,
18-
description,
19-
}: ContentHeroProps) => (
20-
<Box bgImg="bgMainGradient">
21-
<SimpleGrid columns={{ base: 1, lg: 2 }} maxW="1536px" mx="auto" gap="4">
22-
<Box
23-
height={{ base: "300px", md: "400px", lg: "full" }}
24-
order={{ lg: 1 }}
25-
>
26-
<Image
27-
alt=""
28-
src={heroImgSrc}
29-
priority
30-
style={{ objectFit: "contain" }}
31-
boxSize="full"
32-
/>
33-
</Box>
34-
<Stack p={{ base: "8", lg: "16" }} spacing="9" justify="center">
35-
<Breadcrumbs {...breadcrumbs} />
36-
<Stack spacing="6">
37-
<Heading as="h1" size="2xl">
38-
{title}
39-
</Heading>
40-
<Text fontSize="lg">{description}</Text>
41-
{buttons && (
14+
const ContentHero = (props: ContentHeroProps) => {
15+
const { breadcrumbs, heroImg, buttons, title, description } = props
16+
return (
17+
<Box bgImg="bgMainGradient">
18+
<SimpleGrid columns={{ base: 1, lg: 2 }} maxW="1536px" mx="auto" gap="4">
19+
<Box
20+
height={{ base: "300px", md: "400px", lg: "full" }}
21+
order={{ lg: 1 }}
22+
>
23+
<Image
24+
src={heroImg}
25+
alt=""
26+
priority
27+
style={{ objectFit: "contain" }}
28+
boxSize="full"
29+
/>
30+
</Box>
31+
<Stack p={{ base: "8", lg: "16" }} spacing="9" justify="center">
32+
<Breadcrumbs {...breadcrumbs} />
33+
<Stack spacing="6">
34+
<Heading as="h1" size="2xl">
35+
{title}
36+
</Heading>
37+
<Text fontSize="lg">{description}</Text>
4238
<HStack spacing="4">
43-
{buttons.map((button, idx) => {
39+
{buttons!.map((button, idx) => {
4440
if (!button) return
4541
return <CallToAction key={idx} {...button} />
4642
})}
4743
</HStack>
48-
)}
44+
</Stack>
45+
{/* TODO:
46+
* Add conditional Big Stat box here
47+
*/}
4948
</Stack>
50-
{/* TODO:
51-
* Add conditional Big Stat box here
52-
*/}
53-
</Stack>
54-
</SimpleGrid>
55-
</Box>
56-
)
49+
</SimpleGrid>
50+
</Box>
51+
)
52+
}
5753

5854
export default ContentHero

src/components/Hero/HomeHero/HomeHero.stories.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as React from "react"
12
import { Meta, StoryObj } from "@storybook/react"
23

34
import HomeHeroComponent from "."
@@ -11,7 +12,7 @@ const meta = {
1112
layout: "none",
1213
},
1314
argTypes: {
14-
heroImgSrc: {
15+
heroImg: {
1516
table: {
1617
disable: true,
1718
},
@@ -21,10 +22,11 @@ const meta = {
2122

2223
export default meta
2324

24-
// TODO: Double-check correct way to mock Next.js image data
25-
const mockImgData = "/home/hero.png"
25+
import homeHeroImg from "../../../../public/home/hero.png"
2626

2727
export const HomeHero: StoryObj<typeof meta> = {
28-
args: { heroImgSrc: mockImgData },
28+
args: {
29+
heroImg: homeHeroImg,
30+
},
2931
render: (args) => <HomeHeroComponent {...args} />,
3032
}

src/components/Hero/HomeHero/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import { ButtonLink } from "@/components/Buttons"
77
import { Image } from "@/components/Image"
88
import Morpher from "@/components/Morpher"
99

10-
export type HomeHeroProps = Pick<CommonHeroProps, "heroImgSrc">
10+
export type HomeHeroProps = Pick<CommonHeroProps, "heroImg">
1111

12-
const HomeHero = ({ heroImgSrc }: HomeHeroProps) => {
12+
const HomeHero = ({ heroImg }: HomeHeroProps) => {
1313
const { t } = useTranslation("page-index")
1414
return (
1515
<Box>
1616
<Box h={440}>
1717
<Image
18-
src={heroImgSrc}
18+
src={heroImg}
1919
alt={t("page-index:page-index-hero-image-alt")}
2020
w="full"
2121
h="full"
@@ -34,11 +34,11 @@ const HomeHero = ({ heroImgSrc }: HomeHeroProps) => {
3434
<Morpher />
3535
<VStack spacing="6">
3636
<Heading as="h1" size="2xl">
37-
{t("page-index-title")}
37+
{t("page-index:page-index-title")}
3838
</Heading>
39-
<Text size="xl">{t("page-index-description")}</Text>
39+
<Text size="xl">{t("page-index:page-index-description")}</Text>
4040
<ButtonLink href="/learn/">
41-
{t("page-index-title-button")}
41+
{t("page-index:page-index-title-button")}
4242
</ButtonLink>
4343
</VStack>
4444
</Stack>

src/components/Hero/HubHero/HubHero.stories.tsx

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { useTranslation } from "next-i18next"
33
import { Box } from "@chakra-ui/react"
44
import { Meta, StoryObj } from "@storybook/react"
55

6-
import type { CommonHeroProps as HubHeroProps } from "@/lib/types"
7-
86
import HubHeroComponent from "./"
97

108
type HubHeroType = typeof HubHeroComponent
@@ -26,22 +24,23 @@ const meta = {
2624

2725
export default meta
2826

29-
// TODO: Double-check correct way to mock Next.js image data
30-
const mockImgData = "/heroes/learn-hub-hero.png"
27+
import { CommonHeroProps } from "@/lib/types"
28+
29+
import learnHubHeroImg from "../../../../public/heroes/learn-hub-hero.png"
3130

3231
export const HubHero: StoryObj<typeof meta> = {
3332
args: {
3433
title: "learn-hub",
3534
header: "hero-header",
3635
description: "hero-subtitle",
37-
heroImgSrc: mockImgData,
36+
heroImg: learnHubHeroImg,
3837
},
3938

4039
render: ({ title, header, description, ...props }) => {
4140
// eslint-disable-next-line react-hooks/rules-of-hooks
4241
const { t } = useTranslation()
4342

44-
const buttons: HubHeroProps["buttons"] = [
43+
const buttons: CommonHeroProps["buttons"] = [
4544
{
4645
content: t("hero-button-lets-get-started"),
4746
toId: "what-is-crypto-ethereum",

src/components/Hero/HubHero/index.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,27 @@ import type { CommonHeroProps } from "@/lib/types"
1212
import { CallToAction } from "@/components/Hero/CallToAction"
1313
import { Image } from "@/components/Image"
1414

15-
const HubHero = ({
16-
heroImgSrc,
17-
title,
18-
header,
19-
description,
20-
buttons,
21-
}: CommonHeroProps) => {
15+
const HubHero = (props: CommonHeroProps) => {
16+
const { heroImg, title, header, description, buttons } = props
17+
18+
if (buttons && buttons.length > 2) {
19+
throw Error(
20+
"Can not have more than two call-to-action buttons in this hero component."
21+
)
22+
}
23+
2224
const height = useBreakpointValue({
2325
base: "192px",
2426
md: "256px",
2527
lg: "320px",
2628
xl: "576px",
2729
"2xl": "672px",
2830
})
31+
2932
return (
3033
<Box position="relative">
3134
<Image
32-
src={heroImgSrc}
35+
src={heroImg}
3336
alt=""
3437
priority
3538
sizes="100vw"

src/components/Hero/MdxHero/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Heading, Stack } from "@chakra-ui/react"
22

3-
import type { CommonHeroProps } from "@/lib/types"
3+
import { CommonHeroProps } from "@/lib/types"
44

55
import Breadcrumbs, { type BreadcrumbsProps } from "@/components/Breadcrumbs"
66

src/layouts/Roadmap.tsx

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -133,66 +133,66 @@ export const RoadmapLayout: React.FC<IProps> = ({
133133
<Box position="relative">
134134
{slug === "/roadmap/" ? (
135135
<HubHero
136-
heroImgSrc={RoadmapHubHeroImage}
136+
heroImg={RoadmapHubHeroImage}
137137
header={frontmatter.title}
138138
title={""}
139139
description={frontmatter.description}
140140
/>
141141
) : (
142142
<HeroContainer>
143-
<Flex
144-
w="full"
145-
flexDirection={{ base: "column", lg: "row" }}
146-
justify="space-between"
147-
>
148-
<TitleCard>
149-
{/* TODO: Double check this slug works */}
150-
<Breadcrumbs slug={slug} mb="8" />
151-
<Title>{frontmatter.title}</Title>
152-
<OldText>{frontmatter.description}</OldText>
153-
{frontmatter?.buttons && (
154-
// FIXME: remove the `ul` override once removed the corresponding
155-
// global styles in `src/@chakra-ui/gatsby-plugin/styles.ts`
156-
<Wrap spacing={2} marginBottom={4} sx={{ ul: { m: 0 } }}>
157-
{frontmatter.buttons.map((button, idx) => {
158-
if (button?.to) {
143+
<Flex
144+
w="full"
145+
flexDirection={{ base: "column", lg: "row" }}
146+
justify="space-between"
147+
>
148+
<TitleCard>
149+
{/* TODO: Double check this slug works */}
150+
<Breadcrumbs slug={slug} mb="8" />
151+
<Title>{frontmatter.title}</Title>
152+
<OldText>{frontmatter.description}</OldText>
153+
{frontmatter?.buttons && (
154+
// FIXME: remove the `ul` override once removed the corresponding
155+
// global styles in `src/@chakra-ui/gatsby-plugin/styles.ts`
156+
<Wrap spacing={2} marginBottom={4} sx={{ ul: { m: 0 } }}>
157+
{frontmatter.buttons.map((button, idx) => {
158+
if (button?.to) {
159+
return (
160+
<WrapItem key={idx}>
161+
<ButtonLink variant={button?.variant} to={button?.to}>
162+
{button.label}
163+
</ButtonLink>
164+
</WrapItem>
165+
)
166+
}
159167
return (
160168
<WrapItem key={idx}>
161-
<ButtonLink variant={button?.variant} to={button?.to}>
162-
{button.label}
163-
</ButtonLink>
169+
<Button variant={button?.variant} toId={button?.toId}>
170+
{button?.label}
171+
</Button>
164172
</WrapItem>
165173
)
166-
}
167-
return (
168-
<WrapItem key={idx}>
169-
<Button variant={button?.variant} toId={button?.toId}>
170-
{button?.label}
171-
</Button>
172-
</WrapItem>
173-
)
174-
})}
175-
</Wrap>
176-
)}
177-
<TableOfContents
178-
position="relative"
179-
zIndex="2"
180-
items={tocItems}
181-
isMobile
182-
/>
183-
</TitleCard>
184-
<Center>
185-
<Image
186-
src={frontmatter.image}
187-
alt={frontmatter.alt ?? ""}
188-
style={{ objectFit: "contain" }}
189-
width={700}
190-
height={345}
191-
priority
192-
/>
193-
</Center>
194-
</Flex>
195-
</HeroContainer>
174+
})}
175+
</Wrap>
176+
)}
177+
<TableOfContents
178+
position="relative"
179+
zIndex="2"
180+
items={tocItems}
181+
isMobile
182+
/>
183+
</TitleCard>
184+
<Center>
185+
<Image
186+
src={frontmatter.image}
187+
alt={frontmatter.alt ?? ""}
188+
style={{ objectFit: "contain" }}
189+
width={700}
190+
height={345}
191+
priority
192+
/>
193+
</Center>
194+
</Flex>
195+
</HeroContainer>
196196
)}
197197
<Page>
198198
{/* TODO: Switch to `above="lg"` after completion of Chakra Migration */}

0 commit comments

Comments
 (0)