'use client'; import { useEffect, useState } from 'react'; import { BadgeDefinition } from '@/lib/storage'; import { Trophy, Footprints, Flame, Shield, Swords, Crown, Sparkles, } from 'lucide-react'; interface CelebrationAnimationProps { badge: BadgeDefinition; onComplete: () => void; } const iconMap: Record = { Footprints, Flame, Shield, Swords, Crown, Trophy, }; export function CelebrationAnimation({ badge, onComplete, }: CelebrationAnimationProps) { const [particles, setParticles] = useState< Array<{ id: number; x: number; y: number; color: string; delay: number }> >([]); useEffect(() => { // Generate confetti particles const newParticles = Array.from({ length: 50 }, (_, i) => ({ id: i, x: Math.random() * 100, y: Math.random() * 100, color: ['#fbbf24', '#a855f7', '#22c55e', '#3b82f6', '#ef4444'][ Math.floor(Math.random() * 5) ], delay: Math.random() * 0.5, })); setParticles(newParticles); // Auto dismiss after 3 seconds const timer = setTimeout(() => { onComplete(); }, 3000); return () => clearTimeout(timer); }, [onComplete]); const Icon = iconMap[badge.icon] || Trophy; return (
{/* Confetti particles */} {particles.map((particle) => (
))} {/* Badge reveal */}
{/* Glow effect */}
{/* Main content */}
{/* Sparkles */}
{/* Badge icon */}
{/* Text */}

Achievement Unlocked!

{badge.name}

{badge.description}

{/* Tap to dismiss hint */}

Tap anywhere to dismiss

); }