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

Function Devtools

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

usePiPWindowFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
attachStylesFunction · 0.90
onFocusFunction · 0.85

Tested by

no test coverage detected