Skip to content

Commit 00179c0

Browse files
committed
feat: extract theme provider
1 parent 7c33985 commit 00179c0

File tree

6 files changed

+17
-16
lines changed

6 files changed

+17
-16
lines changed

.changeset/cyan-times-marry.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@tanstack/devtools-utils': minor
3+
'@tanstack/devtools-ui': patch
4+
---
5+
6+
Extract devtools-ui from devtools-utils to avoid theme miss-match

packages/devtools-ui/src/components/theme.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { createContext, createEffect, createSignal, useContext } from 'solid-js'
22
import type { Accessor, JSX } from 'solid-js'
33

4-
export type Theme = 'light' | 'dark'
4+
export type ThemeType = 'light' | 'dark'
55

66
type ThemeContextValue = {
7-
theme: Accessor<Theme>
8-
setTheme: (theme: Theme) => void
7+
theme: Accessor<ThemeType>
8+
setTheme: (theme: ThemeType) => void
99
}
1010
const ThemeContext = createContext<ThemeContextValue | undefined>(undefined)
1111

1212
export const ThemeContextProvider = (props: {
1313
children: JSX.Element
14-
theme: Theme
14+
theme: ThemeType
1515
}) => {
16-
const [theme, setTheme] = createSignal<Theme>(props.theme)
16+
const [theme, setTheme] = createSignal<ThemeType>(props.theme)
1717
createEffect(() => {
1818
setTheme(props.theme)
1919
})

packages/devtools-ui/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export {
1414
} from './components/section'
1515
export { Header, HeaderLogo } from './components/header'
1616
export { useTheme, ThemeContextProvider } from './components/theme'
17+
export type { ThemeType } from './components/theme'
1718
export {
1819
CheckCircleIcon,
1920
ChevronDownIcon,

packages/devtools-ui/src/styles/use-styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createEffect, createSignal } from 'solid-js'
33
import { useTheme } from '../components/theme'
44
import { tokens } from './tokens'
55
import type { ButtonVariant } from '../components/button'
6-
import type { Theme } from '../components/theme'
6+
import type { ThemeType } from '../components/theme'
77

88
const buttonVariantColors: Record<
99
ButtonVariant,
@@ -118,7 +118,7 @@ const buttonVariantColors: Record<
118118
},
119119
}
120120
export const css = goober.css
121-
const stylesFactory = (theme: Theme = 'dark') => {
121+
const stylesFactory = (theme: ThemeType = 'dark') => {
122122
const { colors, font, size, border } = tokens
123123
const { fontFamily } = font
124124

packages/devtools-utils/src/solid/class-mount-impl.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import { lazy } from 'solid-js'
44
import { Portal, render } from 'solid-js/web'
5+
56
import type { JSX } from 'solid-js'
67
import type { TanStackDevtoolsPluginProps } from '@tanstack/devtools'
78

@@ -13,19 +14,12 @@ export function __mountComponent(
1314
}>,
1415
): () => void {
1516
const Component = lazy(importFn)
16-
const ThemeProvider = lazy(() =>
17-
import('@tanstack/devtools-ui').then((m) => ({
18-
default: m.ThemeContextProvider,
19-
})),
20-
)
2117

2218
return render(
2319
() => (
2420
<Portal mount={el}>
2521
<div style={{ height: '100%' }}>
26-
<ThemeProvider theme={props.theme}>
27-
<Component {...props} />
28-
</ThemeProvider>
22+
<Component {...props} />
2923
</div>
3024
</Portal>
3125
),

pnpm-lock.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)