blob: 8104f8cff99fe6244160d7b762e47d074e233ec2 (
plain)
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 useFlowStore from '../store/flowStore';
interface ContextMenuProps {
x: number;
y: number;
items: { label: string; onClick: () => void; danger?: boolean }[];
onClose: () => void;
}
export const ContextMenu: React.FC<ContextMenuProps> = ({ x, y, items, onClose }) => {
const { theme } = useFlowStore();
const isDark = theme === 'dark';
return (
<div
className={`fixed z-50 shadow-lg rounded-md py-1 min-w-[150px] ${
isDark
? 'bg-gray-800 border border-gray-600'
: 'bg-white border border-gray-200'
}`}
style={{ top: y, left: x }}
onClick={(e) => e.stopPropagation()}
>
{items.map((item, idx) => (
<button
key={idx}
className={`w-full text-left px-4 py-2 text-sm transition-colors ${
item.danger
? isDark
? 'text-red-400 hover:bg-red-900/50'
: 'text-red-600 hover:bg-red-50'
: isDark
? 'text-gray-200 hover:bg-gray-700'
: 'text-gray-700 hover:bg-gray-100'
}`}
onClick={() => {
item.onClick();
onClose();
}}
>
{item.label}
</button>
))}
</div>
);
};
|