mirror of
https://github.com/zhigang1992/react.git
synced 2026-06-13 01:18:48 +08:00
* refactor(themes): refactor theme module to keep multiple themes * chore: migrate APIs to be compatible with new theme system * test: update snapshots * chore: migrate the path of the theme module * feat(themes): append static methods of themes * chore: hide custom theme when no custom content in the context * chore: manually add flush to preload styles in html * docs(themes): update to fit the new theme system
37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
import React from 'react'
|
|
import { DeepPartial } from 'components/utils/types'
|
|
import { GeistUIThemes } from 'components'
|
|
|
|
export interface Configs {
|
|
onThemeChange?: (themes: DeepPartial<GeistUIThemes>) => void
|
|
isChinese?: boolean
|
|
updateChineseState: (state: boolean) => void
|
|
sidebarScrollHeight: number
|
|
updateSidebarScrollHeight: (height: number) => void
|
|
|
|
tabbarFixed: boolean
|
|
updateTabbarFixed: (state: boolean) => void
|
|
|
|
customTheme: DeepPartial<GeistUIThemes>
|
|
updateCustomTheme: (theme: DeepPartial<GeistUIThemes>) => void
|
|
switchTheme: (type: string) => void
|
|
}
|
|
|
|
export const defaultConfigs: Configs = {
|
|
sidebarScrollHeight: 0,
|
|
updateSidebarScrollHeight: () => {},
|
|
updateChineseState: () => {},
|
|
|
|
tabbarFixed: false,
|
|
updateTabbarFixed: () => {},
|
|
|
|
customTheme: {},
|
|
updateCustomTheme: () => {},
|
|
onThemeChange: () => {},
|
|
switchTheme: () => {},
|
|
}
|
|
|
|
export const ConfigContext = React.createContext<Configs>(defaultConfigs)
|
|
|
|
export const useConfigs = (): Configs => React.useContext(ConfigContext)
|