Spaces:
Paused
Paused
feat: implement security, dynamic language ssr, waitlist form redesign, and mobile audio access
bd47f11 Download components/CountdownBanner.tsx from samirhosninet/HubAPI: direct link, hf CLI and curl.
- Browser
- Download file 4.82 kB
-
https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/CountdownBanner.tsx
- Command line
-
hf download hf://spaces/samirhosninet/HubAPI/components/CountdownBanner.tsx
-
curl -L -o CountdownBanner.tsx https://huggingface.co/spaces/samirhosninet/HubAPI/resolve/main/components/CountdownBanner.tsx
4.82 kB
| "use client"; | |
| import { useEffect, useState } from "react"; | |
| import { motion } from "framer-motion"; | |
| import { useLanguage } from "@/components/LanguageContext"; | |
| import { SplitFlapText, SplitFlapMuteToggle } from "@/components/ui/split-flap-text"; | |
| export function CountdownBanner() { | |
| const { t } = useLanguage(); | |
| const [timeLeft, setTimeLeft] = useState({ | |
| days: "00", | |
| hours: "00", | |
| minutes: "00", | |
| seconds: "00", | |
| }); | |
| const [isMounted, setIsMounted] = useState(false); | |
| useEffect(() => { | |
| const init = setTimeout(() => { | |
| setIsMounted(true); | |
| // Set target date to July 12, 2026 (12/7/2026) | |
| const targetTime = new Date("2026-07-12T00:00:00").getTime(); | |
| const calculateTimeLeft = () => { | |
| const difference = targetTime - Date.now(); | |
| if (difference <= 0) { | |
| setTimeLeft({ days: "00", hours: "00", minutes: "00", seconds: "00" }); | |
| return; | |
| } | |
| const d = Math.floor(difference / (1000 * 60 * 60 * 24)); | |
| const h = Math.floor((difference / (1000 * 60 * 60)) % 24); | |
| const m = Math.floor((difference / 1000 / 60) % 60); | |
| const s = Math.floor((difference / 1000) % 60); | |
| setTimeLeft({ | |
| days: d.toString().padStart(2, "0"), | |
| hours: h.toString().padStart(2, "0"), | |
| minutes: m.toString().padStart(2, "0"), | |
| seconds: s.toString().padStart(2, "0"), | |
| }); | |
| }; | |
| calculateTimeLeft(); | |
| const interval = setInterval(calculateTimeLeft, 1000); | |
| // Store cleanup for interval | |
| return () => clearInterval(interval); | |
| }, 0); | |
| return () => clearTimeout(init); | |
| }, []); | |
| if (!isMounted) return null; | |
| return ( | |
| <motion.div | |
| initial={{ y: -50, opacity: 0 }} | |
| animate={{ y: 0, opacity: 1 }} | |
| transition={{ duration: 0.6, ease: "easeOut" }} | |
| className="w-full bg-background/95 border-b border-primary/10 backdrop-blur-md z-40 py-2 sm:py-2.5 px-4 flex flex-col md:flex-row items-center justify-center gap-3 sm:gap-6 text-xs font-mono select-none" | |
| > | |
| {/* Glow highlight */} | |
| <div className="absolute inset-x-0 bottom-0 h-[1px] bg-gradient-to-r from-transparent via-primary/30 to-transparent pointer-events-none" /> | |
| {/* Main Title & Indicator */} | |
| <div className="flex items-center gap-2"> | |
| <span className="relative flex h-2 w-2"> | |
| <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-primary opacity-75"></span> | |
| <span className="relative inline-flex rounded-full h-2 w-2 bg-primary"></span> | |
| </span> | |
| <span className="text-primary font-bold tracking-widest text-[10px] sm:text-xs"> | |
| {t("countdownTitle")} | |
| </span> | |
| </div> | |
| {/* Split Flap Countdown Digits */} | |
| <div className="flex items-center gap-4 sm:gap-6"> | |
| {/* Days */} | |
| <div className="flex items-center gap-1.5"> | |
| <div className="flex gap-[1px]"> | |
| <SplitFlapText text={timeLeft.days} speed={30} fontSize="14px" /> | |
| </div> | |
| <span className="text-[9px] text-muted-foreground uppercase tracking-widest font-bold ms-0.5"> | |
| {t("days")} | |
| </span> | |
| </div> | |
| <span className="text-primary/60 font-bold animate-pulse">:</span> | |
| {/* Hours */} | |
| <div className="flex items-center gap-1.5"> | |
| <div className="flex gap-[1px]"> | |
| <SplitFlapText text={timeLeft.hours} speed={30} fontSize="14px" /> | |
| </div> | |
| <span className="text-[9px] text-muted-foreground uppercase tracking-widest font-bold ms-0.5"> | |
| {t("hours")} | |
| </span> | |
| </div> | |
| <span className="text-primary/60 font-bold animate-pulse">:</span> | |
| {/* Minutes */} | |
| <div className="flex items-center gap-1.5"> | |
| <div className="flex gap-[1px]"> | |
| <SplitFlapText text={timeLeft.minutes} speed={30} fontSize="14px" /> | |
| </div> | |
| <span className="text-[9px] text-muted-foreground uppercase tracking-widest font-bold ms-0.5"> | |
| {t("minutes")} | |
| </span> | |
| </div> | |
| <span className="text-primary/60 font-bold animate-pulse">:</span> | |
| {/* Seconds */} | |
| <div className="flex items-center gap-1.5"> | |
| <div className="flex gap-[1px]"> | |
| <SplitFlapText text={timeLeft.seconds} speed={30} fontSize="14px" /> | |
| </div> | |
| <span className="text-[9px] text-muted-foreground uppercase tracking-widest font-bold ms-0.5"> | |
| {t("seconds")} | |
| </span> | |
| </div> | |
| </div> | |
| {/* Audio controls */} | |
| <div className="flex items-center gap-2 md:border-s border-border md:ps-6 border-t md:border-t-0 pt-2 md:pt-0"> | |
| <SplitFlapMuteToggle /> | |
| </div> | |
| </motion.div> | |
| ); | |
| } | |