Skip to content

Commit 8bdcc01

Browse files
committed
create ContentLayout and reuse it in upgrade, roadmap, staking, translatathon layouts
1 parent 816648c commit 8bdcc01

File tree

14 files changed

+278
-476
lines changed

14 files changed

+278
-476
lines changed

public/content/roadmap/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ image: /images/heroes/roadmap-hub-hero.jpg
77
alt: "Ethereum roadmap"
88
summaryPoints:
99
buttons:
10-
- label: Further upgrades
10+
- content: Further upgrades
1111
toId: what-changes-are-coming
12-
- label: Past upgrades
12+
- content: Past upgrades
1313
href: /history/
1414
variant: outline
1515
---

src/components/Hero/CallToAction.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { ReactNode } from "react"
22

3-
import { Button, type ButtonProps } from "@/components/ui/buttons/Button"
3+
import {
4+
Button,
5+
ButtonLink,
6+
type ButtonProps,
7+
} from "@/components/ui/buttons/Button"
48

59
import { cn } from "@/lib/utils/cn"
610
import { type MatomoEventOptions, trackCustomEvent } from "@/lib/utils/matomo"
@@ -10,25 +14,38 @@ export type CallToActionProps = Omit<
1014
"children" | "content" | "variant" | "isSecondary"
1115
> & {
1216
content: ReactNode
13-
matomo: MatomoEventOptions
17+
matomo?: MatomoEventOptions
1418
index: number
19+
href?: string
1520
}
1621

1722
export const CallToAction = ({
1823
content,
1924
matomo,
2025
index,
2126
className,
27+
href,
2228
...props
2329
}: CallToActionProps) => {
24-
const handleClick = () => trackCustomEvent(matomo)
30+
const handleClick = () => matomo && trackCustomEvent(matomo)
2531

2632
const buttonProps: ButtonProps = {
2733
variant: index === 0 ? "solid" : "outline",
2834
isSecondary: index !== 0,
2935
className: cn("flex-[1] md:flex-[initial]", className),
3036
}
3137

38+
if (href) {
39+
return (
40+
<ButtonLink
41+
href={href}
42+
buttonProps={{ onClick: handleClick, ...buttonProps, ...props }}
43+
>
44+
{content}
45+
</ButtonLink>
46+
)
47+
}
48+
3249
return (
3350
<Button onClick={handleClick} {...buttonProps} {...props}>
3451
{content}

src/components/LeftNavBar/index.tsx

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,47 @@
1-
import { calc, Flex, type FlexProps, type HeadingProps } from "@chakra-ui/react"
2-
31
import type { ToCItem } from "@/lib/types"
42

53
import ButtonDropdown, {
6-
ButtonDropdownProps,
74
List as ButtonDropdownList,
85
} from "@/components/ButtonDropdown"
9-
import OldHeading from "@/components/OldHeading"
106
import Translation from "@/components/Translation"
117
import UpgradeTableOfContents from "@/components/UpgradeTableOfContents"
128

13-
export const H2 = (props: HeadingProps) => (
14-
<OldHeading
15-
fontWeight={700}
16-
lineHeight={1.4}
17-
size="lg"
18-
textAlign="start"
19-
mt={0}
20-
{...props}
21-
/>
22-
)
23-
24-
export const StyledButtonDropdown = ({
25-
list,
26-
...rest
27-
}: FlexProps & Pick<ButtonDropdownProps, "list">) => (
28-
<Flex align="flex-end" justify="flex-end" mb={8} {...rest} pos="relative">
29-
<ButtonDropdown list={list} w="full" minW="240px" />
30-
</Flex>
31-
)
9+
import { cn } from "@/lib/utils/cn"
3210

33-
type LeftNavBarProps = FlexProps & {
11+
export type LeftNavBarProps = {
3412
dropdownLinks?: ButtonDropdownList
3513
maxDepth?: number
3614
tocItems: ToCItem[]
15+
className?: string
3716
}
3817

3918
const LeftNavBar = ({
4019
dropdownLinks,
4120
maxDepth = 1,
4221
tocItems,
22+
className,
4323
...props
4424
}: LeftNavBarProps) => {
4525
return (
46-
<Flex
47-
as="aside"
48-
flexDirection="column"
49-
flex="0 1 400px"
50-
ms={8}
51-
me={16}
52-
position="sticky"
53-
top="6.25rem"
54-
height={calc("100vh").subtract("80px").toString()}
55-
zIndex={99}
26+
<aside
27+
className={cn(
28+
"z-99 sticky top-[6.25rem] me-16 ms-8 flex h-[calc(100vh-80px)] basis-[400px] flex-col",
29+
className
30+
)}
5631
{...props}
5732
>
58-
{dropdownLinks && <StyledButtonDropdown list={dropdownLinks} />}
59-
<H2>
33+
{dropdownLinks && (
34+
<div className="relative mb-8 flex items-end justify-end">
35+
<ButtonDropdown list={dropdownLinks} w="full" minW="240px" />
36+
</div>
37+
)}
38+
<h2 className="mb-8 text-3xl leading-xs">
6039
<Translation id="on-this-page" />
61-
</H2>
40+
</h2>
6241
{tocItems && (
6342
<UpgradeTableOfContents items={tocItems} maxDepth={maxDepth} />
6443
)}
65-
</Flex>
44+
</aside>
6645
)
6746
}
6847

src/layouts/ContentLayout.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import type { HTMLAttributes } from "react"
2+
3+
import FeedbackCard from "@/components/FeedbackCard"
4+
import { ContentHero, type ContentHeroProps } from "@/components/Hero"
5+
import LeftNavBar, { LeftNavBarProps } from "@/components/LeftNavBar"
6+
import {
7+
ContentContainer,
8+
MobileButton,
9+
MobileButtonDropdown,
10+
Page,
11+
} from "@/components/MdComponents"
12+
13+
type ContentLayoutProps = HTMLAttributes<HTMLDivElement> &
14+
Pick<LeftNavBarProps, "dropdownLinks" | "tocItems" | "maxDepth"> & {
15+
children: React.ReactNode
16+
heroProps: ContentHeroProps
17+
}
18+
19+
export const ContentLayout = ({
20+
children,
21+
dropdownLinks,
22+
tocItems,
23+
maxDepth,
24+
heroProps,
25+
...props
26+
}: ContentLayoutProps) => {
27+
return (
28+
<div {...props}>
29+
<ContentHero {...heroProps} />
30+
31+
<Page>
32+
<LeftNavBar
33+
className="max-lg:hidden"
34+
dropdownLinks={dropdownLinks}
35+
tocItems={tocItems}
36+
maxDepth={maxDepth}
37+
/>
38+
39+
<ContentContainer>
40+
{children}
41+
<FeedbackCard />
42+
</ContentContainer>
43+
44+
{dropdownLinks && (
45+
<MobileButton>
46+
<MobileButtonDropdown list={dropdownLinks} />
47+
</MobileButton>
48+
)}
49+
</Page>
50+
</div>
51+
)
52+
}

0 commit comments

Comments
 (0)