2019-01-09 21:50:03 -05:00
|
|
|
import _ from 'lodash'
|
2019-03-04 13:07:26 -05:00
|
|
|
import flattenColorPalette from '../util/flattenColorPalette'
|
2020-04-26 09:48:54 -04:00
|
|
|
import withAlphaVariable from '../util/withAlphaVariable'
|
2019-03-04 13:05:18 -05:00
|
|
|
|
2019-02-28 11:36:26 -05:00
|
|
|
export default function() {
|
2020-05-01 15:04:40 -04:00
|
|
|
return function({ addUtilities, e, theme, variants, target, corePlugins }) {
|
2020-05-07 00:22:07 +10:00
|
|
|
const colors = flattenColorPalette(theme('backgroundColor'))
|
|
|
|
|
|
2020-04-28 15:31:57 -04:00
|
|
|
if (target('backgroundColor') === 'ie11') {
|
2020-04-26 15:10:12 -04:00
|
|
|
const utilities = _.fromPairs(
|
2020-05-07 00:22:07 +10:00
|
|
|
_.map(colors, (value, modifier) => {
|
2020-05-07 00:23:43 +10:00
|
|
|
return [
|
|
|
|
|
`.${e(`bg-${modifier}`)}`,
|
|
|
|
|
{ 'background-color': value },
|
|
|
|
|
]
|
2020-04-26 15:10:12 -04:00
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
addUtilities(utilities, variants('backgroundColor'))
|
|
|
|
|
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 12:29:33 -05:00
|
|
|
const utilities = _.fromPairs(
|
2020-05-07 00:22:07 +10:00
|
|
|
_.map(colors, (value, modifier) => {
|
2019-01-11 12:29:33 -05:00
|
|
|
return [
|
|
|
|
|
`.${e(`bg-${modifier}`)}`,
|
2020-05-01 15:04:40 -04:00
|
|
|
corePlugins('backgroundOpacity')
|
|
|
|
|
? withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'background-color',
|
|
|
|
|
variable: '--bg-opacity',
|
|
|
|
|
})
|
|
|
|
|
: { 'background-color': value },
|
2019-01-11 12:29:33 -05:00
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
)
|
2019-01-09 21:50:03 -05:00
|
|
|
|
2019-04-18 09:42:21 -04:00
|
|
|
addUtilities(utilities, variants('backgroundColor'))
|
2019-01-09 21:50:03 -05:00
|
|
|
}
|
|
|
|
|
}
|