Skip to content

Commit e4f175c

Browse files
authored
Merge pull request #15694 from ethereum/hot-fix-resources
[hot-fix] resources page to ssr
2 parents 6e75965 + d4588bb commit e4f175c

File tree

10 files changed

+302
-295
lines changed

10 files changed

+302
-295
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client"
2+
3+
import { motion } from "framer-motion"
4+
5+
import { ButtonLink } from "@/components/ui/buttons/Button"
6+
7+
import { cn } from "@/lib/utils/cn"
8+
9+
import type { DashboardSection } from "../types"
10+
11+
import { useActiveHash } from "@/hooks/useActiveHash"
12+
13+
const ResourcesNav = ({
14+
resourceSections,
15+
eventCategory,
16+
}: {
17+
resourceSections: DashboardSection[]
18+
eventCategory: string
19+
}) => {
20+
const activeSection = useActiveHash(
21+
resourceSections.map(({ key }) => key),
22+
"0% 0% -70% 0%"
23+
).replace(/^#/, "")
24+
25+
return (
26+
<nav className="z-sticky mx-4 flex max-w-full gap-1 overflow-x-auto bg-background p-2 shadow md:max-w-[calc(100%-2rem)] md:rounded-2xl md:border md:p-0.5 md:shadow-lg">
27+
{resourceSections.map(({ key, title, icon }) => (
28+
<ButtonLink
29+
key={key}
30+
href={`#${key}`}
31+
variant="ghost"
32+
isSecondary
33+
className={cn(
34+
"relative text-nowrap rounded-xl px-4 py-2 text-sm [&_svg]:shrink-0 [&_svg]:text-sm",
35+
activeSection === key && "!text-primary"
36+
)}
37+
customEventOptions={{
38+
eventCategory,
39+
eventAction: "whats_on_this_page",
40+
eventName: key,
41+
}}
42+
>
43+
{activeSection === key && (
44+
<motion.div
45+
layoutId="active-section-highlight"
46+
className="absolute inset-0 z-0 rounded-xl bg-primary-low-contrast"
47+
/>
48+
)}
49+
{icon && <span className="z-10 text-lg">{icon}</span>}
50+
<span className="relative z-10">{title}</span>
51+
</ButtonLink>
52+
))}
53+
</nav>
54+
)
55+
}
56+
57+
export default ResourcesNav

src/components/Resources/index.tsx renamed to app/[locale]/resources/_components/ResourcesUI.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import { Tag } from "@/components/ui/tag"
33

44
import { cn } from "@/lib/utils/cn"
55

6-
import { Image } from "../Image"
7-
8-
import { Item } from "./types"
6+
import { Image } from "../../../../src/components/Image"
7+
import { Item } from "../types"
98

109
export const DashboardBox = ({
1110
className,
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"use client"
2+
3+
import { useEffect, useState } from "react"
4+
import { useLocale } from "next-intl"
5+
6+
import RadialChart from "@/components/RadialChart"
7+
8+
const SlotCountdownChart = ({ children }: { children: string }) => {
9+
const [timeToNextBlock, setTimeToNextBlock] = useState(12)
10+
const locale = useLocale()
11+
12+
useEffect(() => {
13+
const genesisTime = new Date("2020-12-01T12:00:23Z").getTime()
14+
const updateTime = () => {
15+
const now = Date.now()
16+
const timeElapsed = (now - genesisTime) / 1000
17+
const timeToNext = 12 - (timeElapsed % 12)
18+
setTimeToNextBlock(Math.floor(timeToNext) || 12)
19+
}
20+
21+
updateTime()
22+
const interval = setInterval(updateTime, 1000)
23+
return () => clearInterval(interval)
24+
}, [])
25+
26+
return (
27+
<RadialChart
28+
value={timeToNextBlock}
29+
totalValue={12}
30+
displayValue={new Intl.NumberFormat(locale, {
31+
style: "unit",
32+
unit: "second",
33+
unitDisplay: "narrow",
34+
}).format(timeToNextBlock)}
35+
label={children}
36+
/>
37+
)
38+
}
39+
40+
export default SlotCountdownChart

app/[locale]/resources/_components/resources.tsx

Lines changed: 0 additions & 215 deletions
This file was deleted.

0 commit comments

Comments
 (0)