2020-04-16 11:01:24 -04:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
import flattenColorPalette from '../util/flattenColorPalette'
|
2020-10-09 21:03:23 -04:00
|
|
|
import toColorValue from '../util/toColorValue'
|
2020-04-26 09:48:54 -04:00
|
|
|
import withAlphaVariable from '../util/withAlphaVariable'
|
2020-04-16 11:01:24 -04:00
|
|
|
|
|
|
|
|
export default function() {
|
2020-10-15 12:29:50 -04:00
|
|
|
return function({ addUtilities, e, theme, variants, corePlugins }) {
|
2020-04-16 11:01:24 -04:00
|
|
|
const colors = flattenColorPalette(theme('divideColor'))
|
|
|
|
|
|
2020-05-07 00:27:00 +10:00
|
|
|
const getProperties = value => {
|
|
|
|
|
if (corePlugins('divideOpacity')) {
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-color',
|
|
|
|
|
variable: '--divide-opacity',
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-04-27 08:27:32 -04:00
|
|
|
|
2020-10-09 21:03:23 -04:00
|
|
|
return { 'border-color': toColorValue(value) }
|
2020-04-27 08:27:32 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-16 11:01:24 -04:00
|
|
|
const utilities = _.fromPairs(
|
2020-10-15 16:26:34 -04:00
|
|
|
_.map(_.omit(colors, 'DEFAULT'), (value, modifier) => {
|
2020-04-16 11:01:24 -04:00
|
|
|
return [
|
2020-04-17 09:49:16 -04:00
|
|
|
`.${e(`divide-${modifier}`)} > :not(template) ~ :not(template)`,
|
2020-05-07 00:27:00 +10:00
|
|
|
getProperties(value),
|
2020-04-16 11:01:24 -04:00
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
addUtilities(utilities, variants('divideColor'))
|
|
|
|
|
}
|
|
|
|
|
}
|