Skip to content

Commit

Permalink
Fix bug where color palette could not be empty
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Nov 14, 2020
1 parent 869d68d commit 278c203
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions __tests__/flattenColorPalette.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,7 @@ test('it flattens deeply nested color objects', () => {
'button-primary-focus-variant': 'orange',
})
})

test('it handles empty objects', () => {
expect(flattenColorPalette({})).toEqual({})
})
1 change: 1 addition & 0 deletions src/util/flattenColorPalette.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const flattenColorPalette = (colors) =>
Object.assign(
{},
...Object.entries(colors).flatMap(([color, values]) =>
typeof values == 'object'
? Object.entries(flattenColorPalette(values)).map(([number, hex]) => ({
Expand Down

0 comments on commit 278c203

Please sign in to comment.