Skip to content

Commit c39ed44

Browse files
committed
Port backgroundColors module to plugin
1 parent 0cd679b commit c39ed44

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

src/defaultPlugins.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import backgroundColors from './plugins/backgroundColors'
12
import backgroundPosition from './plugins/backgroundPosition'
23
import backgroundRepeat from './plugins/backgroundRepeat'
34
import backgroundSize from './plugins/backgroundSize'
@@ -47,6 +48,7 @@ import zIndex from './plugins/zIndex'
4748

4849
export default function (config) {
4950
return [
51+
config.modules.backgroundColors === false ? () => {} : backgroundColors(),
5052
config.modules.backgroundPosition === false ? () => {} : backgroundPosition(),
5153
config.modules.backgroundRepeat === false ? () => {} : backgroundRepeat(),
5254
config.modules.backgroundSize === false ? () => {} : backgroundSize(),

src/generators/backgroundColors.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/plugins/backgroundColors.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import _ from 'lodash'
2+
3+
export default function () {
4+
return function ({ addUtilities, config, e }) {
5+
const utilities = _.fromPairs(_.map(config('backgroundColors'), (value, modifier) => {
6+
return [`.${e(`bg-${modifier}`)}`, {
7+
'background-color': value,
8+
}]
9+
}))
10+
11+
addUtilities(utilities, config('modules.backgroundColors'))
12+
}
13+
}

src/utilityModules.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import lists from './generators/lists'
22
import appearance from './generators/appearance'
33
import backgroundAttachment from './generators/backgroundAttachment'
4-
import backgroundColors from './generators/backgroundColors'
54

65
export default [
76
{ name: 'lists', generator: lists },
87
{ name: 'appearance', generator: appearance },
98
{ name: 'backgroundAttachment', generator: backgroundAttachment },
10-
{ name: 'backgroundColors', generator: backgroundColors },
119
]

0 commit comments

Comments
 (0)