import { useToastStore, Toast, ToastType } from "../../state/toastStore"; import { semantic, surface, text } from "../../theme"; const typeStyles: Record = { success: { color: semantic.success, icon: "✓" }, error: { color: semantic.error, icon: "✕" }, warning: { color: semantic.warning, icon: "!" }, info: { color: semantic.info, icon: "i" }, }; function ToastItem({ toast, onDismiss }: { toast: Toast; onDismiss: () => void }) { const style = typeStyles[toast.type]; return (
{style.icon} {toast.message}
); } export function Toaster() { const toasts = useToastStore((state) => state.toasts); const removeToast = useToastStore((state) => state.removeToast); if (toasts.length === 0) return null; return ( <>
{toasts.map((toast) => ( removeToast(toast.id)} /> ))}
); }