File size: 4,453 Bytes
d8804ab
 
 
 
 
587459d
d8804ab
 
587459d
d8804ab
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
587459d
d8804ab
 
587459d
 
 
 
 
 
 
 
 
d8804ab
 
 
587459d
d8804ab
 
 
 
 
 
 
 
 
 
 
587459d
d8804ab
 
 
 
 
 
 
 
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
"use client";

import React, { useState, useEffect } from "react";
import { motion, AnimatePresence } from "framer-motion";
import { X, ArrowRight } from "lucide-react";
import { useLanguage } from "@/components/LanguageContext";

export function WaitlistSocialProofTicker() {
  const { t, language } = useLanguage();
  const [isVisible, setIsVisible] = useState(false);
  const [isDismissed, setIsDismissed] = useState(false);
  const [queueCount, setQueueCount] = useState(2147);

  useEffect(() => {
    if (isDismissed) return;

    // Show initial notification after a brief delay
    const initialDelay = setTimeout(() => {
      setIsVisible(true);
    }, 2000);

    // Simulate occasional live queue increments
    const interval = setInterval(() => {
      if (Math.random() > 0.5) {
        setQueueCount((prev) => prev + Math.floor(Math.random() * 3) + 1);
      }
    }, 8500);

    return () => {
      clearTimeout(initialDelay);
      clearInterval(interval);
    };
  }, [isDismissed]);

  if (isDismissed) return null;

  return (
    <AnimatePresence>
      {isVisible && (
        <motion.div
          initial={{ opacity: 0, y: 50, scale: 0.95 }}
          animate={{ opacity: 1, y: 0, scale: 1 }}
          exit={{ opacity: 0, y: 30, scale: 0.95 }}
          transition={{ duration: 0.5, ease: "easeOut" }}
          className="group fixed bottom-6 left-1/2 -translate-x-1/2 z-50 w-max max-w-[calc(100vw-3rem)] bg-black/90 dark:bg-black/95 backdrop-blur-md border border-primary/20 px-4 sm:px-5 py-3 shadow-[0_10px_30px_rgba(255,170,64,0.06)] flex items-center gap-3 sm:gap-4 text-left font-mono text-[10px] sm:text-xs select-none rounded-full cursor-pointer hover:border-primary/40 hover:bg-black transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/50 focus-visible:ring-offset-2 focus-visible:ring-offset-black"
          role="status"
          aria-live="polite"
          onClick={() => {
            // Focus on waitlist form or scroll to it
            document.getElementById('email-input')?.scrollIntoView({ behavior: 'smooth', block: 'center' });
            setTimeout(() => {
              document.getElementById('email-input')?.focus();
            }, 500);
          }}
        >
          {/* Glowing Green Signal Pulse */}
          <div className="shrink-0 flex items-center justify-center">
            <span className="relative flex h-2 w-2">
              <span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"></span>
              <span className="relative inline-flex rounded-full h-2 w-2 bg-emerald-500"></span>
            </span>
          </div>

          {/* Event Content */}
          <div className="flex items-center gap-2 sm:gap-3 overflow-hidden text-ellipsis whitespace-nowrap">
            <span className="text-amber-400 font-bold uppercase tracking-widest text-[9px] sm:text-[10px]">{t("tickerLive")}</span>
            <span className="text-white/45">•</span>
            <span className="text-zinc-300 font-medium">
              {language === "ar" ? (
                <>
                  هناك <span className="font-bold text-white">{queueCount.toLocaleString()}</span> {t("tickerDevelopers")}
                </>
              ) : (
                <>
                  <span className="font-bold text-white">{queueCount.toLocaleString()}</span> {t("tickerDevelopers")}
                </>
              )}
            </span>
            <span className="hidden sm:inline text-white/45">•</span>
            <span className="hidden sm:flex items-center gap-1.5 text-amber-400/80 font-semibold group-hover:text-amber-400 transition-colors">
              {t("tickerClaim")} <ArrowRight className="w-3 h-3 transition-transform group-hover:translate-x-0.5 rtl:rotate-180" />
            </span>
          </div>

          {/* Close Action */}
          <button
            onClick={(e) => {
              e.stopPropagation();
              setIsVisible(false);
              setTimeout(() => setIsDismissed(true), 500);
            }}
            className="ml-auto text-zinc-500 hover:text-white transition-colors p-1 rounded-full cursor-pointer focus:outline-none focus:ring-1 focus:ring-amber-500 shrink-0"
            aria-label={t("tickerDismiss")}
          >
            <X className="w-3.5 h-3.5" />
          </button>
        </motion.div>
      )}
    </AnimatePresence>
  );
}