import { For, createSignal } from "solid-js"; import { Portal } from "solid-js/web"; import { IconCheck, IconX } from "@/components/ui/icons"; import { cn } from "@/lib/cn"; import { useT } from "@/stores/preferences-context"; type Toast = { id: number; title: string; }; const [toasts, setToasts] = createSignal([]); let nextId = 1; export function showToast(props: { title: string }) { const id = nextId++; setToasts((items) => [...items, { id, title: props.title }].slice(-4)); window.setTimeout(() => dismissToast(id), 3000); } function dismissToast(id: number) { setToasts((items) => items.filter((item) => item.id !== id)); } export function Toaster() { const t = useT(); return ( {/* A polite live region: a saved/deleted confirmation is read out without stealing focus from where the user is working. */}
{(toast) => (

{toast.title}

)}
); }