import clsx from "clsx"; import { useEffect } from "react"; import { Button } from "../button"; import { Dialog } from "../dialog"; import { Loader } from "../loader"; import { Message } from "../../types"; export type SnackProps = Partial & { onRemove?: () => void; }; export function Snack({ expiration = 5000, content = "", color = "yellow", withLoader = false, canClose = false, onRemove = () => {}, }: SnackProps) { useEffect(() => { if (expiration === -1) { return; } const timeoutId = setTimeout(() => onRemove(), expiration); return () => void clearTimeout(timeoutId); }, [onRemove, expiration]); return (
{content} {withLoader && } {canClose && ( )}
); }