CoastalCommitsPastes/client/app/components/theme/ThemeProvider.tsx

29 lines
718 B
TypeScript
Raw Normal View History

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