import { motion } from "framer-motion"; import { AlertTriangle, CheckCircle, Info, X } from "lucide-react"; import { useState } from "react"; interface Alert { id: string; type: "success" | "warning" | "info" | "error"; message: string; timestamp: string; } interface Props { alerts?: Alert[]; } const alertStyles = { success: { bg: "from-green-500/10 via-emerald-500/5 to-transparent", border: "border-green-500/30", icon: CheckCircle, iconColor: "text-green-400", glow: "shadow-green-500/20" }, warning: { bg: "from-yellow-500/10 via-amber-500/5 to-transparent", border: "border-yellow-500/30", icon: AlertTriangle, iconColor: "text-yellow-400", glow: "shadow-yellow-500/20" }, info: { bg: "from-blue-500/10 via-cyan-500/5 to-transparent", border: "border-blue-500/30", icon: Info, iconColor: "text-blue-400", glow: "shadow-blue-500/20" }, error: { bg: "from-red-500/10 via-rose-500/5 to-transparent", border: "border-red-500/30", icon: AlertTriangle, iconColor: "text-red-400", glow: "shadow-red-500/20" } }; const defaultAlerts: Alert[] = [ { id: "1", type: "success", message: "All systems operational • 99.9% uptime this month", timestamp: "Just now" } ]; export default function AlertBanner({ alerts = defaultAlerts }: Props) { const [dismissedIds, setDismissedIds] = useState>(new Set()); const visibleAlerts = alerts.filter(a => !dismissedIds.has(a.id)); if (visibleAlerts.length === 0) return null; const alert = visibleAlerts[0]; const style = alertStyles[alert.type]; const Icon = style.icon; return (
{/* Animated shimmer */}
{/* Pulsing icon */} {/* Message */} {alert.message} {/* Timestamp */} {alert.timestamp} {/* Dismiss button */}
); }