Basic Toast

This commit is contained in:
Sacha Weatherstone
2023-02-13 22:58:57 +10:00
parent 53a4ae290c
commit 35c88b67dd
4 changed files with 237 additions and 2 deletions
+34
View File
@@ -0,0 +1,34 @@
import { useToast } from "@core/hooks/useToast.js";
import {
Toast,
ToastClose,
ToastDescription,
ToastProvider,
ToastTitle,
ToastViewport
} from "@components/UI/Toast.js";
export function Toaster() {
const { toasts } = useToast();
return (
<ToastProvider>
{toasts.map(function ({ id, title, description, action, ...props }) {
return (
<Toast key={id} {...props}>
<div className="grid gap-1">
{title && <ToastTitle>{title}</ToastTitle>}
{description && (
<ToastDescription>{description}</ToastDescription>
)}
</div>
{action}
<ToastClose />
</Toast>
);
})}
<ToastViewport />
</ToastProvider>
);
}