Newer
Older
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
import {
Button,
Kbd,
KbdKey,
Modal,
ModalBody,
ModalContent,
ModalFooter,
ModalHeader,
} from "@nextui-org/react";
import { useAppContext } from "../contexts/AppContext";
import { KeybindManager } from "../lib/keybinds";
export const KeybindModal = () => {
const { showKeybinds, setShowKeybinds } = useAppContext();
return (
<Modal
isOpen={showKeybinds}
onOpenChange={setShowKeybinds}
placement="center"
>
<ModalContent>
{(onClose) => (
<>
<ModalHeader className="flex flex-col gap-1">Keybinds</ModalHeader>
<ModalBody>
{Object.entries(KeybindManager.getKeybinds()).map(
([name, kbs]) => (
<div className="flex flex-row gap-2">
<span>{name}</span>
{kbs.map((kb) => (
<Kbd
keys={(
[
kb.alt && "option",
kb.ctrl && "ctrl",
kb.meta && "command",
kb.shift && "shift",
] as KbdKey[]
).filter((a) => a)}
>
{kb.key}
</Kbd>
))}
</div>
)
)}
</ModalBody>
<ModalFooter>
<Button onPress={onClose}>Close</Button>
</ModalFooter>
</>
)}
</ModalContent>
</Modal>
);
};