forked from tailwindlabs/tailwindcss
/
divideColor.js
34 lines (29 loc) · 1.02 KB
/
divideColor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const flattenColorPalette = require('../../lib/util/flattenColorPalette').default
const withAlphaVariable = require('../../lib/util/withAlphaVariable').default
const { asColor, nameClass } = require('../pluginUtils')
module.exports = function ({ corePlugins, matchUtilities, theme }) {
let colorPalette = flattenColorPalette(theme('divideColor'))
// TODO: Make sure there is no issue with DEFAULT here
matchUtilities({
divide: (modifier) => {
let value = asColor(modifier, colorPalette)
if (value === undefined) {
return []
}
if (corePlugins('divideOpacity')) {
return {
[`${nameClass('divide', modifier)} > :not([hidden]) ~ :not([hidden])`]: withAlphaVariable({
color: colorPalette[modifier],
property: 'border-color',
variable: '--tw-divide-opacity',
}),
}
}
return {
[`${nameClass('divide', modifier)} > :not([hidden]) ~ :not([hidden])`]: {
'border-color': value,
},
}
},
})
}