feat(theme): add CSS injection pipeline, presets, rewrite ThemeProvider, FOUC prevention

This commit is contained in:
DrSmoothl
2026-02-19 17:26:53 +08:00
parent 6aa1132f4c
commit 8fb137a318
5 changed files with 284 additions and 114 deletions

View File

@@ -1,15 +1,30 @@
import { createContext } from 'react'
import type { UserThemeConfig } from './theme/tokens'
type Theme = 'dark' | 'light' | 'system'
export type ThemeProviderState = {
theme: Theme
resolvedTheme: 'dark' | 'light'
setTheme: (theme: Theme) => void
themeConfig: UserThemeConfig
updateThemeConfig: (partial: Partial<UserThemeConfig>) => void
resetTheme: () => void
}
const initialState: ThemeProviderState = {
theme: 'system',
resolvedTheme: 'light',
setTheme: () => null,
themeConfig: {
selectedPreset: 'light',
accentColor: '',
tokenOverrides: {},
customCSS: '',
},
updateThemeConfig: () => null,
resetTheme: () => null,
}
export const ThemeProviderContext = createContext<ThemeProviderState>(initialState)