Modal.jsx
2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import { AlertTriangle, X } from 'lucide-react';
export default function Modal({ isOpen, title, content, confirmText = '确定', cancelText = '取消', isDanger = false, onConfirm, onCancel }) {
if (!isOpen) return null;
return (
<div className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm animate-in fade-in duration-200">
<div className="relative w-full max-w-md p-6 bg-zinc-900 border border-zinc-800 rounded-2xl shadow-2xl text-zinc-100 animate-in zoom-in-95 duration-200">
<div className="flex items-start gap-4">
<div className={`p-3 rounded-xl shrink-0 ${isDanger ? 'bg-rose-500/10 text-rose-400' : 'bg-indigo-500/10 text-indigo-400'}`}>
<AlertTriangle className="w-6 h-6" />
</div>
<div className="flex-1">
<h3 className="text-base font-semibold text-zinc-100">{title}</h3>
<div className="mt-2 text-sm text-zinc-400 leading-relaxed whitespace-pre-wrap">{content}</div>
</div>
<button
onClick={onCancel}
className="text-zinc-500 hover:text-zinc-300 p-1 rounded-lg hover:bg-zinc-800 transition-colors"
>
<X className="w-5 h-5" />
</button>
</div>
<div className="flex justify-end gap-3 mt-6">
<button
onClick={onCancel}
className="px-4 py-2 text-sm font-medium text-zinc-300 bg-zinc-800 hover:bg-zinc-700/80 rounded-xl transition-colors cursor-pointer"
>
{cancelText}
</button>
<button
onClick={onConfirm}
className={`px-4 py-2 text-sm font-medium text-white rounded-xl transition-all cursor-pointer shadow-lg ${
isDanger
? 'bg-rose-600 hover:bg-rose-500 shadow-rose-950/50'
: 'bg-emerald-600 hover:bg-emerald-500 shadow-emerald-950/50'
}`}
>
{confirmText}
</button>
</div>
</div>
</div>
);
}