-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Expand file tree
/
Copy pathAssetContextMenu.tsx
More file actions
97 lines (96 loc) · 2.42 KB
/
Copy pathAssetContextMenu.tsx
File metadata and controls
97 lines (96 loc) · 2.42 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
export function ContextMenu({
x,
y,
asset,
onClose,
onCopy,
onDelete,
onRename,
}: {
x: number;
y: number;
asset: string;
onClose: () => void;
onCopy: (path: string) => void;
onDelete?: (path: string) => void;
onRename?: (oldPath: string, newPath: string) => void;
}) {
return (
<div
className="fixed inset-0 z-[200]"
onClick={onClose}
onContextMenu={(e) => {
e.preventDefault();
onClose();
}}
>
<div
className="absolute bg-neutral-900 border border-neutral-700 rounded-lg shadow-xl py-1 min-w-[140px] text-xs"
style={{ left: x, top: y }}
>
<button
onClick={(e) => {
e.stopPropagation();
onCopy(asset);
onClose();
}}
className="w-full text-left px-3 py-1.5 text-neutral-300 hover:bg-neutral-800 transition-colors"
>
Copy path
</button>
{onRename && (
<button
onClick={(e) => {
e.stopPropagation();
onClose();
}}
className="w-full text-left px-3 py-1.5 text-neutral-300 hover:bg-neutral-800 transition-colors"
>
Rename
</button>
)}
{onDelete && (
<button
onClick={(e) => {
e.stopPropagation();
onDelete(asset);
onClose();
}}
className="w-full text-left px-3 py-1.5 text-red-400 hover:bg-neutral-800 transition-colors"
>
Delete
</button>
)}
</div>
</div>
);
}
export function DeleteConfirm({
name,
onConfirm,
onCancel,
}: {
name: string;
onConfirm: () => void;
onCancel: () => void;
}) {
return (
<div className="px-2 py-1.5 bg-red-950/30 border-l-2 border-red-500 flex items-center justify-between gap-2">
<span className="text-[10px] text-red-400 truncate">Delete {name}?</span>
<div className="flex items-center gap-1 flex-shrink-0">
<button
onClick={onConfirm}
className="px-2 py-0.5 text-[10px] rounded bg-red-600 text-white hover:bg-red-500 transition-colors"
>
Delete
</button>
<button
onClick={onCancel}
className="px-2 py-0.5 text-[10px] rounded text-neutral-400 hover:text-neutral-200 transition-colors"
>
Cancel
</button>
</div>
</div>
);
}