import { useCallback, useEffect, useRef, useState } from 'react'; /* @component-map * App — Main container, renders the Hello World greeting with animated letters, orbs, confetti, and replay button * @end-component-map */ function Confetti({ trigger }) { const [particles, setParticles] = useState([]); const idRef = useRef(0); const colors = ['#FFD93D','#FF6B6B','#6BCB77','#4D96FF','#9B59B6','#FF8C42','#E84393']; useEffect(() => { if (trigger === 0) return; const newParticles = []; for (let i = 0; i < 40; i++) { newParticles.push({ id: idRef.current++, left: Math.random() * 100 + '%', background: colors[Math.floor(Math.random() * colors.length)], animationDelay: (Math.random() * 3) + 's', animationDuration: (3 + Math.random() * 2) + 's', width: (6 + Math.random() * 6) + 'px', height: (6 + Math.random() * 6) + 'px', borderRadius: Math.random() > 0.5 ? '50%' : '2px', }); } setParticles(prev => [...prev, ...newParticles]); const timer = setTimeout(() => { setParticles(prev => prev.filter(p => !newParticles.find(np => np.id === p.id))); }, 5000); return () => clearTimeout(timer); }, [trigger]); return particles.map(p => (
)); } function App() { const text = "Hello, World!"; const [letterKey, setLetterKey] = useState(0); const [confettiTrigger, setConfettiTrigger] = useState(0); useEffect(() => { const timer = setTimeout(() => setConfettiTrigger(1), 400); return () => clearTimeout(timer); }, []); const replayAnim = useCallback(() => { setLetterKey(k => k + 1); setConfettiTrigger(t => t + 1); }, []); return (