import { useSyncExternalStore } from "react"; import { AlertCircle, AlertTriangle, CheckCircle2, Info, X, XCircle, } from "lucide-react"; import { dismiss, getActiveToasts, subscribe, type NotifLevel, } from "../lib/notifications"; export const LEVEL_STYLE: Record< NotifLevel, { icon: typeof Info; color: string } > = { info: { icon: Info, color: "text-accent" }, success: { icon: CheckCircle2, color: "text-emerald-400" }, warning: { icon: AlertTriangle, color: "text-amber-400" }, error: { icon: AlertCircle, color: "text-red-400" }, fatal: { icon: XCircle, color: "text-red-500" }, }; export default function Toaster() { const toasts = useSyncExternalStore(subscribe, getActiveToasts, getActiveToasts); return (
{toasts.map((t) => { const { icon: Icon, color } = LEVEL_STYLE[t.level]; return (
{t.title &&
{t.title}
}
{t.message}
{t.action && ( )}
); })}
); }