Skip to content

Commit

Permalink
fix(docz): add theme config transform before merge
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jul 11, 2018
1 parent fb8069d commit dc3448a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
7 changes: 7 additions & 0 deletions examples/basic/doczrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
themeConfig: {
colors: {
primary: 'rebeccapurple',
},
},
}
8 changes: 5 additions & 3 deletions packages/docz/src/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,13 @@ export type TransformFn = (config: ThemeConfig) => ThemeConfig
export type ThemeReturn = (WrappedComponent: CT) => CT<ThemeProps>

export function theme(
defaultConfig?: ThemeConfig,
initialConfig?: ThemeConfig,
transform?: TransformFn
): ThemeReturn {
return WrappedComponent => {
const cfg = initialConfig || {}
const newConfig = transform ? transform(cfg) : cfg

const Theme: CT<ThemeProps> = ({
wrapper: Wrapper = DefaultWrapper,
entries,
Expand All @@ -81,11 +84,10 @@ export function theme(
hashRouter = false,
}) => {
const Router = hashRouter ? HashRouter : BrowserRouter
const newConfig = merge(defaultConfig, config)
const value = {
entries,
imports,
config: transform ? transform(newConfig) : newConfig,
config: merge(newConfig, config),
}

return (
Expand Down

0 comments on commit dc3448a

Please sign in to comment.