diff --git a/src/components/Toast.tsx b/src/components/Toast.tsx index eff3b7e..2069aff 100644 --- a/src/components/Toast.tsx +++ b/src/components/Toast.tsx @@ -5,6 +5,7 @@ interface Toast { id: string; message: string; type?: 'success' | 'error' | 'info'; + isExiting?: boolean; } let addToast: (toast: Toast) => void; @@ -18,7 +19,13 @@ const ToastContainer: React.FC = () => { // حذف خودکار بعد از ۳ ثانیه setTimeout(() => { - setToasts((prev) => prev.filter((t) => t.id !== toast.id)); + setToasts((prev) => prev.map(t => + t.id === toast.id ? { ...t, isExiting: true } : t + )); + + setTimeout(() => { + setToasts((prev) => prev.filter((t) => t.id !== toast.id)); + }, 300); }, 3000); }; @@ -28,15 +35,16 @@ const ToastContainer: React.FC = () => { }, []); return ( -