Support nested object for textColor plugin
This commit is contained in:
parent
c3c9cdf5d6
commit
bfde7e4d6e
3 changed files with 68 additions and 15 deletions
|
|
@ -1,22 +1,10 @@
|
|||
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
|
||||
}
|
||||
import flattenColorPalette from '../util/flattenColorPalette'
|
||||
|
||||
export default function() {
|
||||
return function({ addUtilities, e, config }) {
|
||||
const utilities = _.fromPairs(
|
||||
_.map(buildColorPalette(config('theme.backgroundColor')), (value, modifier) => {
|
||||
_.map(flattenColorPalette(config('theme.backgroundColor')), (value, modifier) => {
|
||||
return [
|
||||
`.${e(`bg-${modifier}`)}`,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import _ from 'lodash'
|
||||
import flattenColorPalette from '../util/flattenColorPalette'
|
||||
|
||||
export default function() {
|
||||
return function({ addUtilities, e, config }) {
|
||||
const utilities = _.fromPairs(
|
||||
_.map(config('theme.textColor'), (value, modifier) => {
|
||||
_.map(flattenColorPalette(config('theme.textColor')), (value, modifier) => {
|
||||
return [
|
||||
`.${e(`text-${modifier}`)}`,
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue