Files
react/lib/config-context.ts
witt 5c02bcf0e1 refactor(themes): refactor theme module to keep multiple themes (#440)
* 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
2021-02-03 23:11:35 +08:00

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)