mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Port backgroundColors module to plugin
This commit is contained in:
parent
0cd679b4ff
commit
c39ed44c13
@ -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(),
|
||||
|
||||
@ -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,
|
||||
})
|
||||
})
|
||||
}
|
||||
13
src/plugins/backgroundColors.js
Normal file
13
src/plugins/backgroundColors.js
Normal 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'))
|
||||
}
|
||||
}
|
||||
@ -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 },
|
||||
]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user