Skip to content

Commit 268347e

Browse files
committed
refactor: AdoptionSwiper lazy loading
1 parent 42e6555 commit 268347e

File tree

4 files changed

+89
-69
lines changed

4 files changed

+89
-69
lines changed

app/[locale]/10years/_components/AdoptionSwiper.tsx

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"use client"
2+
3+
import { Image } from "@/components/Image"
4+
import Translation from "@/components/Translation"
5+
import { ButtonLink } from "@/components/ui/buttons/Button"
6+
import {
7+
Swiper,
8+
SwiperContainer,
9+
SwiperNavigation,
10+
SwiperSlide,
11+
} from "@/components/ui/swiper"
12+
13+
import { cn } from "@/lib/utils/cn"
14+
15+
import { AdoptionCard } from "../types"
16+
17+
type AdoptionCardProps = {
18+
adoptionCards: AdoptionCard[]
19+
adoptionStyles: string[]
20+
}
21+
22+
const AdoptionSwiper = ({
23+
adoptionCards,
24+
adoptionStyles,
25+
}: AdoptionCardProps) => (
26+
<div className="flex flex-1 flex-col gap-6 md:hidden">
27+
<SwiperContainer className="mx-auto w-full max-w-[550px]">
28+
<Swiper spaceBetween={32}>
29+
{adoptionCards.map(({ image, linkText, href, title }, index) => {
30+
return (
31+
<SwiperSlide key={title}>
32+
<div
33+
className={cn("h-full rounded-2xl p-8", adoptionStyles[index])}
34+
>
35+
<Image
36+
src={image}
37+
alt={title}
38+
className="mx-auto mb-4 h-36 object-contain"
39+
/>
40+
<h3 className="mb-4 text-2xl font-bold">{title}</h3>
41+
<p className="mb-8">
42+
<Translation
43+
id={`page-10-year-adoption-card-${index + 1}-description`}
44+
ns="page-10-year-anniversary"
45+
/>
46+
</p>
47+
<ButtonLink href={href} hideArrow variant="outline">
48+
{linkText}
49+
</ButtonLink>
50+
</div>
51+
</SwiperSlide>
52+
)
53+
})}
54+
<SwiperNavigation />
55+
</Swiper>
56+
</SwiperContainer>
57+
</div>
58+
)
59+
60+
export default AdoptionSwiper
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Skeleton } from "@/components/ui/skeleton"
2+
3+
const Loading = () => (
4+
<div className="flex w-full flex-col items-center gap-6 md:hidden">
5+
<div className="flex w-full max-w-[550px] flex-col gap-6 rounded-2xl bg-card-gradient-secondary p-4 sm:p-6 xl:max-w-[700px]">
6+
<Skeleton className="mx-auto size-36 rounded-4xl" />
7+
<Skeleton className="h-8 w-1/2" />
8+
<div className="space-y-1">
9+
<Skeleton className="h-5 w-[95%]" />
10+
<Skeleton className="h-5 w-full" />
11+
<Skeleton className="h-5 w-1/2" />
12+
</div>
13+
<div className="w-2/5 rounded border px-4 py-3">
14+
<Skeleton className="h-5" />
15+
</div>
16+
</div>
17+
<Skeleton className="h-6 w-40 rounded-full" />
18+
</div>
19+
)
20+
21+
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("./client"), {
6+
ssr: false,
7+
loading: Loading,
8+
})

0 commit comments

Comments
 (0)