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:
parent
c84f0ec4b7
commit
c04a3b26c6
1 changed files with 6 additions and 1 deletions
|
|
@ -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]) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue