Add divideWidth plugin

This commit is contained in:
Adam Wathan 2020-04-16 10:53:19 -04:00
parent c84c397f0b
commit b447cd6ccd
6 changed files with 147 additions and 0 deletions

View file

@ -0,0 +1,20 @@
import _ from 'lodash'
export default function() {
return function({ addUtilities, e, theme, variants }) {
const generators = [
(value, modifier) => ({
[`.${e(`divide-y${modifier}`)} > * + *`]: { 'border-top-width': `${value}` },
[`.${e(`divide-x${modifier}`)} > * + *`]: { 'border-left-width': `${value}` },
}),
]
const utilities = _.flatMap(generators, generator => {
return _.flatMap(theme('divideWidth'), (value, modifier) => {
return generator(value, modifier === 'default' ? '' : `-${modifier}`)
})
})
addUtilities(utilities, variants('divideWidth'))
}
}