Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/cyan-times-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@tanstack/devtools-utils': minor
'@tanstack/devtools-ui': patch
---

Extract devtools-ui from devtools-utils to avoid theme miss-match
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Typo in changeset description.

"miss-match" should be "mismatch".

-Extract devtools-ui from devtools-utils to avoid theme miss-match
+Extract devtools-ui from devtools-utils to avoid theme mismatch
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Extract devtools-ui from devtools-utils to avoid theme miss-match
Extract devtools-ui from devtools-utils to avoid theme mismatch
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.changeset/cyan-times-marry.md at line 6, Typo in the changeset description:
locate the changeset entry whose summary reads "Extract devtools-ui from
devtools-utils to avoid theme miss-match" and correct the word "miss-match" to
"mismatch" so the summary reads "Extract devtools-ui from devtools-utils to
avoid theme mismatch".

10 changes: 5 additions & 5 deletions packages/devtools-ui/src/components/theme.tsx
Original file line number Diff line number Diff line change
@@ -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 ThemeType = 'light' | 'dark'

type ThemeContextValue = {
theme: Accessor<Theme>
setTheme: (theme: Theme) => void
theme: Accessor<ThemeType>
setTheme: (theme: ThemeType) => void
}
const ThemeContext = createContext<ThemeContextValue | undefined>(undefined)

export const ThemeContextProvider = (props: {
children: JSX.Element
theme: Theme
theme: ThemeType
}) => {
const [theme, setTheme] = createSignal<Theme>(props.theme)
const [theme, setTheme] = createSignal<ThemeType>(props.theme)
createEffect(() => {
setTheme(props.theme)
})
Expand Down
1 change: 1 addition & 0 deletions packages/devtools-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export {
} from './components/section'
export { Header, HeaderLogo } from './components/header'
export { useTheme, ThemeContextProvider } from './components/theme'
export type { ThemeType } from './components/theme'
export {
CheckCircleIcon,
ChevronDownIcon,
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools-ui/src/styles/use-styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createEffect, createSignal } from 'solid-js'
import { useTheme } from '../components/theme'
import { tokens } from './tokens'
import type { ButtonVariant } from '../components/button'
import type { Theme } from '../components/theme'
import type { ThemeType } from '../components/theme'

const buttonVariantColors: Record<
ButtonVariant,
Expand Down Expand Up @@ -53,7 +53,7 @@ const buttonVariantColors: Record<
},
}
export const css = goober.css
const stylesFactory = (theme: Theme = 'dark') => {
const stylesFactory = (theme: ThemeType = 'dark') => {
const { colors, font, size, border } = tokens
const { fontFamily } = font

Expand Down
Empty file modified packages/devtools-utils/bin/intent.js
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion packages/devtools-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"node": ">=18"
},
"dependencies": {
"@tanstack/devtools-ui": "workspace:^"
"@tanstack/devtools-ui": "workspace:*"
},
"peerDependencies": {
"@types/react": ">=17.0.0",
Expand Down
17 changes: 7 additions & 10 deletions packages/devtools-utils/src/solid/class-mount-impl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,24 @@

import { lazy } from 'solid-js'
import { Portal, render } from 'solid-js/web'

import type { JSX } from 'solid-js'
import type { ThemeType } from '@tanstack/devtools-ui'

export function __mountComponent(
el: HTMLElement,
theme: 'light' | 'dark',
importFn: () => Promise<{ default: () => JSX.Element }>,
theme: ThemeType,
importFn: () => Promise<{
default: (props: { theme: ThemeType }) => JSX.Element
}>,
): () => void {
const Component = lazy(importFn)
const ThemeProvider = lazy(() =>
import('@tanstack/devtools-ui').then((m) => ({
default: m.ThemeContextProvider,
})),
)

return render(
() => (
<Portal mount={el}>
<div style={{ height: '100%' }}>
<ThemeProvider theme={theme}>
<Component />
</ThemeProvider>
<Component theme={theme} />
</div>
</Portal>
),
Expand Down
5 changes: 4 additions & 1 deletion packages/devtools-utils/src/solid/class.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { ThemeType } from '@tanstack/devtools-ui'
import type { JSX } from 'solid-js'

export type DevtoolProps = { theme: ThemeType }

/**
* Constructs the core class for the Devtools.
* This utility is used to construct a lazy loaded Solid component for the Devtools.
Expand All @@ -10,7 +13,7 @@ import type { JSX } from 'solid-js'
* @returns Tuple containing the DevtoolsCore class and a NoOpDevtoolsCore class
*/
export function constructCoreClass(
importFn: () => Promise<{ default: () => JSX.Element }>,
importFn: () => Promise<{ default: (props: DevtoolProps) => JSX.Element }>,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nts: perhaps make a generic extending DevtoolProps

) {
class DevtoolsCore {
#isMounted = false
Expand Down
2 changes: 1 addition & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading