import React, { useEffect, useState } from 'react'; import { NotificationData } from '../../types'; import { XMarkIcon, CheckCircleIcon, ExclamationCircleIcon, ExclamationTriangleIcon, InformationCircleIcon } from '@heroicons/react/24/outline'; interface NotificationProps { notification: NotificationData; onClose: () => void; } const Notification: React.FC = ({ notification, onClose }) => { const [isVisible, setIsVisible] = useState(false); useEffect(() => { // 动画显示 const timer = setTimeout(() => setIsVisible(true), 50); return () => clearTimeout(timer); }, []); const handleClose = () => { setIsVisible(false); setTimeout(onClose, 300); // 等待动画结束 }; const getIcon = () => { switch (notification.type) { case 'success': return ; case 'error': return ; case 'warning': return ; default: return ; } }; const getColorClasses = () => { switch (notification.type) { case 'success': return 'border-success-green/50 bg-success-green/20'; case 'error': return 'border-danger-red/50 bg-danger-red/20'; case 'warning': return 'border-warning-yellow/50 bg-warning-yellow/20'; default: return 'border-accent-blue/50 bg-accent-blue/20'; } }; return (
{getIcon()}

{notification.title}

{notification.message}

); }; export default Notification;