// Typed, accessible alert banner with optional dismiss button. import { cn } from "../../lib/utils"; export type AlertType = "error" | "info" | "success" | "warning"; export interface AlertProps { type?: AlertType; title?: string; message: string; onClose?: () => void; className?: string; } const config: Record = { error: { bg: "bg-red-50 border-red-200 text-red-700", icon: "⚠", iconLabel: "Error" }, info: { bg: "bg-blue-50 border-blue-200 text-blue-700", icon: "ℹ", iconLabel: "Info" }, success: { bg: "bg-emerald-50 border-emerald-200 text-emerald-700", icon: "✓", iconLabel: "Success" }, warning: { bg: "bg-amber-50 border-amber-200 text-amber-700", icon: "!", iconLabel: "Warning" }, }; /** * @example * setErr(null)} /> * */ export function Alert({ type = "error", title, message, onClose, className }: AlertProps) { const { bg, icon, iconLabel } = config[type]; return (
{icon}
{title &&

{title}

}

{message}

{onClose && ( )}
); }