MessageModal.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. 'use client';
  2. import { AlertCircle } from 'lucide-react';
  3. import { useLanguage } from '@/lib/i18n/LanguageContext';
  4. interface MessageModalProps {
  5. isOpen: boolean;
  6. title?: string;
  7. message: string;
  8. onClose: () => void;
  9. type?: 'info' | 'error' | 'success';
  10. }
  11. export default function MessageModal({ isOpen, onClose, message, title, type = 'error' }: MessageModalProps) {
  12. const { t } = useLanguage();
  13. if (!isOpen) return null;
  14. return (
  15. <div className="fixed inset-0 z-[60] flex items-center justify-center bg-black/60 backdrop-grayscale p-4 animate-in fade-in duration-200">
  16. <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-sm flex flex-col font-mono overflow-hidden">
  17. {/* Header */}
  18. <div className="px-4 py-3 border-b-2 border-black flex justify-between items-center bg-neutral-200 text-black">
  19. <div className="font-bold text-xs flex items-center gap-2 uppercase tracking-wider">
  20. <span className={`w-2.5 h-2.5 inline-block border border-black ${type === 'error' ? 'bg-rose-500' : 'bg-amber-300'}`} />
  21. <span>[ {title || t('common.notice') || 'NOTICE'} ]</span>
  22. </div>
  23. <button aria-label={t('common.close')}
  24. onClick={onClose}
  25. className="w-6 h-6 bg-white hover:bg-amber-300 border border-black flex items-center justify-center font-bold text-xs transition"
  26. >
  27. ✕
  28. </button>
  29. </div>
  30. {/* Body */}
  31. <div className="p-6 bg-white">
  32. <p className="text-xs sm:text-sm text-neutral-800 leading-relaxed text-center font-sans">
  33. {message}
  34. </p>
  35. </div>
  36. {/* Footer */}
  37. <div className="px-4 py-3 border-t-2 border-black bg-neutral-100 flex justify-center font-mono">
  38. <button
  39. onClick={onClose}
  40. className="w-full bg-amber-300 hover:bg-amber-400 text-black py-2.5 border-2 border-black font-black text-xs transition shadow-[2px_2px_0px_#000] active:translate-x-0.5 active:translate-y-0.5 active:shadow-none uppercase"
  41. >
  42. [ {t('common.confirm_known') || '知道了 // OK'} ]
  43. </button>
  44. </div>
  45. </div>
  46. </div>
  47. );
  48. }