Skip to content

Commit ab27f7c

Browse files
refactor(devtools): move default theme to theme file, fix types (TanStack#2213)
1 parent 09116e5 commit ab27f7c

File tree

2 files changed

+21
-19
lines changed

2 files changed

+21
-19
lines changed

src/devtools/devtools.tsx

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
Select,
1818
ActiveQueryPanel,
1919
} from './styledComponents'
20-
import { ThemeProvider } from './theme'
20+
import { ThemeProvider, defaultTheme as theme } from './theme'
2121
import { getQueryStatusLabel, getQueryStatusColor } from './utils'
2222
import Explorer from './Explorer'
2323
import Logo from './Logo'
@@ -74,20 +74,6 @@ interface DevtoolsPanelOptions {
7474

7575
const isServer = typeof window === 'undefined'
7676

77-
const theme = {
78-
background: '#0b1521',
79-
backgroundAlt: '#132337',
80-
foreground: 'white',
81-
gray: '#3f4e60',
82-
grayAlt: '#222e3e',
83-
inputBackgroundColor: '#fff',
84-
inputTextColor: '#000',
85-
success: '#00ab52',
86-
danger: '#ff0085',
87-
active: '#006bff',
88-
warning: '#ffb200',
89-
}
90-
9177
export function ReactQueryDevtools({
9278
initialIsOpen,
9379
panelProps = {},

src/devtools/theme.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
1-
// @ts-nocheck
2-
31
import React from 'react'
42

5-
const ThemeContext = React.createContext()
3+
export const defaultTheme = {
4+
background: '#0b1521',
5+
backgroundAlt: '#132337',
6+
foreground: 'white',
7+
gray: '#3f4e60',
8+
grayAlt: '#222e3e',
9+
inputBackgroundColor: '#fff',
10+
inputTextColor: '#000',
11+
success: '#00ab52',
12+
danger: '#ff0085',
13+
active: '#006bff',
14+
warning: '#ffb200',
15+
}
16+
17+
interface ProviderProps {
18+
theme: typeof defaultTheme
19+
}
20+
21+
const ThemeContext = React.createContext(defaultTheme)
622

7-
export function ThemeProvider({ theme, ...rest }) {
23+
export function ThemeProvider({ theme, ...rest }: ProviderProps) {
824
return <ThemeContext.Provider value={theme} {...rest} />
925
}
1026

0 commit comments

Comments
 (0)