Support nested object for backgroundColor plugin

This commit is contained in:
Adam Wathan 2019-03-04 13:05:18 -05:00
parent ce48a4c91d
commit c3c9cdf5d6
2 changed files with 78 additions and 1 deletions

View file

@ -1,9 +1,22 @@
import _ from 'lodash'
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
}
export default function() {
return function({ addUtilities, e, config }) {
const utilities = _.fromPairs(
_.map(config('theme.backgroundColor'), (value, modifier) => {
_.map(buildColorPalette(config('theme.backgroundColor')), (value, modifier) => {
return [
`.${e(`bg-${modifier}`)}`,
{