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

Function QueryStatus

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

Source from the content-addressed store, hash-verified

1722}
1723
1724const QueryStatus: Component<QueryStatusProps> = (props) => {
1725 const theme = useTheme()
1726 const css = useQueryDevtoolsContext().shadowDOMTarget
1727 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
1728 : goober.css
1729 const styles = createMemo(() => {
1730 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
1731 })
1732
1733 const { colors, alpha } = tokens
1734 const t = (light: string, dark: string) => (theme() === 'dark' ? dark : light)
1735
1736 let tagRef!: HTMLButtonElement
1737
1738 const [mouseOver, setMouseOver] = createSignal(false)
1739 const [focused, setFocused] = createSignal(false)
1740
1741 const showLabel = createMemo(() => {
1742 if (selectedQueryHash()) {
1743 if (panelWidth() < firstBreakpoint && panelWidth() > secondBreakpoint) {
1744 return false
1745 }
1746 }
1747 if (panelWidth() < secondBreakpoint) {
1748 return false
1749 }
1750
1751 return true
1752 })
1753
1754 return (
1755 <button
1756 onFocus={() => setFocused(true)}
1757 onBlur={() => setFocused(false)}
1758 onMouseEnter={() => setMouseOver(true)}
1759 onMouseLeave={() => {
1760 setMouseOver(false)
1761 setFocused(false)
1762 }}
1763 disabled={showLabel()}
1764 ref={tagRef}
1765 aria-label={`${props.label}: ${props.count}`}
1766 class={cx(
1767 styles().queryStatusTag,
1768 !showLabel() &&
1769 css`
1770 cursor: pointer;
1771 &:hover {
1772 background: ${t(
1773 colors.gray[200],
1774 colors.darkGray[400],
1775 )}${alpha[80]};
1776 }
1777 `,
1778 'tsqd-query-status-tag',
1779 `tsqd-query-status-tag-${props.label.toLowerCase()}`,
1780 )}
1781 {...(mouseOver() || focused()

Callers

nothing calls this directly

Calls 5

useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
darkStylesFunction · 0.70
lightStylesFunction · 0.70
tFunction · 0.70

Tested by

no test coverage detected