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
59
60
61
62
63
64
65
66
import { useEffect, useState } from "react";
import { Debug, FlagCategory } from "@sc07-canvas/lib/src/debug";
import {
Button,
Modal,
ModalBody,
ModalContent,
ModalFooter,
ModalHeader,
Switch,
useDisclosure,
} from "@nextui-org/react";
export const DebugModal = () => {
const { isOpen, onOpen, onOpenChange } = useDisclosure();
useEffect(() => {
const handleOpen = () => {
onOpen();
};
Debug.on("openTools", handleOpen);
return () => {
Debug.off("openTools", handleOpen);
};
}, []);
return (
<Modal isOpen={isOpen} onOpenChange={onOpenChange} placement="center">
<ModalContent>
{(onClose) => (
<>
<ModalHeader className="flex flex-col gap-1">
Debug Tools
</ModalHeader>
<ModalBody>
<Button onPress={() => Debug.openDebug()}>
Open Debug Information
</Button>
{Debug.flags.getAll().map((flag, i, arr) => (
<>
{arr[i - 1]?.category !== flag.category && (
<p>{FlagCategory[flag.category]}</p>
)}
<div key={flag.id}>
<Switch
size="sm"
defaultSelected={flag.enabled}
onValueChange={(v) => Debug.flags.setEnabled(flag.id, v)}
>
{flag.id}
</Switch>
</div>
</>
))}
</ModalBody>
<ModalFooter>
<Button onPress={onClose}>Close</Button>
</ModalFooter>
</>
)}
</ModalContent>
</Modal>
);
};