@@ -26,13 +26,7 @@ import {
2626 XIcon ,
2727} from "lucide-react" ;
2828import { 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" ;
3630import { useSearchParams } from "react-router" ;
3731import ReactJsonView from "@microlink/react-json-view" ;
3832
@@ -48,6 +42,8 @@ export const Preview: FC = () => {
4842 const [ params ] = useSearchParams ( ) ;
4943 const isDebug = useMemo ( ( ) => params . has ( "debug" ) , [ params ] ) ;
5044
45+ const [ tab , setTab ] = useState ( ( ) => "preview" ) ;
46+
5147 const onDownloadOutput = useCallback ( ( ) => {
5248 const blob = new Blob ( [ JSON . stringify ( output , null , 2 ) ] , {
5349 type : "application/json" ,
@@ -115,7 +111,12 @@ export const Preview: FC = () => {
115111 } , [ debouncedCode , $setError ] ) ;
116112
117113 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+ >
119120 < ResizablePanel className = "relative flex flex-col" >
120121 { $wasmState !== "loaded" ? (
121122 < 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 = () => {
131132 >
132133 < div className = "flex" >
133134 < 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+ /> { " " }
135149 </ div >
136150 < Button
137151 size = "sm"
@@ -171,7 +185,11 @@ export const Preview: FC = () => {
171185 animate = { { opacity : 1 , scale : 1 } }
172186 exit = { { opacity : 0 , scale : 0.75 } }
173187 >
174- < LoaderIcon className = "animate-spin text-content-primary" />
188+ < LoaderIcon
189+ width = { 16 }
190+ height = { 16 }
191+ className = "animate-spin text-content-primary"
192+ />
175193 </ motion . div >
176194 ) : null }
177195 </ AnimatePresence >
@@ -367,8 +385,10 @@ const Debugger: FC<DebuggerProps> = ({ output }) => {
367385 direction = "vertical"
368386 className = "h-full w-full bg-surface-primary"
369387 >
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 >
372392 </ ResizablePanel >
373393 < ResizableHandle className = "bg-surface-quaternary" />
374394 < ResizablePanel
@@ -378,13 +398,15 @@ const Debugger: FC<DebuggerProps> = ({ output }) => {
378398 ) }
379399 defaultSize = { 30 }
380400 >
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+ ) }
388410 </ ResizablePanel >
389411 </ ResizablePanelGroup >
390412 ) ;
0 commit comments