Skip to content

Commit bb56ccd

Browse files
authored
Merge pull request #16042 from ethereum/what-is-ethereum
feat: /what-is-ethereum revamp
2 parents 89bea65 + 5cbf335 commit bb56ccd

File tree

12 files changed

+1320
-793
lines changed

12 files changed

+1320
-793
lines changed

app/[locale]/what-is-ethereum/page.tsx

Lines changed: 1000 additions & 637 deletions
Large diffs are not rendered by default.
21.2 KB
Loading

src/components/EnergyConsumptionChart/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ ChartJS.register(
3636
)
3737

3838
const EnergyConsumptionChart = () => {
39-
const { t } = useTranslation("page-what-is-ethereum")
39+
const { t } = useTranslation("page-energy-consumption")
4040
const locale = useLocale()
4141
const isClient = useIsClient()
4242
const isRtl = isLangRightToLeft(locale as Lang)
@@ -247,7 +247,7 @@ const EnergyConsumptionChart = () => {
247247
</Center>
248248

249249
<p className="text-center font-semibold">
250-
{t("page-what-is-ethereum-energy-consumption-chart-legend")}
250+
{t("energy-consumption-chart-legend")}
251251
</p>
252252
</div>
253253
)

src/components/IntlStringElements.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export const Emphasis = (chunks: React.ReactNode) => <em>{chunks}</em>
2+
3+
export const Strong = (chunks: React.ReactNode) => <strong>{chunks}</strong>

src/components/TableOfContents/ItemsList.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
1+
import { cva, type VariantProps } from "class-variance-authority"
2+
13
import type { ToCItem } from "@/lib/types"
24

35
import ToCLink from "@/components/TableOfContents/TableOfContentsLink"
46

7+
const variants = cva("mb-2 last:mb-0", {
8+
variants: {
9+
variant: {
10+
default: "",
11+
beginner:
12+
"[&:has([data-state-active='true'])]:text-primary hover:text-primary-hover list-item",
13+
},
14+
},
15+
defaultVariants: {
16+
variant: "default",
17+
},
18+
})
19+
520
export type ItemsListProps = {
621
items: Array<ToCItem>
722
depth: number
823
maxDepth: number
924
activeHash?: string
10-
}
25+
} & VariantProps<typeof variants>
1126

