Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix code style
  • Loading branch information
adamwathan committed Feb 13, 2019
commit d95d28eec8cd0906ec04d011edaa93ff45095acc
8 changes: 4 additions & 4 deletions __tests__/resolveConfig.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ test('theme values in the extend section extend the existing theme', () => {
backgroundColors: {
customBackground: '#bada55',
},
}
},
},
}

Expand Down Expand Up @@ -520,7 +520,7 @@ test('theme values in the extend section extend the user theme', () => {
height: {
customHeight: '500vh',
},
}
},
},
}

Expand All @@ -536,7 +536,7 @@ test('theme values in the extend section extend the user theme', () => {
},
height: {
'0': 0,
'full': '100%',
full: '100%',
},
width: {
'0': 0,
Expand Down Expand Up @@ -604,7 +604,7 @@ test('theme values in the extend section can extend values that are depended on
backgroundColors: {
customBackground: '#bada55',
},
}
},
},
}

Expand Down
5 changes: 3 additions & 2 deletions src/util/resolveConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ function resolveFunctionKeys(object) {
}

function without(object, key) {
return (({[key]: _, ...rest }) => rest)(object)
/* eslint-disable no-unused-vars */
return (({ [key]: _, ...rest }) => rest)(object)
}

function mergeExtensions(theme) {
return mergeWith({}, without(theme, 'extend'), theme.extend, (_, extensions, key) => {
Copy link

@ramon-villain ramon-villain Feb 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not you get the same result spreading the parameter?

function mergeExtensions({extend, ...theme}) {
  return mergeWith({}, theme, extend, (_, extensions, key) => {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, so much better, thanks! ❤️

return isFunction(theme[key])
? mergedTheme => ({
...theme[key](mergedTheme),
...extensions
...extensions,
})
: {
...theme[key],
Expand Down