@@ -26,13 +26,7 @@ import {
26
26
XIcon ,
27
27
} from "lucide-react" ;
28
28
import { AnimatePresence , motion } from "motion/react" ;
29
- import {
30
- type FC ,
31
- useCallback ,
32
- useEffect ,
33
- useMemo ,
34
- useState ,
35
- } from "react" ;
29
+ import { type FC , useCallback , useEffect , useMemo , useState } from "react" ;
36
30
import { useSearchParams } from "react-router" ;
37
31
import ReactJsonView from "@microlink/react-json-view" ;
38
32
@@ -48,6 +42,8 @@ export const Preview: FC = () => {
48
42
const [ params ] = useSearchParams ( ) ;
49
43
const isDebug = useMemo ( ( ) => params . has ( "debug" ) , [ params ] ) ;
50
44
45
+ const [ tab , setTab ] = useState ( ( ) => "preview" ) ;
46
+
51
47
const onDownloadOutput = useCallback ( ( ) => {
52
48
const blob = new Blob ( [ JSON . stringify ( output , null , 2 ) ] , {
53
49
type : "application/json" ,
@@ -115,7 +111,12 @@ export const Preview: FC = () => {
115
111
} , [ debouncedCode , $setError ] ) ;
116
112
117
113
return (
118
- < Tabs . Root defaultValue = "preview" asChild = { true } >
114
+ < Tabs . Root
115
+ defaultValue = "preview"
116
+ asChild = { true }
117
+ value = { tab }
118
+ onValueChange = { ( tab ) => setTab ( ( ) => tab ) }
119
+ >
119
120
< ResizablePanel className = "relative flex flex-col" >
120
121
{ $wasmState !== "loaded" ? (
121
122
< div className = "absolute top-0 left-0 z-10 flex h-full w-full items-center justify-center backdrop-blur-sm" >
@@ -131,7 +132,20 @@ export const Preview: FC = () => {
131
132
>
132
133
< div className = "flex" >
133
134
< Tabs . Trigger value = "preview" icon = { PlayIcon } label = "Preview" />
134
- < Tabs . Trigger value = "debug" icon = { BugIcon } label = "Debugger" />
135
+ < Tabs . Trigger
136
+ value = "debug"
137
+ icon = {
138
+ isDebouncing && tab === "debug"
139
+ ? ( { className, ...rest } ) => (
140
+ < LoaderIcon
141
+ { ...rest }
142
+ className = { cn ( "animate-spin" , className ) }
143
+ />
144
+ )
145
+ : BugIcon
146
+ }
147
+ label = "Debugger"
148
+ /> { " " }
135
149
</ div >
136
150
< Button
137
151
size = "sm"
@@ -171,7 +185,11 @@ export const Preview: FC = () => {
171
185
animate = { { opacity : 1 , scale : 1 } }
172
186
exit = { { opacity : 0 , scale : 0.75 } }
173
187
>
174
- < LoaderIcon className = "animate-spin text-content-primary" />
188
+ < LoaderIcon
189
+ width = { 16 }
190
+ height = { 16 }
191
+ className = "animate-spin text-content-primary"
192
+ />
175
193
</ motion . div >
176
194
) : null }
177
195
</ AnimatePresence >
@@ -367,8 +385,10 @@ const Debugger: FC<DebuggerProps> = ({ output }) => {
367
385
direction = "vertical"
368
386
className = "h-full w-full bg-surface-primary"
369
387
>
370
- < ResizablePanel >
371
- < ReactJsonView src = { output ?? { } } />
388
+ < ResizablePanel className = "flex" >
389
+ < div className = "h-full w-full overflow-scroll p-4" >
390
+ < ReactJsonView src = { output ?? { } } collapsed = { 1 } />
391
+ </ div >
372
392
</ ResizablePanel >
373
393
< ResizableHandle className = "bg-surface-quaternary" />
374
394
< ResizablePanel
@@ -378,13 +398,15 @@ const Debugger: FC<DebuggerProps> = ({ output }) => {
378
398
) }
379
399
defaultSize = { 30 }
380
400
>
381
- < div className = "mb-4 overflow-y-scroll" >
382
- { parserLogs . length === 0 ? (
383
- < LogsEmptyState />
384
- ) : (
385
- parserLogs . map ( ( log , index ) => < Log log = { log } key = { index } /> )
386
- ) }
387
- </ div >
401
+ { parserLogs . length === 0 ? (
402
+ < LogsEmptyState />
403
+ ) : (
404
+ < div className = "mb-4 overflow-y-scroll" >
405
+ { parserLogs . map ( ( log , index ) => (
406
+ < Log log = { log } key = { index } />
407
+ ) ) }
408
+ </ div >
409
+ ) }
388
410
</ ResizablePanel >
389
411
</ ResizablePanelGroup >
390
412
) ;
0 commit comments