2019-01-09 21:50:03 -05:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
|
2019-03-04 13:05:18 -05:00
|
|
|
function buildColorPalette(colors) {
|
|
|
|
|
const result = _(colors)
|
|
|
|
|
.flatMap((color, name) => {
|
|
|
|
|
return _.isObject(color)
|
|
|
|
|
? _.map(color, (value, key) => [`${name}-${key}`, value])
|
|
|
|
|
: [[name, color]]
|
|
|
|
|
})
|
|
|
|
|
.fromPairs()
|
|
|
|
|
.value()
|
|
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-28 11:36:26 -05:00
|
|
|
export default function() {
|
|
|
|
|
return function({ addUtilities, e, config }) {
|
2019-01-11 12:29:33 -05:00
|
|
|
const utilities = _.fromPairs(
|
2019-03-04 13:05:18 -05:00
|
|
|
_.map(buildColorPalette(config('theme.backgroundColor')), (value, modifier) => {
|
2019-01-11 12:29:33 -05:00
|
|
|
return [
|
|
|
|
|
`.${e(`bg-${modifier}`)}`,
|
|
|
|
|
{
|
|
|
|
|
'background-color': value,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
)
|
2019-01-09 21:50:03 -05:00
|
|
|
|
2019-02-28 11:36:26 -05:00
|
|
|
addUtilities(utilities, config('variants.backgroundColor'))
|
2019-01-09 21:50:03 -05:00
|
|
|
}
|
|
|
|
|
}
|