Initial commit
This commit is contained in:
24
src_frontend_orig/components/Toast.jsx
Normal file
24
src_frontend_orig/components/Toast.jsx
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useEffect } from 'react';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
|
||||
export function Toast({ message, onClose }) {
|
||||
useEffect(() => {
|
||||
if (!message) return;
|
||||
const t = setTimeout(() => onClose && onClose(), 3000);
|
||||
return () => clearTimeout(t);
|
||||
}, [message, onClose]);
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{message && (
|
||||
<motion.div
|
||||
className="toast"
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: 20 }}
|
||||
>
|
||||
{message}
|
||||
</motion.div>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user