2020-04-16 11:01:24 -04:00
|
|
|
import _ from 'lodash'
|
|
|
|
|
import flattenColorPalette from '../util/flattenColorPalette'
|
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-05-01 15:04:40 -04:00
|
|
|
return function({ addUtilities, e, theme, variants, target, 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 (target('divideColor') === 'ie11') {
|
|
|
|
|
return { 'border-color': value }
|
|
|
|
|
}
|
2020-04-27 08:27:32 -04:00
|
|
|
|
2020-05-07 00:27:00 +10:00
|
|
|
if (corePlugins('divideOpacity')) {
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-color',
|
|
|
|
|
variable: '--divide-opacity',
|
|
|
|
|
})
|
|
|
|
|
}
|
2020-04-27 08:27:32 -04:00
|
|
|
|
2020-05-07 00:27:00 +10:00
|
|
|
return { 'border-color': value }
|
2020-04-27 08:27:32 -04:00
|
|
|
}
|
|
|
|
|
|
2020-04-16 11:01:24 -04:00
|
|
|
const utilities = _.fromPairs(
|
|
|
|
|
_.map(_.omit(colors, 'default'), (value, modifier) => {
|
|
|
|
|
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'))
|
|
|
|
|
}
|
|
|
|
|
}
|