Port borderRadius module to plugin
This commit is contained in:
parent
d969096c29
commit
2a0b64fa14
4 changed files with 45 additions and 59 deletions
43
src/plugins/borderRadius.js
Normal file
43
src/plugins/borderRadius.js
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import _ from 'lodash'
|
||||
|
||||
export default function () {
|
||||
return function ({ addUtilities, config, e }) {
|
||||
const generators = [
|
||||
(value, modifier) => ({
|
||||
[`.${e(`rounded${modifier}`)}`]: { borderRadius: `${value}` },
|
||||
}),
|
||||
(value, modifier) => ({
|
||||
[`.${e(`rounded-t${modifier}`)}`]: {
|
||||
borderTopLeftRadius: `${value}`,
|
||||
borderTopRightRadius: `${value}`,
|
||||
},
|
||||
[`.${e(`rounded-r${modifier}`)}`]: {
|
||||
borderTopRightRadius: `${value}`,
|
||||
borderBottomRightRadius: `${value}`,
|
||||
},
|
||||
[`.${e(`rounded-b${modifier}`)}`]: {
|
||||
borderBottomRightRadius: `${value}`,
|
||||
borderBottomLeftRadius: `${value}`,
|
||||
},
|
||||
[`.${e(`rounded-l${modifier}`)}`]: {
|
||||
borderTopLeftRadius: `${value}`,
|
||||
borderBottomLeftRadius: `${value}`,
|
||||
},
|
||||
}),
|
||||
(value, modifier) => ({
|
||||
[`.${e(`rounded-tl${modifier}`)}`]: { borderTopLeftRadius: `${value}` },
|
||||
[`.${e(`rounded-tr${modifier}`)}`]: { borderTopRightRadius: `${value}` },
|
||||
[`.${e(`rounded-br${modifier}`)}`]: { borderBottomRightRadius: `${value}` },
|
||||
[`.${e(`rounded-bl${modifier}`)}`]: { borderBottomLeftRadius: `${value}` },
|
||||
}),
|
||||
]
|
||||
|
||||
const utilities = _.flatMap(generators, generator => {
|
||||
return _.flatMap(config('borderRadius'), (value, modifier) => {
|
||||
return generator(value, modifier === 'default' ? '' : `-${modifier}`)
|
||||
})
|
||||
})
|
||||
|
||||
addUtilities(utilities, config('modules.borderRadius'))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue