Skip to content

Commit 5a66964

Browse files
committed
refactor: AdoptionSwiper to accept data as props
add AdoptionCard type
1 parent 681c215 commit 5a66964

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,16 @@ import {
1111

1212
import { cn } from "@/lib/utils/cn"
1313

14-
import { adoptionCards, adoptionStyles } from "./data"
14+
import { AdoptionCard } from "./types"
1515

16-
const AdoptionSwiper = () => {
16+
type AdoptionCardProps = {
17+
adoptionCards: AdoptionCard[]
18+
adoptionStyles: string[]
19+
}
20+
const AdoptionSwiper = ({
21+
adoptionCards,
22+
adoptionStyles,
23+
}: AdoptionCardProps) => {
1724
return (
1825
<div className="flex flex-1 flex-col gap-6 md:hidden">
1926
<SwiperContainer className="mx-auto w-full max-w-[550px]">

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import Link from "@/components/ui/Link"
22

3+
import { AdoptionCard } from "./types"
4+
35
import Adoption1Image from "@/public/images/10-year-anniversary/adoption-1.png"
46
import Adoption2Image from "@/public/images/10-year-anniversary/adoption-2.png"
57
import Adoption3Image from "@/public/images/10-year-anniversary/adoption-3.png"
@@ -13,7 +15,7 @@ import StableCoinImage from "@/public/images/10-year-anniversary/the-pioneer-sta
1315
import Adoption4Image from "@/public/images/10-year-anniversary/walking-talking-1.png"
1416
import Adoption6Image from "@/public/images/10-year-anniversary/walking-talking-2.png"
1517

16-
const adoptionCards = [
18+
const adoptionCards: AdoptionCard[] = [
1719
{
1820
image: Adoption1Image,
1921
title: "Decade of Decentralization",

app/[locale]/10years/_components/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { StaticImageData } from "next/image"
2+
13
export type Story = {
24
storyEnglish: string
35
storyOriginal: string
@@ -8,3 +10,11 @@ export type Story = {
810
twitter: string
911
region: string
1012
}
13+
14+
export type AdoptionCard = {
15+
image: StaticImageData
16+
title: string
17+
description: React.ReactNode
18+
href: string
19+
linkText: string
20+
}

app/[locale]/10years/page.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,10 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
274274
</p>
275275
</div>
276276
</div>
277-
<AdoptionSwiper />
277+
<AdoptionSwiper
278+
adoptionCards={adoptionCards}
279+
adoptionStyles={adoptionStyles}
280+
/>
278281
<div className="hidden flex-1 flex-col gap-6 md:flex">
279282
{adoptionCards.map((card, index) => (
280283
<div

0 commit comments

Comments
 (0)