import { useEffect, useState, useRef } from "react"; import { motion, AnimatePresence } from "motion/react"; interface SplashScreenProps { onDone: () => void; } const TITLE = "ALGOSCOPE"; const SUBTITLE = "Real-time algospeak & toxicity intelligence on Bluesky"; // Animated background nodes for the splash const BG_NODES = Array.from({ length: 14 }, (_, i) => ({ id: i, x: 8 + (i * 13.5) % 92, y: 10 + (i * 17) % 80, r: 3 + (i % 4) * 1.8, color: i % 3 === 0 ? "#ff4b4b" : i % 3 === 1 ? "#ff8c42" : "#a6b0ff", delay: i * 0.07, })); const BG_EDGES = [ [0, 3], [3, 7], [7, 11], [1, 5], [5, 9], [9, 12], [2, 6], [6, 10], [0, 4], [4, 8], [8, 13], [2, 7], [1, 6], [3, 10], [5, 12], [4, 11], ]; export function SplashScreen({ onDone }: SplashScreenProps) { const [lettersDone, setLettersDone] = useState(0); const [subtitleVisible, setSubtitleVisible] = useState(false); const [progress, setProgress] = useState(0); const [exiting, setExiting] = useState(false); const timerRef = useRef>(null); useEffect(() => { // Letter-by-letter reveal let i = 0; const letterInterval = setInterval(() => { i++; setLettersDone(i); if (i >= TITLE.length) clearInterval(letterInterval); }, 80); // Show subtitle after title is done timerRef.current = setTimeout(() => setSubtitleVisible(true), 900); // Progress bar let prog = 0; const progInterval = setInterval(() => { prog += 1.6; setProgress(Math.min(100, prog)); if (prog >= 100) clearInterval(progInterval); }, 28); // Exit const exitTimer = setTimeout(() => { setExiting(true); setTimeout(onDone, 700); }, 2600); return () => { clearInterval(letterInterval); clearInterval(progInterval); if (timerRef.current) clearTimeout(timerRef.current); clearTimeout(exitTimer); }; }, [onDone]); return ( {!exiting && ( {/* Animated background graph */} {BG_EDGES.map(([a, b], i) => { const nodeA = BG_NODES[a]; const nodeB = BG_NODES[b]; return ( ); })} {BG_NODES.map(node => ( ))} {/* Radial glow */}
{/* Logo icon */} A {/* Title: letter by letter */}
{TITLE.split("").map((char, i) => ( {char} ))}
{/* Subtitle */} {subtitleVisible && ( {SUBTITLE} )} {/* Progress bar */}
{/* Loading label */} {progress < 100 ? "Loading intelligence engine…" : "Ready"} {/* Version badge */} by Odeliya Charitonova · TAU CS )} ); }