MCPcopy Create free account
hub / github.com/TanStack/query / Devtools

Function Devtools

packages/query-devtools/src/Devtools.tsx:198–355  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

196 * @returns The toggle button and the panel.
197 */
198export const Devtools: Component<DevtoolsPanelProps> = (props) => {
199 const theme = useTheme()
200 const css = useQueryDevtoolsContext().shadowDOMTarget
201 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
202 : goober.css
203 const styles = createMemo(() => {
204 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
205 })
206 const pip = usePiPWindow()
207
208 const buttonPosition = createMemo(() => {
209 return useQueryDevtoolsContext().buttonPosition || BUTTON_POSITION
210 })
211
212 const isOpen = createMemo(() => {
213 return props.localStore.open === 'true'
214 ? true
215 : props.localStore.open === 'false'
216 ? false
217 : useQueryDevtoolsContext().initialIsOpen || INITIAL_IS_OPEN
218 })
219
220 const position = createMemo(() => {
221 return (
222 props.localStore.position ||
223 useQueryDevtoolsContext().position ||
224 POSITION
225 )
226 })
227
228 let transitionsContainerRef!: HTMLDivElement
229 createEffect(() => {
230 const root = transitionsContainerRef.parentElement as HTMLElement
231 const height = props.localStore.height || DEFAULT_HEIGHT
232 const width = props.localStore.width || DEFAULT_WIDTH
233 const panelPosition = position()
234 root.style.setProperty(
235 '--tsqd-panel-height',
236 `${panelPosition === 'top' ? '-' : ''}${height}px`,
237 )
238 root.style.setProperty(
239 '--tsqd-panel-width',
240 `${panelPosition === 'left' ? '-' : ''}${width}px`,
241 )
242 })
243
244 // Calculates the inherited font size of the parent and sets it as a CSS variable
245 // All the design tokens are calculated based on this variable
246 onMount(() => {
247 // This is to make sure that the font size is updated when the stylesheet is updated
248 // and the user focuses back on the window
249 const onFocus = () => {
250 const root = transitionsContainerRef.parentElement as HTMLElement
251 const fontSize = getComputedStyle(root).fontSize
252 root.style.setProperty('--tsqd-font-size', fontSize)
253 }
254 onFocus()
255 window.addEventListener('focus', onFocus)

Callers

nothing calls this directly

Calls 6

useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
usePiPWindowFunction · 0.90
onFocusFunction · 0.85
darkStylesFunction · 0.70
lightStylesFunction · 0.70

Tested by

no test coverage detected