Sort border width utilities from most general to most specific
This commit is contained in:
parent
a379d80aa7
commit
ddfa8de684
2 changed files with 109 additions and 99 deletions
|
|
@ -1,28 +1,38 @@
|
|||
import _ from 'lodash'
|
||||
import defineClasses from '../util/defineClasses'
|
||||
|
||||
function sizedBorder(width, modifier) {
|
||||
modifier = modifier === 'default' ? '' : `-${modifier}`
|
||||
function defineBorderWidthUtilities(borderWidths) {
|
||||
const generators = [
|
||||
(width, modifier) =>
|
||||
defineClasses({
|
||||
[`border${modifier}`]: {
|
||||
'border-width': `${width}`,
|
||||
},
|
||||
}),
|
||||
(width, modifier) =>
|
||||
defineClasses({
|
||||
[`border-t${modifier}`]: {
|
||||
'border-top-width': `${width}`,
|
||||
},
|
||||
[`border-r${modifier}`]: {
|
||||
'border-right-width': `${width}`,
|
||||
},
|
||||
[`border-b${modifier}`]: {
|
||||
'border-bottom-width': `${width}`,
|
||||
},
|
||||
[`border-l${modifier}`]: {
|
||||
'border-left-width': `${width}`,
|
||||
},
|
||||
}),
|
||||
]
|
||||
|
||||
return defineClasses({
|
||||
[`border${modifier}`]: {
|
||||
'border-width': `${width}`,
|
||||
},
|
||||
[`border-t${modifier}`]: {
|
||||
'border-top-width': `${width}`,
|
||||
},
|
||||
[`border-r${modifier}`]: {
|
||||
'border-right-width': `${width}`,
|
||||
},
|
||||
[`border-b${modifier}`]: {
|
||||
'border-bottom-width': `${width}`,
|
||||
},
|
||||
[`border-l${modifier}`]: {
|
||||
'border-left-width': `${width}`,
|
||||
},
|
||||
return _.flatMap(generators, generator => {
|
||||
return _.flatMap(borderWidths, (width, modifier) => {
|
||||
return generator(width, modifier === 'default' ? '' : `-${modifier}`)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = function({ borderWidths }) {
|
||||
return _.flatMap(borderWidths, sizedBorder)
|
||||
return defineBorderWidthUtilities(borderWidths)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue