import React, { useState } from 'react'; import { Info, CheckCircle, AlertTriangle, XCircle, X } from 'lucide-react'; type AlertVariant = 'info' | 'success' | 'warning' | 'error'; interface AlertProps { variant: AlertVariant; title?: string; children: React.ReactNode; dismissible?: boolean; } const variantStyles: Record = { info: { container: 'bg-blue-50 text-blue-800', border: 'border-blue-200', icon: Info, iconColor: 'text-blue-500', }, success: { container: 'bg-green-50 text-green-800', border: 'border-green-200', icon: CheckCircle, iconColor: 'text-green-500', }, warning: { container: 'bg-yellow-50 text-yellow-800', border: 'border-yellow-200', icon: AlertTriangle, iconColor: 'text-yellow-500', }, error: { container: 'bg-red-50 text-red-800', border: 'border-red-200', icon: XCircle, iconColor: 'text-red-500', }, }; export default function Alert({ variant, title, children, dismissible = false }: AlertProps) { const [isVisible, setIsVisible] = useState(true); if (!isVisible) return null; const style = variantStyles[variant]; const Icon = style.icon; return (
{title && ( {title} )}
{children}
{dismissible && ( )}
); }