diff --git a/packages/docz-theme-default/src/index.tsx b/packages/docz-theme-default/src/index.tsx index 38baba2..d46745f 100644 --- a/packages/docz-theme-default/src/index.tsx +++ b/packages/docz-theme-default/src/index.tsx @@ -36,4 +36,4 @@ const Theme = () => ( ) -export default theme(Theme, config) +export default theme(config)(Theme) diff --git a/packages/docz/src/theme.tsx b/packages/docz/src/theme.tsx index 4ddc6dc..9761982 100644 --- a/packages/docz/src/theme.tsx +++ b/packages/docz/src/theme.tsx @@ -50,37 +50,38 @@ const initialContext: DataContext = { export const dataContext = React.createContext(initialContext) +const DefaultWrapper: SFC = ({ children }) => {children} + export interface ThemeProps extends DataContext { wrapper?: CT children(WrappedComponent: CT): JSX.Element } -const DefaultWrapper: SFC = ({ children }) => {children} +export type ThemeReturn = (WrappedComponent: CT) => CT -export function theme( - WrappedComponent: CT, - defaultConfig?: ThemeConfig -): CT { - const Theme: CT = ({ - wrapper: Wrapper = DefaultWrapper, - entries, - imports, - config = {}, - }) => { - const newConfig = merge(defaultConfig, config) - const value = { entries, imports, config: newConfig } +export function theme(defaultConfig?: ThemeConfig): ThemeReturn { + return WrappedComponent => { + const Theme: CT = ({ + wrapper: Wrapper = DefaultWrapper, + entries, + imports, + config = {}, + }) => { + const newConfig = merge(defaultConfig, config) + const value = { entries, imports, config: newConfig } - return ( - - - - - - - - ) + return ( + + + + + + + + ) + } + + Theme.displayName = 'DoczTheme' + return Theme } - - Theme.displayName = 'DoczTheme' - return Theme }