Add support for mixed "plain color string" and "color map" background defintitions

Lets you do this:

```
  backgroundColors: [
    'blue',
    'purple',
    'pink',
    {
      primary: 'white',
      secondary: 'orange',
    },
  ]
```
This commit is contained in:
Adam Wathan 2017-08-25 10:17:28 -04:00
parent c84f0ec4b7
commit c04a3b26c6

View file

@ -11,7 +11,12 @@ function findColor(colors, color) {
module.exports = function ({ colors, backgroundColors }) {
if (_.isArray(backgroundColors)) {
backgroundColors = _(backgroundColors).map(color => [color, color]).fromPairs()
backgroundColors = _(backgroundColors).flatMap(color => {
if (_.isString(color)) {
return [[color, color]]
}
return _.toPairs(color)
}).fromPairs()
}
return _(backgroundColors).toPairs().map(([className, colorName]) => {