1227
const ItemsList = ({
1328
items,
1429
depth,
1530
maxDepth,
1631
activeHash,
32+
variant,
1733
...rest
1834
}: ItemsListProps) => {
1935
if (depth > maxDepth) return null
@@ -23,8 +39,13 @@ const ItemsList = ({
2339
{items.map((item, index) => {
2440
const { title, items } = item
2541
return (
26-
<li key={index} className="mb-2 last:mb-0" {...rest}>
27-
<ToCLink depth={depth} item={item} activeHash={activeHash} />
42+
<li key={index} className={variants({ variant })} {...rest}>
43+
<ToCLink
44+
variant={variant}
45+
depth={depth}
46+
item={item}
47+
activeHash={activeHash}
48+
/>
2849
{items && (
2950
<ul key={title} className="m-0 mt-2 list-none gap-2 ps-2 text-sm">
3051
<ItemsList

src/components/TableOfContents/TableOfContentsLink.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,51 @@
1+
import { cva, type VariantProps } from "class-variance-authority"
2+
13
import type { ToCItem } from "@/lib/types"
24

35
import { cn } from "@/lib/utils/cn"
46

57
import { BaseLink } from "../ui/Link"
68

9+
const variants = cva(
10+
"group relative inline-block w-full py-0.5 text-body-medium no-underline lg:w-auto",
11+
{
12+
variants: {
13+
variant: {
14+
default: "",
15+
beginner: "[&_[data-label='marker']]:!hidden inline leading-base",
16+
},
17+
},
18+
defaultVariants: {
19+
variant: "default",
20+
},
21+
}
22+
)
23+
724
export type TableOfContentsLinkProps = {
825
depth: number
926
item: ToCItem
1027
activeHash?: string
11-
}
28+
} & VariantProps<typeof variants>
1229

1330
const Link = ({
1431
depth,
1532
item: { title, url },
1633
activeHash,
34+
variant,
1735
}: TableOfContentsLinkProps) => {
1836
const isActive = activeHash === url
1937

2038
return (
2139
<BaseLink
40+
data-state-active={isActive}
2241
href={url}
23-
className={cn(
24-
"group relative inline-block w-full py-0.5 text-body-medium no-underline lg:w-auto",
25-
isActive && "visited text-primary"
26-
)}
42+
className={variants({
43+
variant,
44+
className: isActive && "visited text-primary",
45+
})}
2746
>
2847
<div
48+
data-label="marker"
2949
className={cn(
3050
"absolute top-1/2 -mt-1 hidden h-2 w-2 rounded-full border border-primary-hover bg-background group-hover:inline-block",
3151
isActive && "inline-block"

src/components/TableOfContents/TableOfContentsMobile.tsx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
"use client"
2+
3+
import { cva, type VariantProps } from "class-variance-authority"
14
import { ChevronDown } from "lucide-react"
25

36
import type { ToCItem } from "@/lib/types"
@@ -13,12 +16,25 @@ import ItemsListMobile from "./ItemsListMobile"
1316

1417
import { useTranslation } from "@/hooks/useTranslation"
1518

19+
const variants = cva("flex w-full justify-between lg:hidden", {
20+
variants: {
21+
variant: {
22+
default: "",
23+
beginner:
24+
"[&>span]:flex-none mb-16 justify-center rounded-lg border-border bg-accent-a/10 text-lg font-bold",
25+
},
26+
},
27+
defaultVariants: {
28+
variant: "default",
29+
},
30+
})
31+
1632
export type TableOfContentsMobileProps = {
1733
items?: Array<ToCItem>
1834
maxDepth?: number
19-
}
35+
} & VariantProps<typeof variants>
2036

21-
const Mobile = ({ items, maxDepth }: TableOfContentsMobileProps) => {
37+
const Mobile = ({ items, maxDepth, variant }: TableOfContentsMobileProps) => {
2238
const { t } = useTranslation("common")
2339

2440
if (!items) {
@@ -28,11 +44,7 @@ const Mobile = ({ items, maxDepth }: TableOfContentsMobileProps) => {
2844
return (
2945
<DropdownMenu>
3046
<DropdownMenuTrigger asChild>
31-
<Button
32-
isSecondary
33-
variant="outline"
34-
className="flex w-full justify-between lg:hidden"
35-
>
47+
<Button isSecondary variant="outline" className={variants({ variant })}>
3648
<span className="flex-1 text-center">{t("on-this-page")}</span>
3749
<ChevronDown />
3850
</Button>

src/components/TableOfContents/index.tsx

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"use client"
22

3+
import { cva, type VariantProps } from "class-variance-authority"
4+
35
import type { ToCItem } from "@/lib/types"
46

57
import Github from "@/components/icons/github.svg"
@@ -14,7 +16,39 @@ import { useActiveHash } from "@/hooks/useActiveHash"
1416
import { useTranslation } from "@/hooks/useTranslation"
1517
import { usePathname } from "@/i18n/routing"
1618

17-
export type TableOfContentsProps = {
19+
const variants = cva(
20+
"sticky hidden flex-col items-start overflow-y-auto lg:flex",
21+
{
22+
variants: {
23+
variant: {
24+
default:
25+
"top-19 min-w-48 max-w-[25%] p-4 pe-0 h-[calc(100vh-80px)] gap-4",
26+
beginner: cn(
27+
"top-[7.25rem] min-w-80 max-w-72 lg:p-8 px-3 py-2",
28+
"h-fit shrink-0 space-y-2.5 rounded-2xl bg-accent-a/10 text-body-medium",
29+
"[&_ul]:list-decimal [&_ul]:border-s-0 [&_ul]:text-base [&_ul]:list-inside [&_ul]:ps-0"
30+
),
31+
},
32+
},
33+
defaultVariants: {
34+
variant: "default",
35+
},
36+
}
37+
)
38+
39+
const labelVariants = cva("text-body-medium", {
40+
variants: {
41+
variant: {
42+
default: "uppercase",
43+
beginner: "font-bold text-lg",
44+
},
45+
},
46+
defaultVariants: {
47+
variant: "default",
48+
},
49+
})
50+
51+
export interface TableOfContentsProps extends VariantProps<typeof variants> {
1852
items: Array<ToCItem>
1953
maxDepth?: number
2054
editPath?: string
@@ -30,13 +64,12 @@ const TableOfContents = ({
3064
hideEditButton = false,
3165
isMobile = false,
3266
className,
67+
variant,
3368
...rest
3469
}: TableOfContentsProps) => {
3570
const pathname = usePathname()
3671
const { t } = useTranslation("common")
37-
3872
const titleIds: Array<string> = []
39-
4073
if (!isMobile) {
4174
const getTitleIds = (items: Array<ToCItem>, depth: number): void => {
4275
// Return early if maxDepth hit
@@ -56,17 +89,11 @@ const TableOfContents = ({
5689
return null
5790
}
5891
if (isMobile) {
59-
return <Mobile items={items} maxDepth={maxDepth} />
92+
return <Mobile variant={variant} items={items} maxDepth={maxDepth} />
6093
}
6194

6295
return (
63-
<aside
64-
className={cn(
65-
"sticky top-19 hidden h-[calc(100vh-80px)] min-w-48 max-w-[25%] flex-col items-start gap-4 overflow-y-auto p-4 pe-0 lg:flex",
66-
className
67-
)}
68-
{...rest}
69-
>
96+
<aside className={variants({ variant, className })} {...rest}>
7097
{!hideEditButton && editPath && (
7198
<ButtonLink
7299
href={editPath}
@@ -81,13 +108,14 @@ const TableOfContents = ({
81108
{t("edit-page")}
82109
</ButtonLink>
83110
)}
84-
<div className="uppercase text-body-medium">{t("on-this-page")}</div>
111+
<div className={labelVariants({ variant })}>{t("on-this-page")}</div>
85112
<ul className="m-0 mb-2 mt-2 list-none gap-2 border-s border-s-body-medium ps-4 pt-0 text-sm">
86113
<ItemsList
87114
items={items}
88115
depth={0}
89116
maxDepth={maxDepth ? maxDepth : 1}
90117
activeHash={activeHash}
118+
variant={variant}
91119
/>
92120
</ul>
93121
</aside>

src/components/ui/section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { cva, type VariantProps } from "class-variance-authority"
44
import { cn } from "@/lib/utils/cn"
55

66
// TODO: Add to design system
7-
const variants = cva("w-full scroll-mt-24", {
7+
const variants = cva("w-full scroll-mt-24 lg:scroll-mt-28", {
88
variants: {
99
variant: {
1010
responsiveFlex: "flex flex-col gap-8 md:flex-row lg:gap-16",
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"adoption-chart-artists-label": "Artists",
3+
"adoption-chart-column-now-label": "Now",
4+
"adoption-chart-companies-label": "Companies",
5+
"adoption-chart-developers-label": "Developers",
6+
"adoption-chart-gamers-label": "Gamers",
7+
"adoption-chart-investors-label": "Investors",
8+
"adoption-chart-musicians-label": "Musicians",
9+
"adoption-chart-refugees-label": "Refugees",
10+
"adoption-chart-writers-label": "Writers",
11+
"energy-consumption-chart-airbnb-label": "AirBnB",
12+
"energy-consumption-chart-btc-pow-label": "BTC PoW",
13+
"energy-consumption-chart-eth-pos-label": "ETH PoS",
14+
"energy-consumption-chart-eth-pow-label": "ETH PoW",
15+
"energy-consumption-chart-gaming-us-label": "Gaming in the US",
16+
"energy-consumption-chart-global-data-centers-label": "Global data centers",
17+
"energy-consumption-chart-netflix-label": "Netflix",
18+
"energy-consumption-chart-paypal-label": "PayPal",
19+
"energy-consumption-gold-mining-cbeci-label": "Gold mining",
20+
"energy-consumption-chart-legend": "Annual Energy Consumption in TWh/yr"
21+
}

0 commit comments

Comments
 (0)