Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Hero): create multiple hero components for new DS #11132

Merged
merged 27 commits into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5dcfcdc
feat(Hero): create multiple hero components for new DS
TylerAPfledderer Jul 20, 2023
0b4f4e9
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Sep 12, 2023
feba0e4
fix(Hero/utils): set optional tuple element for buttons
TylerAPfledderer Sep 18, 2023
25c443b
feat(pages/learn): implement `HubHero`
TylerAPfledderer Sep 18, 2023
8e83d10
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Sep 20, 2023
cbe229b
refactor(Hero): use custom globalized `GatsbyImage`
TylerAPfledderer Sep 20, 2023
53286dd
fix(ContentHero): return empty for undefined button in iterative
TylerAPfledderer Sep 20, 2023
1e92f6e
refactor(Hero): create central import entry
TylerAPfledderer Sep 20, 2023
5344f14
refactor(ContentHero): allow entire `Breadcrumbs` prop object to be p…
TylerAPfledderer Sep 23, 2023
3a14aaf
refactor(ContentHero): render heading as `h1`
TylerAPfledderer Sep 23, 2023
1357ecd
chore(MdxHero): change `heroTitle` prop to `title`
TylerAPfledderer Sep 23, 2023
256fffc
chore(CallToAction): remove double import
TylerAPfledderer Sep 23, 2023
d1ebcc5
chore(CallToAction): add `content` as an omitted prop from `ButtonProps`
TylerAPfledderer Sep 24, 2023
1cb49e6
refactor(Hero): add `title` to `CommonHeroProps`
TylerAPfledderer Sep 24, 2023
7d388ec
refactor(CallToAction): change type signature for `index` prop
TylerAPfledderer Sep 24, 2023
f250f3c
fix(Hero): update prop names used in stories
TylerAPfledderer Sep 24, 2023
07619e5
style(MdxHero): remove margin from breadcrumbs and add TODO reminder
TylerAPfledderer Sep 24, 2023
051f51e
Merge branch 'dev' into feat/hero-new-ds
pettinarip Sep 26, 2023
7e4793e
fix(Hero): update imports from `Buttons`
TylerAPfledderer Sep 27, 2023
700bb5b
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Oct 3, 2023
136ccde
style(Hero): remove unneeded spacing override for breadcrumbs
TylerAPfledderer Oct 3, 2023
879e611
Merge remote-tracking branch 'origin/dev' into feat/hero-new-ds
TylerAPfledderer Oct 18, 2023
e2556af
feat(pages/learn): use new image for learn hub hero
TylerAPfledderer Oct 18, 2023
888b973
fix(pages/learn): add spacing beneath the hero on mobile
TylerAPfledderer Oct 18, 2023
36a722b
chore(learn-hub-hero): supply higher-quality image
TylerAPfledderer Oct 19, 2023
9b35261
style(Morpher): update color to `body.medium`
TylerAPfledderer Oct 24, 2023
21ca922
refactor(pages/index): apply new home hero
TylerAPfledderer Oct 24, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .storybook/i18next.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import i18n, { Resource } from "i18next"
import { initReactI18next } from "gatsby-plugin-react-i18next"
import fs from "fs"

