import * as ToastPrimitive from "@radix-ui/react-toast"; import { clsx } from "clsx"; import CloseIcon from "./Icons/Close"; import CloseCircleIcon from "./Icons/CloseCircle"; import InfoIcon from "./Icons/Info"; import SuccessIcon from "./Icons/Success"; import WarningIcon from "./Icons/Warning"; const Toast = ({ toast, open, setOpen, }: { toast: { id: string; title: string; description?: string; status: "success" | "error" | "info" | "warning"; preventClose?: boolean; }; open: boolean; setOpen: (open: boolean) => void; }) => { return ( { if (!toast.preventClose) { setOpen(open); } }} className={clsx( "z-50 fixed bottom-4 md:left-1/2 md:-translate-x-[50%] inset-x-4 w-auto shadow-lg md:max-w-[658px] duration-300", "radix-state-open:animate-fade-in", "radix-state-closed:animate-toast-hide", "radix-swipe-end:animate-toast-swipe-out", "translate-x-radix-toast-swipe-move-x", "radix-swipe-cancel:translate-x-0 radix-swipe-cancel:duration-200 radix-swipe-cancel:ease-[ease]", "px-[40px] md:px-[58px] py-6 flex flex-col border rounded-[4px]", { "bg-green-100 text-green-600 border-green-600": toast.status === "success", "bg-red-200 text-red-600 border-red-600": toast.status === "error", "bg-blue-100 text-blue-700 border-blue-600": toast.status === "info", "bg-orange-200 text-orange-600 border-orange-600": toast.status === "warning", }, { "h-[72px]": !toast.description, } /*"focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75"*/ )} > {toast.status === "success" ? ( ) : toast.status === "warning" ? ( ) : toast.status === "error" ? ( ) : ( )} {toast.title} {toast.description && ( {toast.description} )} {/*action && ( { e.preventDefault(); action(); }} > {actionLabel} )*/} ); }; export default Toast;