import { createContext, createEffect, createSignal, useContext as getContext, } from 'solid-js' import type { Accessor, JSX } from 'solid-js' export type TanStackDevtoolsTheme = 'light' | 'dark' type ThemeContextValue = { theme: Accessor setTheme: (theme: TanStackDevtoolsTheme) => void } const ThemeContext = createContext(undefined) export const ThemeContextProvider = (props: { children: JSX.Element theme: TanStackDevtoolsTheme }) => { const [theme, setTheme] = createSignal(props.theme) createEffect(() => { setTheme(props.theme) }) return ( {props.children} ) } export function createTheme() { const context = getContext(ThemeContext) if (!context) { throw new Error('createTheme must be used within a ThemeContextProvider') } return context }