Skip to content

Commit edcb1a7

Browse files
committed
refactor: client, loading, server component breakdown
1 parent f5d172c commit edcb1a7

File tree

10 files changed

+110
-98
lines changed

10 files changed

+110
-98
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { MdInfoOutline } from "react-icons/md"
88

99
import type { ChildOnlyProp, CommitHistory, Lang } from "@/lib/types"
1010

11-
import AdoptionChart from "@/components/AdoptionChart/lazy"
11+
import AdoptionChart from "@/components/AdoptionChart/server"
1212
import {
1313
Banner,
1414
BannerBody,
@@ -18,12 +18,12 @@ import {
1818
} from "@/components/BannerGrid"
1919
import Callout from "@/components/Callout"
2020
import Card from "@/components/Card"
21-
import EnergyConsumptionChart from "@/components/EnergyConsumptionChart/lazy"
21+
import EnergyConsumptionChart from "@/components/EnergyConsumptionChart/server"
2222
import FeedbackCard from "@/components/FeedbackCard"
2323
import FileContributors from "@/components/FileContributors"
2424
import I18nProvider from "@/components/I18nProvider"
2525
import { Image, ImageProps } from "@/components/Image"
26-
import ListenToPlayer from "@/components/ListenToPlayer/lazy"
26+
import ListenToPlayer from "@/components/ListenToPlayer/server"
2727
import MainArticle from "@/components/MainArticle"
2828
import { StandaloneQuizWidget } from "@/components/Quiz/QuizWidget"
2929
import StatErrorMessage from "@/components/StatErrorMessage"

src/components/AdoptionChart/lazy.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Skeleton } from "@/components/ui/skeleton"
2+
3+
const Loading = () => (
4+
<div className="ms-8 grid w-full max-w-96 flex-[2] grid-cols-3 gap-x-4 gap-y-6">
5+
<div className="flex h-fit flex-1 flex-col self-end overflow-hidden rounded-4xl border">
6+
<Skeleton className="m-4" />
7+
</div>
8+
<div className="flex h-fit flex-1 flex-col self-end overflow-hidden rounded-4xl border [&>div]:border-b last:[&>div]:border-none">
9+
{Array.from({ length: 3 }).map((_, idx) => (
10+
<div key={"col2" + idx} className="border-b p-4 last:border-none">
11+
<Skeleton />
12+
</div>
13+
))}
14+
</div>
15+
<div className="flex h-fit flex-1 flex-col self-end overflow-hidden rounded-4xl border">
16+
{Array.from({ length: 8 }).map((_, idx) => (
17+
<div key={"col3" + idx} className="border-b p-4 last:border-none">
18+
<Skeleton />
19+
</div>
20+
))}
21+
</div>
22+
<Skeleton className="mx-6" />
23+
<Skeleton className="mx-6" />
24+
<Skeleton className="mx-6" />
25+
</div>
26+
)
27+
28+
export default Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dynamic from "next/dynamic"
2+
3+
import Loading from "./loading"
4+
5+
export default dynamic(() => import("./index"), {
6+
ssr: false,
7+
loading: Loading,
8+
})

src/components/EnergyConsumptionChart/lazy.tsx

Lines changed: 0 additions & 52 deletions
This file was deleted.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import { Skeleton } from "@/components/ui/skeleton"
2+
3+
const Loading = () => (
4+
<div className="my-16 w-full space-y-12">
5+
<div className="grid w-full grid-cols-5 place-items-end sm:grid-cols-6 md:grid-cols-10">
6+
<div className="flex flex-col items-center space-y-4">
7+
<Skeleton className="h-60 w-9" />
8+
<Skeleton className="h-8 w-9" />
9+
</div>
10+
<div className="flex flex-col items-center space-y-4">
11+
<Skeleton className="h-40 w-9" />
12+
<Skeleton className="h-8 w-9" />
13+
</div>
14+
<div className="flex flex-col items-center space-y-4">
15+
<Skeleton className="h-20 w-9" />
16+
<Skeleton className="h-8 w-9" />
17+
</div>
18+
<div className="flex flex-col items-center space-y-4">
19+
<Skeleton className="h-10 w-9" />
20+
<Skeleton className="h-8 w-9" />
21+
</div>
22+
<div className="flex flex-col items-center space-y-4 max-sm:hidden">
23+
<Skeleton className="h-6 w-9" />
24+
<Skeleton className="h-8 w-9" />
25+
</div>
26+
{Array.from({ length: 4 }).map((_, idx) => (
27+
<div
28+
key={idx}
29+
className="flex flex-col items-center space-y-4 max-md:hidden"
30+
>
31+
<Skeleton className="h-3 w-9" />
32+
<Skeleton className="h-8 w-9" />
33+
</div>
34+
))}
35+
<div className="flex flex-col items-center space-y-4">
36+
<Skeleton className="h-1 w-9" />
37+
<Skeleton className="h-8 w-9" />
38+
</div>
39+
</div>
40+
<Skeleton className="mx-auto w-80" />
41+
</div>
42+
)
43+
44+
export default Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dynamic from "next/dynamic"
2+
3+
import Loading from "./loading"
4+
5+
export default dynamic(() => import("./index"), {
6+
ssr: false,
7+
loading: Loading,
8+
})

src/components/ListenToPlayer/lazy.tsx

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Skeleton } from "../ui/skeleton"
2+
import { Spinner } from "../ui/spinner"
3+
4+
const Loading = () => (
5+
<div className="relative flex h-10.5 w-full items-center overflow-hidden rounded-lg lg:w-56">
6+
<Skeleton className="absolute size-full" />
7+
<Spinner className="ms-2 animate-pulse-light text-2xl" />
8+
</div>
9+
)
10+
11+
export default Loading
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import dynamic from "next/dynamic"
2+
3+
import Loading from "./loading"
4+
5+
export default dynamic(() => import("./index"), {
6+
ssr: false,
7+
loading: Loading,
8+
})

0 commit comments

Comments
 (0)