ConfirmModal.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 'use client';
  2. import { X } from 'lucide-react';
  3. interface ConfirmModalProps {
  4. isOpen: boolean;
  5. title: string;
  6. message: string;
  7. onConfirm: () => void;
  8. onCancel: () => void;
  9. }
  10. export default function ConfirmModal({ isOpen, onCancel, onConfirm, message, title }: ConfirmModalProps) {
  11. if (!isOpen) return null;
  12. return (
  13. <div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-grayscale p-4">
  14. <div className="bg-neutral-50 border-2 border-black shadow-[8px_8px_0px_#000] w-full max-w-md flex flex-col font-mono animate-in zoom-in-95 duration-200">
  15. {/* Header */}
  16. <div className="px-5 py-3 border-b-2 border-black flex justify-between items-center bg-neutral-200 text-black">
  17. <div className="flex items-center gap-2 text-xs font-bold uppercase tracking-wider">
  18. <span className="w-2.5 h-2.5 bg-amber-300 border border-black inline-block" />
  19. <span>[ {title} ]</span>
  20. </div>
  21. <button
  22. onClick={onCancel}
  23. className="w-6 h-6 bg-white hover:bg-amber-300 border border-black flex items-center justify-center font-bold text-xs transition"
  24. >
  25. ✕
  26. </button>
  27. </div>
  28. {/* Body */}
  29. <div className="p-6 bg-white">
  30. <p className="text-xs sm:text-sm text-neutral-800 leading-relaxed font-sans text-center">
  31. {message}
  32. </p>
  33. </div>
  34. {/* Footer Buttons */}
  35. <div className="px-5 py-4 border-t-2 border-black bg-neutral-100 flex justify-end gap-3 font-mono">
  36. <button
  37. onClick={onCancel}
  38. className="px-4 py-2 border-2 border-black bg-white text-black font-bold text-xs shadow-[2px_2px_0px_#000] hover:bg-neutral-50 transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
  39. >
  40. [ 取消 ]
  41. </button>
  42. <button
  43. onClick={() => {
  44. onConfirm();
  45. onCancel();
  46. }}
  47. className="px-6 py-2 bg-amber-300 hover:bg-amber-400 text-black border-2 border-black font-black text-xs shadow-[2px_2px_0px_#000] transition active:translate-x-0.5 active:translate-y-0.5 active:shadow-none"
  48. >
  49. [ 确认提交 → ]
  50. </button>
  51. </div>
  52. </div>
  53. </div>
  54. );
  55. }