import { useStore } from '@nanostores/preact'; import { $toastMessage } from '../stores/toast'; import { useEffect } from 'preact/hooks'; import { CheckIcon } from './ReactIcons/CheckIcon'; import { ErrorIcon } from './ReactIcons/ErrorIcon'; import { WarningIcon } from './ReactIcons/WarningIcon'; import { InfoIcon } from './ReactIcons/InfoIcon'; import { Spinner } from './ReactIcons/Spinner'; export interface Props {} export function Toaster(props: Props) { const toastMessage = useStore($toastMessage); useEffect(() => { if (toastMessage === undefined) { return; } const removeMessage = setTimeout(() => { if (toastMessage?.type !== 'loading') { $toastMessage.set(undefined); } }, 2500); return () => { clearTimeout(removeMessage); }; }, [toastMessage]); if (!toastMessage) { return null; } return (