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

Function ParentPanel

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

Source from the content-addressed store, hash-verified

436export const ParentPanel: Component<{
437 children: JSX.Element
438}> = (props) => {
439 const { panelWidth, setPanelWidth } = useDevtoolsState()
440
441 const theme = useTheme()
442 const css = useQueryDevtoolsContext().shadowDOMTarget
443 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
444 : goober.css
445 const styles = createMemo(() => {
446 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
447 })
448
449 let panelRef!: HTMLDivElement
450
451 onMount(() => {
452 createResizeObserver(panelRef, ({ width }, el) => {
453 if (el === panelRef) {
454 setPanelWidth(width)
455 }
456 })
457 })
458
459 const getPanelDynamicStyles = () => {
460 const { colors } = tokens
461 const t = (light: string, dark: string) =>
462 theme() === 'dark' ? dark : light
463 if (panelWidth() < secondBreakpoint) {
464 return css`
465 flex-direction: column;
466 background-color: ${t(colors.gray[300], colors.gray[600])};
467 `
468 }
469 return css`
470 flex-direction: row;
471 background-color: ${t(colors.gray[200], colors.darkGray[900])};
472 `
473 }
474
475 return (
476 <div
477 dir="ltr"
478 style={{
479 '--tsqd-font-size': '16px',
480 }}
481 ref={panelRef}
482 class={cx(
483 styles().parentPanel,
484 getPanelDynamicStyles(),
485 {
486 [css`
487 min-width: min-content;
488 `]: panelWidth() < thirdBreakpoint,
489 },
490 'tsqd-main-panel',
491 )}
492 >
493 {props.children}
494 </div>
495 )

Callers

nothing calls this directly

Calls 6

useDevtoolsStateFunction · 0.90
useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
getPanelDynamicStylesFunction · 0.85
darkStylesFunction · 0.70
lightStylesFunction · 0.70

Tested by

no test coverage detected