Skip to content

Commit 342a2e6

Browse files
authored
Merge pull request #15750 from ethereum/lazy-find-wallets
feat: migrate /wallets/find-wallet to ssr, add loaders
2 parents c22de2d + bb190c0 commit 342a2e6

File tree

5 files changed

+116
-54
lines changed

5 files changed

+116
-54
lines changed

app/[locale]/wallets/find-wallet/_components/find-wallet.tsx

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

app/[locale]/wallets/find-wallet/page.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import {
77

88
import { Lang } from "@/lib/types"
99

10+
import Breadcrumbs from "@/components/Breadcrumbs"
11+
import FindWalletProductTable from "@/components/FindWalletProductTable/lazy"
1012
import I18nProvider from "@/components/I18nProvider"
13+
import MainArticle from "@/components/MainArticle"
1114

1215
import { getMetadata } from "@/lib/utils/metadata"
1316
import { getRequiredNamespacesForPage } from "@/lib/utils/translations"
@@ -17,10 +20,12 @@ import {
1720
getSupportedLocaleWallets,
1821
} from "@/lib/utils/wallets"
1922

20-
import FindWalletPage from "./_components/find-wallet"
21-
2223
const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
2324
const { locale } = await params
25+
const t = await getTranslations({
26+
locale,
27+
namespace: "page-wallets-find-wallet",
28+
})
2429

2530
setRequestLocale(locale)
2631

@@ -45,7 +50,19 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
4550

4651
return (
4752
<I18nProvider locale={locale} messages={messages}>
48-
<FindWalletPage wallets={wallets} />
53+
<MainArticle className="relative flex flex-col">
54+
<div className="flex w-full flex-col gap-8 px-4 pb-4 pt-11 md:w-1/2">
55+
<Breadcrumbs slug="wallets/find-wallet" />
56+
<h1 className="text-[2.5rem] leading-[1.4] md:text-5xl">
57+
{t("page-find-wallet-title")}
58+
</h1>
59+
<p className="mb-6 text-xl leading-[1.4] text-body-medium last:mb-8">
60+
{t("page-find-wallet-description")}
61+
</p>
62+
</div>
63+
64+
<FindWalletProductTable wallets={wallets} />
65+
</MainArticle>
4966
</I18nProvider>
5067
)
5168
}

src/components/FindWalletProductTable/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { useEffect, useMemo, useState } from "react"
1+
"use client"
2+
3+
import { useMemo, useState } from "react"
24

35
import {
46
ChainName,
@@ -22,15 +24,11 @@ import WalletSubComponent from "./WalletSubComponent"
2224
import { useTranslation } from "@/hooks/useTranslation"
2325

2426
const FindWalletProductTable = ({ wallets }: { wallets: Wallet[] }) => {
27+
console.log({ wallets })
2528
const { t } = useTranslation("page-wallets-find-wallet")
2629
const walletPersonas = useWalletPersonaPresets()
2730
const walletFilterOptions = useWalletFilters()
2831
const [filters, setFilters] = useState<FilterOption[]>(walletFilterOptions)
29-
const [isClient, setIsClient] = useState(false)
30-
31-
useEffect(() => {
32-
setIsClient(true)
33-
}, [])
3432

3533
const activeFilterKeys = useMemo(() => {
3634
const keys: string[] = []
@@ -101,10 +99,6 @@ const FindWalletProductTable = ({ wallets }: { wallets: Wallet[] }) => {
10199
})
102100
}
103101

104-
if (!isClient) {
105-
return null
106-
}
107-
108102
if (!Array.isArray(wallets)) {
109103
return <div>Error loading wallets</div>
110104
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import dynamic from "next/dynamic"
2+
3+
import Loading from "./loading"
4+
5+
export default dynamic(() => import("."), { ssr: false, loading: Loading })
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
import { Skeleton, SkeletonLines } from "../ui/skeleton"
2+
3+
const WalletSkeleton = () => (
4+
<>
5+
{Array.from({ length: 3 }).map((_, idx) => (
6+
<div key={"wallet" + idx} className="flex w-full gap-4 border-b p-4">
7+
<Skeleton className="size-16" />
8+
9+
<div className="flex flex-1 flex-col gap-2">
10+
<Skeleton className="h-7 w-full max-w-32" />
11+
<div className="flex gap-1">
12+
<Skeleton className="h-5 w-20 rounded-full" />
13+
<Skeleton className="h-5 w-20 rounded-full" />
14+
<Skeleton className="h-5 w-20 rounded-full" />
15+
</div>
16+
<SkeletonLines noOfLines={4} className="pt-4" />
17+
<div className="h-12 max-w-28 rounded border px-2 py-1.5">
18+
<Skeleton className="h-full" />
19+
</div>
20+
</div>
21+
<div className="flex items-center">
22+
<Skeleton className="size-6" />
23+
</div>
24+
</div>
25+
))}
26+
</>
27+
)
28+
29+
const Loading = () => (
30+
<div className="flex flex-col gap-16 px-4 lg:gap-20">
31+
<div className="flex max-w-full gap-4 overflow-x-scroll lg:grid lg:grid-cols-5">
32+
{Array.from({ length: 5 }).map((_, idx) => (
33+
<Skeleton
34+
key={"personas" + idx}
35+
className="h-40 min-w-48 rounded-2xl shadow-svg-button-link xl:h-32"
36+
/>
37+
))}
38+
</div>
39+
<div className="flex flex-[3] flex-col gap-2 lg:hidden">
40+
<div className="flex max-w-40 gap-2">
41+
<div className="flex flex-1 flex-col gap-1">
42+
<Skeleton className="w-full max-w-32" />
43+
<Skeleton className="w-full max-w-24" />
44+
</div>
45+
<Skeleton className="size-8" />
46+
</div>
47+
<WalletSkeleton />
48+
</div>
49+
<div className="flex gap-6 max-lg:hidden">
50+
<div className="flex max-w-80 flex-1 flex-col gap-2">
51+
<div className="flex h-10 items-center justify-between px-6 py-1.5">
52+
<Skeleton className="w-1/3" />
53+
<div className="flex w-1/3 gap-1">
54+
<Skeleton className="aspect-square" />
55+
<Skeleton className="w-full" />
56+
</div>
57+
</div>
58+
{Array.from({ length: 3 }).map((_, setIdx) => (
59+
<div
60+
key={"set" + setIdx}
61+
className="flex w-full flex-col border px-6 py-2"
62+
>
63+
{Array.from({ length: 4 }).map((_, idx) => (
64+
<div
65+
key={"set" + setIdx + "option" + idx}
66+
className="flex gap-2 border-b px-2 py-6 last:border-none"
67+
>
68+
<Skeleton className="aspect-square" />
69+
<Skeleton className="w-1/3" />
70+
<Skeleton className="ms-auto aspect-[2]" />
71+
</div>
72+
))}
73+
</div>
74+
))}
75+
</div>
76+
<div className="flex flex-1 flex-col gap-2">
77+
<div className="flex gap-2">
78+
<Skeleton className="w-full max-w-32" />
79+
<Skeleton className="w-8" />
80+
</div>
81+
<WalletSkeleton />
82+
</div>
83+
</div>
84+
</div>
85+
)
86+
87+
export default Loading

0 commit comments

Comments
 (0)