File size: 4,823 Bytes
587459d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581e32b
 
587459d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bd47f11
587459d
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
"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>
  );
}