|
1 |
| -import { useState } from 'react'; |
2 | 1 | import { useSettings } from '@/hooks/useSetting';
|
3 | 2 | import { cn } from '@/lib/utils';
|
4 | 3 | import { Button } from './button';
|
| 4 | +import { Dialog, DialogContent, DialogTrigger } from './dialog'; |
5 | 5 |
|
6 | 6 | export const Debug = ({ value, isOpen = false, className }: { value: unknown; isOpen?: boolean; className?: string }) => {
|
7 | 7 | const { experiments } = useSettings();
|
8 |
| - const [open, setOpen] = useState(isOpen); |
9 |
| - const onClick = () => { |
10 |
| - setOpen((prev) => !prev); |
11 |
| - }; |
12 | 8 |
|
13 | 9 | if (!experiments.devMode) return null;
|
14 | 10 |
|
15 | 11 | return (
|
16 |
| - <div className="flex flex-col gap-2"> |
17 |
| - <div className="w-full flex flex-row justify-end"> |
18 |
| - <Button onClick={onClick} className="h-5" variant="ghost"> |
19 |
| - 👀 |
20 |
| - </Button> |
21 |
| - </div> |
22 |
| - <div> |
23 |
| - {open && ( |
24 |
| - <pre |
25 |
| - className={cn( |
26 |
| - 'border border-gray-200 dark:border-neutral-800 ', |
27 |
| - 'text-sm text-gray-500 dark:text-gray-400 p-2 rounded-lg overflow-auto h-64 text-left', |
28 |
| - className, |
29 |
| - )} |
30 |
| - > |
31 |
| - {JSON.stringify(value, null, 2)} |
32 |
| - </pre> |
33 |
| - )} |
34 |
| - </div> |
35 |
| - </div> |
| 12 | + <Dialog defaultOpen={isOpen}> |
| 13 | + <DialogTrigger asChild> |
| 14 | + <div className="w-full relative h-5"> |
| 15 | + <Button variant="ghost" className="absolute top-0 right-0"> |
| 16 | + 👀 |
| 17 | + </Button> |
| 18 | + </div> |
| 19 | + </DialogTrigger> |
| 20 | + <DialogContent className="p-0 size-[75%] min-size-[500px]"> |
| 21 | + <pre |
| 22 | + className={cn( |
| 23 | + 'border border-gray-200 dark:border-neutral-800 text-xs text-gray-500 dark:text-gray-400 p-2 rounded-lg overflow-auto text-left', |
| 24 | + className, |
| 25 | + )} |
| 26 | + > |
| 27 | + {JSON.stringify(value, null, 2)} |
| 28 | + </pre> |
| 29 | + </DialogContent> |
| 30 | + </Dialog> |
36 | 31 | );
|
37 | 32 | };
|
0 commit comments