2022-11-18 01:36:53 -05:00
|
|
|
import type { FunctionComponent, PropsWithChildren } from "react"
|
|
|
|
import ThemeClientContextProvider from "./ThemeClientContextProvider"
|
2022-11-15 23:50:54 -05:00
|
|
|
import ThemeServerContextProvider, {
|
2022-11-18 01:36:53 -05:00
|
|
|
useServerTheme
|
|
|
|
} from "./ThemeServerContextProvider"
|
2022-11-15 23:50:54 -05:00
|
|
|
|
|
|
|
const ThemeProviderWrapper: FunctionComponent<PropsWithChildren<{}>> = ({
|
2022-11-18 01:36:53 -05:00
|
|
|
children
|
2022-11-15 23:50:54 -05:00
|
|
|
}) => {
|
2022-11-18 01:36:53 -05:00
|
|
|
const theme = useServerTheme()
|
|
|
|
return (
|
|
|
|
<ThemeClientContextProvider defaultTheme={theme}>
|
|
|
|
{children}
|
|
|
|
</ThemeClientContextProvider>
|
|
|
|
)
|
|
|
|
}
|
2022-11-15 23:50:54 -05:00
|
|
|
|
2022-11-18 01:36:53 -05:00
|
|
|
const ThemeProvider: FunctionComponent<PropsWithChildren<{}>> = ({
|
|
|
|
children
|
|
|
|
}) => {
|
|
|
|
return (
|
|
|
|
<ThemeServerContextProvider>
|
|
|
|
<ThemeProviderWrapper>{children}</ThemeProviderWrapper>
|
|
|
|
</ThemeServerContextProvider>
|
|
|
|
)
|
|
|
|
}
|
2022-11-15 23:50:54 -05:00
|
|
|
|
2022-11-18 01:36:53 -05:00
|
|
|
export default ThemeProvider
|