@@ -161,8 +161,9 @@ export const Devtools: Component<DevtoolsPanelProps> = (props) => {
161161 )
162162 } )
163163
164+ let transitionsContainerRef ! : HTMLDivElement
164165 createEffect ( ( ) => {
165- const root = document . querySelector ( '.tsqd-parent-container' ) as HTMLElement
166+ const root = transitionsContainerRef . parentElement as HTMLElement
166167 const height = props . localStore . height || DEFAULT_HEIGHT
167168 const width = props . localStore . width || DEFAULT_WIDTH
168169 const panelPosition = position ( )
@@ -176,6 +177,23 @@ export const Devtools: Component<DevtoolsPanelProps> = (props) => {
176177 )
177178 } )
178179
180+ // Calculates the inherited font size of the parent and sets it as a CSS variable
181+ // All the design tokens are calculated based on this variable
182+ onMount ( ( ) => {
183+ // This is to make sure that the font size is updated when the stylesheet is updated
184+ // and the user focuses back on the window
185+ const onFocus = ( ) => {
186+ const root = transitionsContainerRef . parentElement as HTMLElement
187+ const fontSize = getComputedStyle ( root ) . fontSize
188+ root . style . setProperty ( '--tsqd-font-size' , fontSize )
189+ }
190+ onFocus ( )
191+ window . addEventListener ( 'focus' , onFocus )
192+ onCleanup ( ( ) => {
193+ window . removeEventListener ( 'focus' , onFocus )
194+ } )
195+ } )
196+
179197 return (
180198 < div
181199 // styles for animating the panel in and out
@@ -209,6 +227,7 @@ export const Devtools: Component<DevtoolsPanelProps> = (props) => {
209227 ` ,
210228 'tsqd-transitions-container' ,
211229 ) }
230+ ref = { transitionsContainerRef }
212231 >
213232 < TransitionGroup name = "tsqd-panel-transition" >
214233 < Show when = { isOpen ( ) } >
@@ -444,6 +463,7 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
444463 setupQueryCacheSubscription ( )
445464 setupMutationCacheSubscription ( )
446465
466+ let containerRef ! : HTMLDivElement
447467 const theme = useTheme ( )
448468 const styles = createMemo ( ( ) => {
449469 return theme ( ) === 'dark' ? darkStyles : lightStyles
@@ -553,6 +573,13 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
553573 props . setLocalStore ( 'position' , pos )
554574 }
555575
576+ // Sets the Font Size variable on portal menu elements since they will be outside
577+ // the main panel container
578+ const setComputedVariables = ( el : HTMLDivElement ) => {
579+ const computedStyle = getComputedStyle ( containerRef )
580+ const variable = computedStyle . getPropertyValue ( '--tsqd-font-size' )
581+ el . style . setProperty ( '--tsqd-font-size' , variable )
582+ }
556583 return (
557584 < >
558585 < div
@@ -568,6 +595,7 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
568595 ` ,
569596 'tsqd-queries-container' ,
570597 ) }
598+ ref = { containerRef }
571599 >
572600 < div class = { cx ( styles ( ) . row , 'tsqd-header' ) } >
573601 < div class = { styles ( ) . logoAndToggleContainer } >
@@ -796,7 +824,9 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
796824 >
797825 < Settings />
798826 </ DropdownMenu . Trigger >
799- < DropdownMenu . Portal >
827+ < DropdownMenu . Portal
828+ ref = { ( el ) => setComputedVariables ( el as HTMLDivElement ) }
829+ >
800830 < DropdownMenu . Content
801831 class = { cx ( styles ( ) . settingsMenu , 'tsqd-settings-menu' ) }
802832 >
@@ -819,7 +849,9 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
819849 < span > Position</ span >
820850 < ChevronDown />
821851 </ DropdownMenu . SubTrigger >
822- < DropdownMenu . Portal >
852+ < DropdownMenu . Portal
853+ ref = { ( el ) => setComputedVariables ( el as HTMLDivElement ) }
854+ >
823855 < DropdownMenu . SubContent
824856 class = { cx (
825857 styles ( ) . settingsMenu ,
@@ -896,7 +928,9 @@ const ContentView: Component<DevtoolsPanelProps> = (props) => {
896928 < span > Theme</ span >
897929 < ChevronDown />
898930 </ DropdownMenu . SubTrigger >
899- < DropdownMenu . Portal >
931+ < DropdownMenu . Portal
932+ ref = { ( el ) => setComputedVariables ( el as HTMLDivElement ) }
933+ >
900934 < DropdownMenu . SubContent
901935 class = { cx (
902936 styles ( ) . settingsMenu ,
@@ -1800,7 +1834,7 @@ const QueryDetails = () => {
18001834 </ div >
18011835 < div
18021836 style = { {
1803- padding : '0.5rem' ,
1837+ padding : tokens . size [ 2 ] ,
18041838 } }
18051839 class = "tsqd-query-details-explorer-container tsqd-query-details-data-explorer"
18061840 >
@@ -1817,7 +1851,7 @@ const QueryDetails = () => {
18171851 </ div >
18181852 < div
18191853 style = { {
1820- padding : '0.5rem' ,
1854+ padding : tokens . size [ 2 ] ,
18211855 } }
18221856 class = "tsqd-query-details-explorer-container tsqd-query-details-query-explorer"
18231857 >
@@ -1935,7 +1969,7 @@ const MutationDetails = () => {
19351969 </ div >
19361970 < div
19371971 style = { {
1938- padding : '0.5rem' ,
1972+ padding : tokens . size [ 2 ] ,
19391973 } }
19401974 class = "tsqd-query-details-explorer-container tsqd-query-details-query-explorer"
19411975 >
@@ -1950,7 +1984,7 @@ const MutationDetails = () => {
19501984 </ div >
19511985 < div
19521986 style = { {
1953- padding : '0.5rem' ,
1987+ padding : tokens . size [ 2 ] ,
19541988 } }
19551989 class = "tsqd-query-details-explorer-container tsqd-query-details-query-explorer"
19561990 >
@@ -1965,7 +1999,7 @@ const MutationDetails = () => {
19651999 </ div >
19662000 < div
19672001 style = { {
1968- padding : '0.5rem' ,
2002+ padding : tokens . size [ 2 ] ,
19692003 } }
19702004 class = "tsqd-query-details-explorer-container tsqd-query-details-query-explorer"
19712005 >
@@ -1980,7 +2014,7 @@ const MutationDetails = () => {
19802014 </ div >
19812015 < div
19822016 style = { {
1983- padding : '0.5rem' ,
2017+ padding : tokens . size [ 2 ] ,
19842018 } }
19852019 class = "tsqd-query-details-explorer-container tsqd-query-details-query-explorer"
19862020 >
@@ -2195,15 +2229,15 @@ const stylesFactory = (theme: 'light' | 'dark') => {
21952229 right : 0 ;
21962230 left : 0 ;
21972231 max-height : 90% ;
2198- min-height : 3.5 rem ;
2232+ min-height : ${ size [ 14 ] } ;
21992233 border-bottom : ${ t ( colors . gray [ 400 ] , colors . darkGray [ 300 ] ) } 1px solid;
22002234 ` ,
22012235 'panel-position-bottom' : css `
22022236 bottom : 0 ;
22032237 right : 0 ;
22042238 left : 0 ;
22052239 max-height : 90% ;
2206- min-height : 3.5 rem ;
2240+ min-height : ${ size [ 14 ] } ;
22072241 border-top : ${ t ( colors . gray [ 400 ] , colors . darkGray [ 300 ] ) } 1px solid;
22082242 ` ,
22092243 'panel-position-right' : css `
@@ -2535,6 +2569,8 @@ const stylesFactory = (theme: 'light' | 'dark') => {
25352569 outline : 2px solid ${ colors . blue [ 800 ] } ;
25362570 }
25372571 & svg {
2572+ width : ${ tokens . size [ 3 ] } ;
2573+ height : ${ tokens . size [ 3 ] } ;
25382574 color : ${ t ( colors . gray [ 500 ] , colors . gray [ 400 ] ) } ;
25392575 }
25402576 }
@@ -2620,8 +2656,8 @@ const stylesFactory = (theme: 'light' | 'dark') => {
26202656 border-radius : ${ tokens . border . radius . sm } ;
26212657 background-color : ${ t ( colors . gray [ 100 ] , colors . darkGray [ 400 ] ) } ;
26222658 border : 1px solid ${ t ( colors . gray [ 300 ] , colors . darkGray [ 200 ] ) } ;
2623- width : 1.625 rem ;
2624- height : 1.625 rem ;
2659+ width : ${ tokens . size [ 6.5 ] } ;
2660+ height : ${ tokens . size [ 6.5 ] } ;
26252661 justify-content : center;
26262662 display : flex;
26272663 align-items : center;
0 commit comments