diff --git a/.changeset/cyan-times-marry.md b/.changeset/cyan-times-marry.md new file mode 100644 index 00000000..5eddebcc --- /dev/null +++ b/.changeset/cyan-times-marry.md @@ -0,0 +1,6 @@ +--- +'@tanstack/devtools-utils': minor +'@tanstack/devtools-ui': patch +--- + +Extract devtools-ui from devtools-utils to avoid theme miss-match diff --git a/examples/solid/devtools-ui/src/index.tsx b/examples/solid/devtools-ui/src/index.tsx index d6dda4eb..de6e3ac3 100644 --- a/examples/solid/devtools-ui/src/index.tsx +++ b/examples/solid/devtools-ui/src/index.tsx @@ -1,8 +1,9 @@ import { createEffect, createSignal } from 'solid-js' import { render } from 'solid-js/web' - import { JsonTree, ThemeContextProvider } from '@tanstack/devtools-ui' +import type { TanStackDevtoolsTheme } from '@tanstack/devtools-ui' + import './index.css' const JsonTreeDate = { @@ -20,7 +21,7 @@ const JsonTreePath = { const darkThemeMq = window.matchMedia('(prefers-color-scheme: dark)') function App() { - const [theme, setTheme] = createSignal<'light' | 'dark'>( + const [theme, setTheme] = createSignal( darkThemeMq.matches ? 'dark' : 'light', ) diff --git a/packages/devtools-a11y/src/core/styles/styles.ts b/packages/devtools-a11y/src/core/styles/styles.ts index d324f37f..64b40104 100644 --- a/packages/devtools-a11y/src/core/styles/styles.ts +++ b/packages/devtools-a11y/src/core/styles/styles.ts @@ -2,6 +2,7 @@ import * as goober from 'goober' import { useTheme } from '@tanstack/devtools-ui' import { createMemo } from 'solid-js' +import type { TanStackDevtoolsTheme } from '@tanstack/devtools-ui' import type { RuleCategory, SeverityThreshold } from '../types/types' const SEVERITY_COLORS: Record = { @@ -49,7 +50,7 @@ const css = goober.css const FONT_SCALE = 1.1 const fontPx = (size: number) => `calc(${size}px * ${FONT_SCALE})` -function createA11yPanelStyles(theme: 'light' | 'dark') { +function createA11yPanelStyles(theme: TanStackDevtoolsTheme) { const t = (light: string, dark: string) => (theme === 'light' ? light : dark) const bg = t('#f9fafb;', '#191c24') diff --git a/packages/devtools-ui/src/components/icons.tsx b/packages/devtools-ui/src/components/icons.tsx index 3284d681..0915b083 100644 --- a/packages/devtools-ui/src/components/icons.tsx +++ b/packages/devtools-ui/src/components/icons.tsx @@ -1,5 +1,7 @@ // import { Show, createUniqueId } from 'solid-js' +import type { TanStackDevtoolsTheme } from './theme' + /* export function Search() { return ( ) } */ -/* +/* export function ChevronDown() { return ( ) } -/* +/* export function Pencil() { return ( @@ -696,7 +698,7 @@ export function PiP() { ) } -export function CopiedCopier(props: { theme: 'light' | 'dark' }) { +export function CopiedCopier(props: { theme: TanStackDevtoolsTheme }) { return ( ) } -/* +/* export function List() { return ( @@ -884,7 +886,7 @@ export function PauseCircle() { ) } */ -/* +/* export function TanstackLogo() { const id = createUniqueId() return ( diff --git a/packages/devtools-ui/src/components/theme.tsx b/packages/devtools-ui/src/components/theme.tsx index 07423dcf..3ae8c428 100644 --- a/packages/devtools-ui/src/components/theme.tsx +++ b/packages/devtools-ui/src/components/theme.tsx @@ -1,19 +1,19 @@ import { createContext, createEffect, createSignal, useContext } from 'solid-js' import type { Accessor, JSX } from 'solid-js' -export type Theme = 'light' | 'dark' +export type TanStackDevtoolsTheme = 'light' | 'dark' type ThemeContextValue = { - theme: Accessor - setTheme: (theme: Theme) => void + theme: Accessor + setTheme: (theme: TanStackDevtoolsTheme) => void } const ThemeContext = createContext(undefined) export const ThemeContextProvider = (props: { children: JSX.Element - theme: Theme + theme: TanStackDevtoolsTheme }) => { - const [theme, setTheme] = createSignal(props.theme) + const [theme, setTheme] = createSignal(props.theme) createEffect(() => { setTheme(props.theme) }) diff --git a/packages/devtools-ui/src/index.ts b/packages/devtools-ui/src/index.ts index 96dfa7f9..086a7235 100644 --- a/packages/devtools-ui/src/index.ts +++ b/packages/devtools-ui/src/index.ts @@ -14,6 +14,7 @@ export { } from './components/section' export { Header, HeaderLogo } from './components/header' export { useTheme, ThemeContextProvider } from './components/theme' +export type { TanStackDevtoolsTheme } from './components/theme' export { CheckCircleIcon, ChevronDownIcon, diff --git a/packages/devtools-ui/src/styles/use-styles.ts b/packages/devtools-ui/src/styles/use-styles.ts index c707a605..6a0afdd2 100644 --- a/packages/devtools-ui/src/styles/use-styles.ts +++ b/packages/devtools-ui/src/styles/use-styles.ts @@ -2,8 +2,9 @@ import * as goober from 'goober' import { createEffect, createSignal } from 'solid-js' import { useTheme } from '../components/theme' import { tokens } from './tokens' + +import type { TanStackDevtoolsTheme } from '../components/theme' import type { ButtonVariant } from '../components/button' -import type { Theme } from '../components/theme' const buttonVariantColors: Record< ButtonVariant, @@ -118,7 +119,7 @@ const buttonVariantColors: Record< }, } export const css = goober.css -const stylesFactory = (theme: Theme = 'dark') => { +const stylesFactory = (theme: TanStackDevtoolsTheme) => { const { colors, font, size, border } = tokens const { fontFamily } = font diff --git a/packages/devtools-utils/package.json b/packages/devtools-utils/package.json index d70802d0..a9f40581 100644 --- a/packages/devtools-utils/package.json +++ b/packages/devtools-utils/package.json @@ -72,9 +72,6 @@ "engines": { "node": ">=18" }, - "dependencies": { - "@tanstack/devtools-ui": "workspace:^" - }, "devDependencies": { "@tanstack/devtools": "workspace:^", "tsup": "^8.5.0", diff --git a/packages/devtools-utils/src/solid/class-mount-impl.tsx b/packages/devtools-utils/src/solid/class-mount-impl.tsx index 2c619044..62652af4 100644 --- a/packages/devtools-utils/src/solid/class-mount-impl.tsx +++ b/packages/devtools-utils/src/solid/class-mount-impl.tsx @@ -2,6 +2,7 @@ import { lazy } from 'solid-js' import { Portal, render } from 'solid-js/web' + import type { JSX } from 'solid-js' import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools' @@ -13,19 +14,12 @@ export function __mountComponent( }>, ): () => void { const Component = lazy(importFn) - const ThemeProvider = lazy(() => - import('@tanstack/devtools-ui').then((m) => ({ - default: m.ThemeContextProvider, - })), - ) return render( () => (
- - - +
), diff --git a/packages/devtools/src/context/devtools-context.tsx b/packages/devtools/src/context/devtools-context.tsx index 362b2f4c..c72bde74 100644 --- a/packages/devtools/src/context/devtools-context.tsx +++ b/packages/devtools/src/context/devtools-context.tsx @@ -11,9 +11,10 @@ import { import { initialState } from './devtools-store' import type { DevtoolsStore } from './devtools-store' import type { JSX, Setter } from 'solid-js' +import type { TanStackDevtoolsTheme } from '@tanstack/devtools-ui' export interface TanStackDevtoolsPluginProps { - theme: DevtoolsStore['settings']['theme'] + theme: TanStackDevtoolsTheme devtoolsOpen: boolean } export interface TanStackDevtoolsPlugin { diff --git a/packages/devtools/src/context/devtools-store.ts b/packages/devtools/src/context/devtools-store.ts index 5e3b4f0f..e4e908de 100644 --- a/packages/devtools/src/context/devtools-store.ts +++ b/packages/devtools/src/context/devtools-store.ts @@ -1,5 +1,6 @@ import type { TabName } from '../tabs' import type { TanStackDevtoolsPlugin } from './devtools-context' +import type { TanStackDevtoolsTheme } from '@tanstack/devtools-ui' type ModifierKey = 'Alt' | 'Control' | 'Meta' | 'Shift' | 'CtrlOrMeta' type KeyboardKey = ModifierKey | (string & {}) @@ -21,7 +22,7 @@ type TriggerPosition = | 'middle-right' type TriggerProps = { - theme: 'light' | 'dark' + theme: TanStackDevtoolsTheme } export type DevtoolsStore = { @@ -71,7 +72,7 @@ export type DevtoolsStore = { * The theme of the dev tools * @default "dark" */ - theme: 'light' | 'dark' + theme: TanStackDevtoolsTheme /** * Whether the trigger should be completely hidden or not (you can still open with the hotkey) diff --git a/packages/devtools/src/index.ts b/packages/devtools/src/index.ts index 93293af0..f5669d1b 100644 --- a/packages/devtools/src/index.ts +++ b/packages/devtools/src/index.ts @@ -6,3 +6,4 @@ export type { TanStackDevtoolsPluginProps, TanStackDevtoolsConfig, } from './context/devtools-context' +export type { TanStackDevtoolsTheme } from '@tanstack/devtools-ui' diff --git a/packages/preact-devtools/src/devtools.tsx b/packages/preact-devtools/src/devtools.tsx index 19dbf547..514f1ef9 100644 --- a/packages/preact-devtools/src/devtools.tsx +++ b/packages/preact-devtools/src/devtools.tsx @@ -7,6 +7,7 @@ import type { TanStackDevtoolsConfig, TanStackDevtoolsPlugin, TanStackDevtoolsPluginProps, + TanStackDevtoolsTheme, } from '@tanstack/devtools' type PluginRender = @@ -14,7 +15,7 @@ type PluginRender = | ((el: HTMLElement, props: TanStackDevtoolsPluginProps) => JSX.Element) type TriggerProps = { - theme: 'dark' | 'light' + theme: TanStackDevtoolsTheme } type TriggerRender = diff --git a/packages/react-devtools/src/devtools.tsx b/packages/react-devtools/src/devtools.tsx index 43688150..31acc79f 100644 --- a/packages/react-devtools/src/devtools.tsx +++ b/packages/react-devtools/src/devtools.tsx @@ -7,6 +7,7 @@ import type { TanStackDevtoolsConfig, TanStackDevtoolsPlugin, TanStackDevtoolsPluginProps, + TanStackDevtoolsTheme, } from '@tanstack/devtools' type PluginRender = @@ -14,7 +15,7 @@ type PluginRender = | ((el: HTMLElement, props: TanStackDevtoolsPluginProps) => JSX.Element) type TriggerProps = { - theme: 'dark' | 'light' + theme: TanStackDevtoolsTheme } type TriggerRender = diff --git a/packages/solid-devtools/src/core.tsx b/packages/solid-devtools/src/core.tsx index 84895299..8eab4fca 100644 --- a/packages/solid-devtools/src/core.tsx +++ b/packages/solid-devtools/src/core.tsx @@ -13,6 +13,7 @@ import type { TanStackDevtoolsConfig, TanStackDevtoolsPlugin, TanStackDevtoolsPluginProps, + TanStackDevtoolsTheme, } from '@tanstack/devtools' type SolidPluginRender = @@ -76,7 +77,7 @@ export type TanStackDevtoolsSolidPlugin = Omit< name: string | SolidPluginRender } interface TriggerProps { - theme: 'light' | 'dark' + theme: TanStackDevtoolsTheme } export interface TanStackDevtoolsInit { /** diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 15c852e9..406365fc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -876,9 +876,6 @@ importers: packages/devtools-utils: dependencies: - '@tanstack/devtools-ui': - specifier: workspace:^ - version: link:../devtools-ui '@types/react': specifier: '>=17.0.0' version: 19.2.10