tailwindcss/src/plugins/divideColor.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-04-16 11:01:24 -04:00
import _ from 'lodash'
import flattenColorPalette from '../util/flattenColorPalette'
import withAlphaVariable from '../util/withAlphaVariable'
2020-04-16 11:01:24 -04:00
export default function() {
2020-04-28 15:31:57 -04:00
return function({ addUtilities, e, theme, variants, target }) {
2020-04-16 11:01:24 -04:00
const colors = flattenColorPalette(theme('divideColor'))
2020-04-28 15:31:57 -04:00
if (target('divideColor') === 'ie11') {
const utilities = _.fromPairs(
_.map(_.omit(colors, 'default'), (value, modifier) => {
return [
`.${e(`divide-${modifier}`)} > :not(template) ~ :not(template)`,
{ 'border-color': value },
]
})
)
addUtilities(utilities, variants('textColor'))
return
}
2020-04-16 11:01:24 -04:00
const utilities = _.fromPairs(
_.map(_.omit(colors, 'default'), (value, modifier) => {
return [
`.${e(`divide-${modifier}`)} > :not(template) ~ :not(template)`,
withAlphaVariable({
color: value,
property: 'border-color',
variable: '--divide-opacity',
}),
2020-04-16 11:01:24 -04:00
]
})
)
addUtilities(utilities, variants('divideColor'))
}
}