Port backgroundColors module to plugin

This commit is contained in:
Adam Wathan 2019-01-09 21:50:03 -05:00
parent 0cd679b4ff
commit c39ed44c13
4 changed files with 15 additions and 12 deletions

View File

@ -1,3 +1,4 @@
import backgroundColors from './plugins/backgroundColors'
import backgroundPosition from './plugins/backgroundPosition'
import backgroundRepeat from './plugins/backgroundRepeat'
import backgroundSize from './plugins/backgroundSize'
@ -47,6 +48,7 @@ import zIndex from './plugins/zIndex'
export default function (config) {
return [
config.modules.backgroundColors === false ? () => {} : backgroundColors(),
config.modules.backgroundPosition === false ? () => {} : backgroundPosition(),
config.modules.backgroundRepeat === false ? () => {} : backgroundRepeat(),
config.modules.backgroundSize === false ? () => {} : backgroundSize(),

View File

@ -1,10 +0,0 @@
import _ from 'lodash'
import defineClass from '../util/defineClass'
export default function({ backgroundColors }) {
return _.map(backgroundColors, (color, className) => {
return defineClass(`bg-${className}`, {
'background-color': color,
})
})
}

View File

@ -0,0 +1,13 @@
import _ from 'lodash'
export default function () {
return function ({ addUtilities, config, e }) {
const utilities = _.fromPairs(_.map(config('backgroundColors'), (value, modifier) => {
return [`.${e(`bg-${modifier}`)}`, {
'background-color': value,
}]
}))
addUtilities(utilities, config('modules.backgroundColors'))
}
}

View File

@ -1,11 +1,9 @@
import lists from './generators/lists'
import appearance from './generators/appearance'
import backgroundAttachment from './generators/backgroundAttachment'
import backgroundColors from './generators/backgroundColors'
export default [
{ name: 'lists', generator: lists },
{ name: 'appearance', generator: appearance },
{ name: 'backgroundAttachment', generator: backgroundAttachment },
{ name: 'backgroundColors', generator: backgroundColors },
]