diff --git a/app/[locale]/10years/_components/AdoptionSwiper.tsx b/app/[locale]/10years/_components/AdoptionSwiper.tsx index 17f5b6623fa..9ab70a033a9 100644 --- a/app/[locale]/10years/_components/AdoptionSwiper.tsx +++ b/app/[locale]/10years/_components/AdoptionSwiper.tsx @@ -11,13 +11,20 @@ import { import { cn } from "@/lib/utils/cn" -import { adoptionCards, adoptionStyles } from "./data" +import { AdoptionCard } from "./types" -const AdoptionSwiper = () => { +type AdoptionCardProps = { + adoptionCards: AdoptionCard[] + adoptionStyles: string[] +} +const AdoptionSwiper = ({ + adoptionCards, + adoptionStyles, +}: AdoptionCardProps) => { return (
Celebrating 10 years of{" "} - {words.text} + + + {initialText} + + + {words.text} + +
diff --git a/app/[locale]/10years/_components/data.tsx b/app/[locale]/10years/_components/data.tsx index a5d5bf854fe..d4c0b80554d 100644 --- a/app/[locale]/10years/_components/data.tsx +++ b/app/[locale]/10years/_components/data.tsx @@ -1,5 +1,7 @@ import Link from "@/components/ui/Link" +import { AdoptionCard } from "./types" + import Adoption1Image from "@/public/images/10-year-anniversary/adoption-1.png" import Adoption2Image from "@/public/images/10-year-anniversary/adoption-2.png" import Adoption3Image from "@/public/images/10-year-anniversary/adoption-3.png" @@ -7,13 +9,13 @@ import DefiSummerImage from "@/public/images/10-year-anniversary/defi-summer.png import EthETFImage from "@/public/images/10-year-anniversary/eth-etf.png" import EthereumLaunchImage from "@/public/images/10-year-anniversary/ethereum-launch.png" import NftImage from "@/public/images/10-year-anniversary/nft-frontier.png" +import TheMergeImage from "@/public/images/10-year-anniversary/robot-and-crowd-cheering.png" import Adoption5Image from "@/public/images/10-year-anniversary/robot-walking.png" -import TheMergeImage from "@/public/images/10-year-anniversary/the-merge.png" import StableCoinImage from "@/public/images/10-year-anniversary/the-pioneer-stablecoin.png" import Adoption4Image from "@/public/images/10-year-anniversary/walking-talking-1.png" import Adoption6Image from "@/public/images/10-year-anniversary/walking-talking-2.png" -const adoptionCards = [ +const adoptionCards: AdoptionCard[] = [ { image: Adoption1Image, title: "Decade of Decentralization", @@ -102,12 +104,12 @@ const adoptionCards = [ // duplicate 1 2 3, 1 2 3 to fix mobile slider bug where styles are not applied const adoptionStyles = [ - "bg-background bg-gradient-to-t from-20% to-60% from-accent-c/10 to-accent-c/5 dark:from-accent-c/20 dark:to-accent-c/10 border-accent-c/10", + "bg-background bg-gradient-to-b from-20% to-60% from-accent-c/10 to-accent-c/5 dark:from-accent-c/20 dark:to-accent-c/10 border-accent-c/10", "bg-background bg-gradient-to-b from-20% to-60% from-accent-b/10 to-accent-b/5 dark:from-accent-b/20 dark:to-accent-b/10 border-accent-b/10", - "bg-background bg-gradient-to-r from-20% to-60% from-accent-a/10 to-accent-a/5 dark:from-accent-a/20 dark:to-accent-a/10 border-accent-a/10", - "bg-background bg-gradient-to-t from-20% to-60% from-accent-c/10 to-accent-c/5 dark:from-accent-c/20 dark:to-accent-c/10 border-accent-c/10", + "bg-background bg-gradient-to-b from-20% to-60% from-accent-a/10 to-accent-a/5 dark:from-accent-a/20 dark:to-accent-a/10 border-accent-a/10", + "bg-background bg-gradient-to-b from-20% to-60% from-accent-c/10 to-accent-c/5 dark:from-accent-c/20 dark:to-accent-c/10 border-accent-c/10", "bg-background bg-gradient-to-b from-20% to-60% from-accent-b/10 to-accent-b/5 dark:from-accent-b/20 dark:to-accent-b/10 border-accent-b/10", - "bg-background bg-gradient-to-r from-20% to-60% from-accent-a/10 to-accent-a/5 dark:from-accent-a/20 dark:to-accent-a/10 border-accent-a/10", + "bg-background bg-gradient-to-b from-20% to-60% from-accent-a/10 to-accent-a/5 dark:from-accent-a/20 dark:to-accent-a/10 border-accent-a/10", ] const innovationCards = [ diff --git a/app/[locale]/10years/_components/types.ts b/app/[locale]/10years/_components/types.ts new file mode 100644 index 00000000000..48c2f690a12 --- /dev/null +++ b/app/[locale]/10years/_components/types.ts @@ -0,0 +1,20 @@ +import { StaticImageData } from "next/image" + +export type Story = { + storyEnglish: string + storyOriginal: string + category: string + name: string + date: string + country: string + twitter: string + region: string +} + +export type AdoptionCard = { + image: StaticImageData + title: string + description: React.ReactNode + href: string + linkText: string +} diff --git a/app/[locale]/10years/_components/utils.ts b/app/[locale]/10years/_components/utils.ts new file mode 100644 index 00000000000..ca6740971ce --- /dev/null +++ b/app/[locale]/10years/_components/utils.ts @@ -0,0 +1,31 @@ +import { formatDate, isValidDate } from "@/lib/utils/date" + +import { DEFAULT_LOCALE } from "@/lib/constants" + +import type { Story } from "./types" + +const parseDate = (date: string, locale = DEFAULT_LOCALE): string => { + // TODO: Remove this check when spreadsheet is fixed + // Currently dates are in the formatted as "DD.MM." which is not parsable by Date.parse + // If partially valid date, reformat it + const partiallyValidDate = /^(\d{1,2})\.(\d{1})\.$/ + if (partiallyValidDate.test(date)) { + const [, day, month] = date.match(partiallyValidDate) || [] + const newDate = `2025-${month.padStart(2, "0")}-${day.padStart(2, "0")}` + return formatDate(newDate, locale) + } + + // If the date is already in a valid format, return it + if (isValidDate(date)) return formatDate(date, locale) + // If the date is not recognized, return original value + return date +} + +export const parseStoryDates = ( + stories: Story[], + locale = DEFAULT_LOCALE +): Story[] => + stories.map(({ date, ...story }) => ({ + ...story, + date: parseDate(date, locale), + })) diff --git a/app/[locale]/10years/page.tsx b/app/[locale]/10years/page.tsx index e4c5bfe8946..231da40f07e 100644 --- a/app/[locale]/10years/page.tsx +++ b/app/[locale]/10years/page.tsx @@ -29,6 +29,7 @@ import InnovationSwiper from "./_components/InnovationSwiper" import Stories from "./_components/Stories" import TenYearGlobe from "./_components/TenYearGlobe" import TenYearHero from "./_components/TenYearHero" +import { parseStoryDates } from "./_components/utils" import { fetch10YearEvents } from "@/lib/api/fetch10YearEvents" import { fetch10YearStories } from "@/lib/api/fetch10YearStories" @@ -54,6 +55,8 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => { const [fetched10YearEvents, fetched10YearStories] = await loadData() + const stories = parseStoryDates(fetched10YearStories, locale) + // Get i18n messages const allMessages = await getMessages({ locale }) const requiredNamespaces = getRequiredNamespacesForPage("/10years") @@ -271,13 +274,16 @@ const Page = async ({ params }: { params: Promise<{ locale: Lang }> }) => {
diff --git a/app/[locale]/_components/home.tsx b/app/[locale]/_components/home.tsx
index 472dc7a3ef3..db09497a328 100644
--- a/app/[locale]/_components/home.tsx
+++ b/app/[locale]/_components/home.tsx
@@ -608,7 +608,10 @@ const HomePage = ({
-