From 04566064ed3f33ea07087f5029201053b8a1cd38 Mon Sep 17 00:00:00 2001 From: Aryan Deora Date: Mon, 18 Sep 2023 11:51:44 -0400 Subject: [PATCH] fix(query-devtools): Fix styling issues in devtool --- packages/query-devtools/package.json | 6 +- packages/query-devtools/src/Devtools.tsx | 398 ++++++++++++------ packages/query-devtools/src/Explorer.tsx | 3 +- .../react-query-devtools/src/devtools.tsx | 2 +- .../svelte-query-devtools/src/Devtools.svelte | 2 +- pnpm-lock.yaml | 47 ++- 6 files changed, 300 insertions(+), 158 deletions(-) diff --git a/packages/query-devtools/package.json b/packages/query-devtools/package.json index 5a3a75f0b7..411fb29cd3 100644 --- a/packages/query-devtools/package.json +++ b/packages/query-devtools/package.json @@ -40,19 +40,21 @@ "test:lib": "vitest run --coverage", "test:lib:dev": "pnpm run test:lib --watch", "test:build": "publint --strict", - "build": "tsup" + "build": "tsup", + "build:dev": "tsup --watch" }, "files": [ "build", "src" ], "devDependencies": { - "@emotion/css": "^11.11.0", "@solid-primitives/keyed": "^1.2.0", "@solid-primitives/resize-observer": "^2.0.18", "@solid-primitives/storage": "^1.3.11", "@tanstack/match-sorter-utils": "^8.8.4", "@tanstack/query-core": "workspace:*", + "clsx": "^2.0.0", + "goober": "^2.1.13", "solid-js": "^1.7.8", "solid-transition-group": "^0.2.2", "superjson": "^1.12.4", diff --git a/packages/query-devtools/src/Devtools.tsx b/packages/query-devtools/src/Devtools.tsx index f27f3ddbdc..955f41b172 100644 --- a/packages/query-devtools/src/Devtools.tsx +++ b/packages/query-devtools/src/Devtools.tsx @@ -9,7 +9,8 @@ import { onMount, } from 'solid-js' import { rankItem } from '@tanstack/match-sorter-utils' -import { css, cx } from '@emotion/css' +import { css } from 'goober' +import { clsx as cx } from 'clsx' import { TransitionGroup } from 'solid-transition-group' import { Key } from '@solid-primitives/keyed' import { createLocalStorage } from '@solid-primitives/storage' @@ -110,50 +111,56 @@ export const Devtools = () => { return localStore.position || useQueryDevtoolsContext().position || POSITION }) + createEffect(() => { + const root = document.querySelector('.tsqd-parent-container') as HTMLElement + const height = localStore.height || DEFAULT_HEIGHT + const width = localStore.width || DEFAULT_WIDTH + const panelPosition = position() + root.style.setProperty( + '--tsqd-panel-height', + `${panelPosition === 'top' ? '-' : ''}${height}px`, + ) + root.style.setProperty( + '--tsqd-panel-width', + `${panelPosition === 'left' ? '-' : ''}${width}px`, + ) + }) + return (
- + { /> - +
= (props) => { // - // min-width - When the panel is in the left or right position, the panel // width is set to min-content to allow the panel to shrink to the lowest possible width - class={`${styles.panel} ${styles[`panel-position-${position()}`]} ${css` - flex-direction: ${panelWidth() < secondBreakpoint ? 'column' : 'row'}; - background-color: ${panelWidth() < secondBreakpoint - ? tokens.colors.gray[600] - : tokens.colors.darkGray[900]}; - ${panelWidth() < thirdBreakpoint && - (position() === 'right' || position() === 'left') - ? ` + class={cx( + styles.panel, + styles[`panel-position-${position()}`], + css` + flex-direction: ${panelWidth() < secondBreakpoint ? 'column' : 'row'}; + background-color: ${panelWidth() < secondBreakpoint + ? tokens.colors.gray[600] + : tokens.colors.darkGray[900]}; + `, + { + [css` min-width: min-content; - ` - : ''} - `}`} + `]: + panelWidth() < thirdBreakpoint && + (position() === 'right' || position() === 'left'), + }, + 'tsqd-main-panel', + )} style={{ height: position() === 'bottom' || position() === 'top' @@ -390,12 +403,17 @@ export const DevtoolsPanel: Component = (props) => { class={cx( styles.dragHandle, styles[`dragHandle-position-${position()}`], + 'tsqd-drag-handle', )} onMouseDown={handleDragStart} >