11import clsx from 'clsx'
22import { For } from 'solid-js'
33import { useStyles } from '../styles/use-styles'
4- import { useDetachedWindowControls , useDevtoolsState } from '../context/use-devtools-context'
4+ import {
5+ useDetachedWindowControls ,
6+ useDevtoolsState ,
7+ } from '../context/use-devtools-context'
58import { tabs } from '../tabs'
6- import { TANSTACK_DEVTOOLS_DETACHED_OWNER , TANSTACK_DEVTOOLS_IS_DETACHED , setSessionItem , setStorageItem , } from '../utils/storage'
9+ import {
10+ TANSTACK_DEVTOOLS_DETACHED_OWNER ,
11+ TANSTACK_DEVTOOLS_IS_DETACHED ,
12+ setSessionItem ,
13+ setStorageItem ,
14+ } from '../utils/storage'
715
816interface TabsProps {
917 toggleOpen : ( ) => void
@@ -12,18 +20,19 @@ interface TabsProps {
1220export const Tabs = ( props : TabsProps ) => {
1321 const styles = useStyles ( )
1422 const { state, setState } = useDevtoolsState ( )
15- const { setDetachedWindowOwner, detachedWindowOwner, detachedWindow } = useDetachedWindowControls ( )
23+ const { setDetachedWindowOwner, detachedWindowOwner, detachedWindow } =
24+ useDetachedWindowControls ( )
1625 const handleDetachment = ( ) => {
1726 const rdtWindow = window . open (
1827 window . location . href ,
19- "" ,
20- `popup,width=${ window . innerWidth } ,height=${ state ( ) . height } ,top=${ window . screen . height } ,left=${ window . screenLeft } }`
28+ '' ,
29+ `popup,width=${ window . innerWidth } ,height=${ state ( ) . height } ,top=${ window . screen . height } ,left=${ window . screenLeft } }` ,
2130 )
2231
2332 if ( rdtWindow ) {
2433 setDetachedWindowOwner ( true )
25- setStorageItem ( TANSTACK_DEVTOOLS_IS_DETACHED , " true" )
26- setSessionItem ( TANSTACK_DEVTOOLS_DETACHED_OWNER , " true" )
34+ setStorageItem ( TANSTACK_DEVTOOLS_IS_DETACHED , ' true' )
35+ setSessionItem ( TANSTACK_DEVTOOLS_DETACHED_OWNER , ' true' )
2736 rdtWindow . TDT_MOUNTED = true
2837 }
2938 }
@@ -40,37 +49,60 @@ export const Tabs = (props: TabsProps) => {
4049 </ button >
4150 ) }
4251 </ For >
43- { ! detachedWindow && < div style = { {
44- "margin-top" : "auto"
45- } } >
46- { ! detachedWindowOwner ( ) && < button
47- type = "button"
48- class = { clsx ( styles ( ) . tab , 'detach' ) }
49- onClick = { handleDetachment }
52+ { ! detachedWindow && (
53+ < div
54+ style = { {
55+ 'margin-top' : 'auto' ,
56+ } }
5057 >
51- < svg xmlns = "http://www.w3.org/2000/svg" width = "24" height = "24" viewBox = "0 0 24 24" fill = "none" stroke = "currentColor" stroke-width = "2" stroke-linecap = "round" stroke-linejoin = "round" class = "lucide lucide-picture-in-picture-icon lucide-picture-in-picture" > < path d = "M2 10h6V4" /> < path d = "m2 4 6 6" /> < path d = "M21 10V7a2 2 0 0 0-2-2h-7" /> < path d = "M3 14v2a2 2 0 0 0 2 2h3" /> < rect x = "12" y = "14" width = "10" height = "7" rx = "1" /> </ svg >
52- </ button > }
53- < button
54- type = "button"
55- class = { clsx ( styles ( ) . tab , 'close' ) }
56- onClick = { ( ) => props . toggleOpen ( ) }
57- >
58- < svg
59- xmlns = "http://www.w3.org/2000/svg"
60- width = "24"
61- height = "24"
62- viewBox = "0 0 24 24"
63- fill = "none"
64- stroke = "currentColor"
65- stroke-width = "2"
66- stroke-linecap = "round"
67- stroke-linejoin = "round"
58+ { ! detachedWindowOwner ( ) && (
59+ < button
60+ type = "button"
61+ class = { clsx ( styles ( ) . tab , 'detach' ) }
62+ onClick = { handleDetachment }
63+ >
64+ < svg
65+ xmlns = "http://www.w3.org/2000/svg"
66+ width = "24"
67+ height = "24"
68+ viewBox = "0 0 24 24"
69+ fill = "none"
70+ stroke = "currentColor"
71+ stroke-width = "2"
72+ stroke-linecap = "round"
73+ stroke-linejoin = "round"
74+ class = "lucide lucide-picture-in-picture-icon lucide-picture-in-picture"
75+ >
76+ < path d = "M2 10h6V4" />
77+ < path d = "m2 4 6 6" />
78+ < path d = "M21 10V7a2 2 0 0 0-2-2h-7" />
79+ < path d = "M3 14v2a2 2 0 0 0 2 2h3" />
80+ < rect x = "12" y = "14" width = "10" height = "7" rx = "1" />
81+ </ svg >
82+ </ button >
83+ ) }
84+ < button
85+ type = "button"
86+ class = { clsx ( styles ( ) . tab , 'close' ) }
87+ onClick = { ( ) => props . toggleOpen ( ) }
6888 >
69- < path d = "M18 6 6 18" />
70- < path d = "m6 6 12 12" />
71- </ svg >
72- </ button >
73- </ div > }
89+ < svg
90+ xmlns = "http://www.w3.org/2000/svg"
91+ width = "24"
92+ height = "24"
93+ viewBox = "0 0 24 24"
94+ fill = "none"
95+ stroke = "currentColor"
96+ stroke-width = "2"
97+ stroke-linecap = "round"
98+ stroke-linejoin = "round"
99+ >
100+ < path d = "M18 6 6 18" />
101+ < path d = "m6 6 12 12" />
102+ </ svg >
103+ </ button >
104+ </ div >
105+ ) }
74106 </ div >
75107 )
76108}
0 commit comments