Skip to content

Commit 7d096ae

Browse files
authored
Merge pull request #13843 from ethereum/layouts-unification
Md layouts tw migration & unification
2 parents 5602e08 + 3c58b42 commit 7d096ae

File tree

20 files changed

+772
-1068
lines changed

20 files changed

+772
-1068
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/Hero/ContentHero/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const ContentHero = (props: ContentHeroProps) => {
2929
>
3030
<Box
3131
order={{ lg: 1 }}
32+
py={{ base: 0, lg: 12 }}
3233
height={{
3334
base: "300px",
3435
md: "400px",
@@ -47,6 +48,7 @@ const ContentHero = (props: ContentHeroProps) => {
4748
boxSize="full"
4849
style={{ objectFit: "contain" }}
4950
flex={{ base: "1 1 100%", md: "none" }}
51+
maxHeight={451}
5052
/>
5153
</Box>
5254
<Stack p={{ base: "8", lg: "16" }} spacing="9" justify="center">

src/components/Image.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,16 @@ const imageProps: (keyof NextImageProps)[] = [
3333
"useMap",
3434
]
3535

36+
const isStaticImageData = (src: ImageProps["src"]): src is StaticImageData => {
37+
return typeof src === "object" && "blurDataURL" in src
38+
}
39+
3640
const DefaultNextImage = (props: ImageProps) => {
37-
const hasBlurData = !!(
38-
(props.src as StaticImageData).blurDataURL || props.blurDataURL
39-
)
41+
if (isStaticImageData(props.src)) {
42+
return <NextImage placeholder="blur" {...props} />
43+
}
44+
45+
const hasBlurData = !!props.blurDataURL
4046
return <NextImage placeholder={hasBlurData ? "blur" : "empty"} {...props} />
4147
}
4248

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

0 commit comments

Comments
 (0)