Support nested object for backgroundColor plugin
This commit is contained in:
parent
ce48a4c91d
commit
c3c9cdf5d6
2 changed files with 78 additions and 1 deletions
|
|
@ -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}`)}`,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue