Skip to content

Commit ea53d3b

Browse files
committed
feat: better debug
1 parent 336dc91 commit ea53d3b

File tree

1 file changed

+20
-25
lines changed

1 file changed

+20
-25
lines changed

src/components/ui/Debug.tsx

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
1-
import { useState } from 'react';
21
import { useSettings } from '@/hooks/useSetting';
32
import { cn } from '@/lib/utils';
43
import { Button } from './button';
4+
import { Dialog, DialogContent, DialogTrigger } from './dialog';
55

66
export const Debug = ({ value, isOpen = false, className }: { value: unknown; isOpen?: boolean; className?: string }) => {
77
const { experiments } = useSettings();
8-
const [open, setOpen] = useState(isOpen);
9-
const onClick = () => {
10-
setOpen((prev) => !prev);
11-
};
128

139
if (!experiments.devMode) return null;
1410

1511
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>
3631
);
3732
};

0 commit comments

Comments
 (0)