export const baseLocales = {
en: { title: "English", left: "En" },
Expand All @@ -15,6 +14,7 @@ const ns = [
"glossary",
"page-about",
"page-index",
"page-learn",
"page-upgrades",
"page-developers-index",
]
Expand Down
2 changes: 1 addition & 1 deletion .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const config: StorybookConfig = {
"@chakra-ui/storybook-addon",
"storybook-react-i18next",
],
staticDirs: ["../static"],
staticDirs: ["../static", "../src/assets"],
babel: async () => ({
...babelConfig,
}),
Expand Down
Binary file added src/assets/heroes/learn-hub-hero.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/mainnet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/components/Hero/CallToAction.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from "react"
import { MatomoEventOptions, trackCustomEvent } from "../../utils/matomo"
import { Button, type IButtonProps } from "../Buttons"

export type CallToActionProps = Omit<IButtonProps, "children" | "content"> & {
content: React.ReactNode
matomo: MatomoEventOptions
}

export function CallToAction(props: CallToActionProps & { index: React.Key }) {
const { content, matomo, index, ...rest } = props

const handleClick = () => trackCustomEvent(matomo)

const buttonProps: IButtonProps = {
variant: index === 0 ? "solid" : "outline",
isSecondary: index !== 0,
flex: { base: 1, md: "initial" },
}

return (
<Button onClick={handleClick} {...buttonProps} {...rest}>
{content}
</Button>
)
}
79 changes: 79 additions & 0 deletions src/components/Hero/ContentHero/ContentHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import * as React from "react"
import { Meta, StoryObj } from "@storybook/react"
import ContentHeroComponent, { ContentHeroProps } from "."
import { IGatsbyImageData } from "gatsby-plugin-image"
import { useTranslation } from "gatsby-plugin-react-i18next"

type ContentHeroType = typeof ContentHeroComponent

const meta = {
title: "Organisms / Layouts / Hero",
component: ContentHeroComponent,
parameters: {
layout: "none",
},
argTypes: {
heroImgSrc: {
table: {
disable: true,
},
},
},
} satisfies Meta<ContentHeroType>

export default meta

// Comes from the original compiled querying
const mockGatsbyImgData: IGatsbyImageData = {
layout: "constrained",
images: {
fallback: {
src: "/mainnet.png",
sizes: "100vw",
},
sources: [
{
srcSet: "/mainnet.png",
type: "image/webp",
sizes: "100vw",
},
],
},
width: 1,
height: 1,
}

export const ContentHero: StoryObj = {
render: () => {
const { t } = useTranslation()

const buttons: ContentHeroProps["buttons"] = [
{
content: t("hero-button-lets-get-started"),
toId: "what-is-crypto-ethereum",
matomo: {
eventCategory: "learn hub hero buttons",
eventAction: "click",
eventName: "lets get started",
},
},
{
content: "Button",
matomo: {
eventCategory: "learn hub hero buttons",
eventAction: "click",
eventName: "lets get started",
},
},
]
return (
<ContentHeroComponent
breadcrumbs={{ slug: "/en/run-a-node/" }}
heroImgSrc={mockGatsbyImgData}
title={t("hero-header")}
description={t("hero-subtitle")}
buttons={buttons}
/>
)
},
}
55 changes: 55 additions & 0 deletions src/components/Hero/ContentHero/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import * as React from "react"
import { Box, Heading, HStack, SimpleGrid, Stack, Text } from "@chakra-ui/react"
import Breadcrumbs, { IProps as BreadcrumbsProps } from "../../Breadcrumbs"
import GatsbyImage from "../../GatsbyImage"
import { CallToAction } from "../CallToAction"
import { CommonHeroProps } from "../utils"

export interface ContentHeroProps extends Omit<CommonHeroProps, "header"> {
breadcrumbs: BreadcrumbsProps
}

const ContentHero = (props: ContentHeroProps) => {
const { breadcrumbs, heroImgSrc, buttons, title, description } = props
return (
<Box bgImg="bgMainGradient">
<SimpleGrid columns={{ base: 1, lg: 2 }} maxW="1536px" mx="auto" gap="4">
<Box
height={{ base: "300px", md: "400px", lg: "full" }}
order={{ lg: 1 }}
>
<GatsbyImage
alt=""
image={heroImgSrc}
loading="eager"
objectFit="contain"
boxSize="full"
/>
</Box>
<Stack p={{ base: "8", lg: "16" }} spacing="9" justify="center">
<Breadcrumbs {...breadcrumbs} />
<Stack spacing="6">
<Heading as="h1" size="2xl">
{title}
</Heading>
<Text fontSize="lg">{description}</Text>
<HStack spacing="4">
{buttons
? buttons.map((button, idx) => {
if (!button) return

return <CallToAction key={idx} index={idx} {...button} />
})
: null}
</HStack>
</Stack>
{/* TODO:
* Add conditional Big Stat box here
*/}
</Stack>
</SimpleGrid>
</Box>
)
}

export default ContentHero
50 changes: 50 additions & 0 deletions src/components/Hero/HomeHero/HomeHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as React from "react"
import { Meta, StoryObj } from "@storybook/react"
import HomeHeroComponent from "."
import { IGatsbyImageData } from "gatsby-plugin-image"

type HomeHeroType = typeof HomeHeroComponent

const meta = {
title: "Organisms / Layouts / Hero",
component: HomeHeroComponent,
parameters: {
layout: "none",
},
argTypes: {
heroImgSrc: {
table: {
disable: true,
},
},
},
} satisfies Meta<HomeHeroType>

export default meta

// Comes from the original compiled querying
const mockGatsbyImgData: IGatsbyImageData = {
layout: "fullWidth",
images: {
fallback: {
src: "/home/hero.png",
sizes: "100vw",
},
sources: [
{
srcSet: "/home/hero.png",
type: "image/webp",
sizes: "100vw",
},
],
},
width: 1,
height: 1,
}

export const HomeHero: StoryObj<typeof meta> = {
args: {
heroImgSrc: mockGatsbyImgData,
},
render: (args) => <HomeHeroComponent {...args} />,
}
49 changes: 49 additions & 0 deletions src/components/Hero/HomeHero/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import * as React from "react"
import { useTranslation } from "react-i18next"
import { Box, Heading, Stack, Text, VStack } from "@chakra-ui/react"
import { ButtonLink } from "../../Buttons"
import Morpher from "../../Morpher"
import Translation from "../../Translation"
import GatsbyImage from "../../GatsbyImage"
import { CommonHeroProps } from "../utils"

export interface HomeHeroProps extends Pick<CommonHeroProps, "heroImgSrc"> {}

const HomeHero = ({ heroImgSrc }: HomeHeroProps) => {
const { t } = useTranslation()
return (
<Box>
<GatsbyImage
image={heroImgSrc}
alt={t("page-index-hero-image-alt")}
loading="eager"
w="full"
height={{ base: "300px", sm: "350px", md: "380px", lg: "440px" }}
/>
<VStack>
<Stack
spacing={{ base: "4", lg: "7" }}
textAlign="center"
mx="4"
py="8"
maxW="2xl"
>
<Morpher />
<VStack spacing="6">
<Heading as="h1" size="2xl">
<Translation id="page-index-title" />
</Heading>
<Text size="xl">
<Translation id="page-index-description" />
</Text>
<ButtonLink to="/learn/">
<Translation id="page-index-title-button" />
</ButtonLink>
</VStack>
</Stack>
</VStack>
</Box>
)
}

export default HomeHero
87 changes: 87 additions & 0 deletions src/components/Hero/HubHero/HubHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import * as React from "react"
import { Meta, StoryObj } from "@storybook/react"
import HubHeroComponent, { HubHeroProps } from "./"
import { Box } from "@chakra-ui/react"
import { IGatsbyImageData } from "gatsby-plugin-image"
import { useTranslation } from "react-i18next"

type HubHeroType = typeof HubHeroComponent

const meta = {
title: "Organisms / Layouts / Hero",
component: HubHeroComponent,
parameters: {
layout: "none",
},
decorators: [
(Story) => (
<Box maxW="container.2xl" mx="auto">
<Story />
</Box>
),
],
} satisfies Meta<HubHeroType>

export default meta

const mockGatsbyImgData: IGatsbyImageData = {
layout: "fullWidth",
images: {
fallback: {
src: "/heroes/learn-hub-hero.png",
sizes: "100vw",
},
sources: [
{
srcSet: "/heroes/learn-hub-hero.png",
type: "image/webp",
sizes: "100vw",
},
],
},
width: 1,
height: 1,
}

export const HubHero: StoryObj<typeof meta> = {
args: {
title: "learn-hub",
header: "hero-header",
description: "hero-subtitle",
heroImgSrc: mockGatsbyImgData,
},
render: (args) => {
const { t } = useTranslation()
const { title, header, description, ...rest } = args

const buttons: HubHeroProps["buttons"] = [
{
content: t("hero-button-lets-get-started"),
toId: "what-is-crypto-ethereum",
matomo: {
eventCategory: "learn hub hero buttons",
eventAction: "click",
eventName: "lets get started",
},
},
{
content: "Button",
matomo: {
eventCategory: "learn hub hero buttons",
eventAction: "click",
eventName: "lets get started",
},
},
]

return (
<HubHeroComponent
title={t(title)}
header={t(header)}
description={t(description)}
buttons={buttons}
{...rest}
/>
)
},
}
Loading
Loading