import clsx from "clsx"; import { Check, CircleAlert, OctagonAlert, X } from "lucide-react"; import { Text, UNSTABLE_Toast as Toast, UNSTABLE_ToastContent as ToastContent, UNSTABLE_ToastQueue as ToastQueue, UNSTABLE_ToastRegion as ToastRegion, } from "react-aria-components"; import { flushSync } from "react-dom"; import { useTranslation } from "react-i18next"; import { SendouButton } from "./Button"; import styles from "./Toast.module.css"; export interface SendouToast { message: string; variant: "error" | "success" | "info"; } export const toastQueue = new ToastQueue({ wrapUpdate(fn) { if ("startViewTransition" in document) { document.startViewTransition(() => { flushSync(fn); }); } else { fn(); } }, }); export function SendouToastRegion() { const { t } = useTranslation(["common"]); return ( {({ toast }) => (
{toast.content.variant === "success" ? ( ) : toast.content.variant === "error" ? ( ) : ( )} {t(`common:toasts.${toast.content.variant}`)} } className={styles.closeButton} slot="close" size="small" />
{toast.content.message}
)}
); }