Skip to content

Commit ea18af2

Browse files
committed
refactor: InnovationSwiper lazy loading
1 parent d61ed08 commit ea18af2

File tree

4 files changed

+85
-56
lines changed

4 files changed

+85
-56
lines changed

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

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use client"
2+
3+
import { Image } from "@/components/Image"
4+
import {
5+
Swiper,
6+
SwiperContainer,
7+
SwiperNavigation,
8+
SwiperSlide,
9+
} from "@/components/ui/swiper"
10+
11+
import type { InnovationCard } from "../types"
12+
13+
type InnovationSwiperProps = {
14+
innovationCards: InnovationCard[]
15+
}
16+
const InnovationSwiper = ({ innovationCards }: InnovationSwiperProps) => (
17+
<div className="w-[100%]">
18+
<SwiperContainer className="mx-auto w-full max-w-[550px] xl:max-w-[700px]">
19+
<Swiper
20+
className="mx-auto w-full max-w-[550px] xl:max-w-[700px]"
21+
spaceBetween={32}
22+
>
23+
{innovationCards.map(
24+
({ image, title, date, description1, description2 }, index) => (
25+
<SwiperSlide
26+
key={index}
27+
className="mx-auto flex w-full max-w-[550px] flex-col gap-4 rounded-lg bg-card-gradient-secondary p-4 sm:p-6 xl:max-w-[700px]"
28+
>
29+
<Image
30+
src={image}
31+
alt={title}
32+
className="mx-auto my-4 h-auto max-h-48 object-contain"
33+
/>
34+
<div>
35+
<h3 className="mb-4">{title}</h3>
36+
<p className="text-body-secondary mb-4">{date}</p>
37+
</div>
38+
<p className="mb-4">{description1}</p>
39+
<p className="mb-4">{description2}</p>
40+
</SwiperSlide>
41+
)
42+
)}
43+
<SwiperNavigation />
44+
</Swiper>
45+
</SwiperContainer>
46+
</div>
47+
)
48+
49+
export default InnovationSwiper
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="flex w-full flex-col items-center gap-6">
5+
<div className="flex w-full max-w-[550px] flex-col gap-6 rounded-lg bg-card-gradient-secondary p-4 sm:p-6 xl:max-w-[700px]">
6+
<Skeleton className="mx-auto size-48 rounded-4xl" />
7+
<Skeleton className="h-8 w-1/2" />
8+
<Skeleton className="h-5 w-1/4" />
9+
<div className="space-y-1">
10+
<Skeleton className="h-5 w-[85%] md:hidden" />
11+
<Skeleton className="h-5 w-[95%]" />
12+
<Skeleton className="h-5 w-full" />
13+
<Skeleton className="h-5 w-[90%]" />
14+
<Skeleton className="h-5 w-1/2" />
15+
</div>
16+
<div className="space-y-1">
17+
<Skeleton className="h-5 w-[92%] md:hidden" />
18+
<Skeleton className="h-5 w-[90%]" />
19+
<Skeleton className="h-5 w-full" />
20+
<Skeleton className="h-5 w-[95%]" />
21+
<Skeleton className="h-5 w-1/3" />
22+
</div>
23+
</div>
24+
<Skeleton className="h-6 w-40 rounded-full" />
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("./client"), {
6+
ssr: false,
7+
loading: Loading,
8+
})

0 commit comments

Comments
 (0)