diff --git a/packages/website/src/components/Countdown.tsx b/packages/website/src/components/Countdown.tsx new file mode 100644 index 000000000..fac933852 --- /dev/null +++ b/packages/website/src/components/Countdown.tsx @@ -0,0 +1,89 @@ +import { Code, Flex, Heading, Link, Text } from "@radix-ui/themes"; +import { useEffect, useState, type ReactNode } from "react"; +import type { MaybeSkeletonComponentProps } from "../types/maybeSkeletonComponentProps"; +import { InlineSkeleton } from "./InlineSkeleton"; + +const TIME = 1792598400 * 1000; + +export function Countdown({ skeleton }: MaybeSkeletonComponentProps) { + const [timeLeft, setTimeLeft] = useState(TIME - Date.now()); + + useEffect(() => { + const interval = setInterval(() => { + setTimeLeft(TIME - Date.now()); + }, 1000); + + return () => { + clearInterval(interval); + }; + }, []); + + let string: ReactNode; + + if (timeLeft > 0) { + const hours = Math.floor(timeLeft / (1000 * 60 * 60)); + const minutes = Math.floor((timeLeft / (1000 * 60)) % 60) + .toString() + .padStart(2, "0"); + const seconds = Math.floor((timeLeft / 1000) % 60) + .toString() + .padStart(2, "0"); + + string = ( + <> + revealed in{" "} + + {hours}h {minutes}m {seconds}s + + + ); + } else { + string = "have been revealed."; + } + + return ( + + + + + + + + Tier XIs {!skeleton && string}{" "} + {skeleton && } + + + Get ready to go to the Tankopedia! + + + + + + ); +} diff --git a/packages/website/src/pages/[...chunk_default]/[...locale]/index.astro b/packages/website/src/pages/[...chunk_default]/[...locale]/index.astro index 21a5a0d8f..48e147252 100644 --- a/packages/website/src/pages/[...chunk_default]/[...locale]/index.astro +++ b/packages/website/src/pages/[...chunk_default]/[...locale]/index.astro @@ -5,6 +5,7 @@ import locales from "@blitzkit/i18n/locales.json"; import { literals } from "@blitzkit/i18n/src/literals"; import { Box, Flex, Link } from "@radix-ui/themes"; import { AesonPlug } from "../../../components/AesonPlug"; +import { Countdown } from "../../../components/Countdown"; import HomeHero from "../../../components/HomeHero.astro"; import { Plugs } from "../../../components/Plugs"; import ToolCard from "../../../components/ToolCard.astro"; @@ -65,6 +66,8 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => { + + { locale !== locales.default && (