Port leading module to plugin

This commit is contained in:
Adam Wathan 2019-01-09 21:15:06 -05:00
parent 97da5c40d6
commit c8802df40d
4 changed files with 15 additions and 12 deletions

View File

@ -1,3 +1,4 @@
import leading from './plugins/leading'
import margin from './plugins/margin'
import maxHeight from './plugins/maxHeight'
import maxWidth from './plugins/maxWidth'
@ -31,6 +32,7 @@ import zIndex from './plugins/zIndex'
export default function (config) {
return [
config.modules.leading === false ? () => {} : leading(),
config.modules.margin === false ? () => {} : margin(),
config.modules.maxHeight === false ? () => {} : maxHeight(),
config.modules.maxWidth === false ? () => {} : maxWidth(),

View File

@ -1,10 +0,0 @@
import _ from 'lodash'
import defineClass from '../util/defineClass'
export default function({ leading }) {
return _.map(leading, (value, modifier) => {
return defineClass(`leading-${modifier}`, {
'line-height': `${value}`,
})
})
}

13
src/plugins/leading.js Normal file
View File

@ -0,0 +1,13 @@
import _ from 'lodash'
export default function () {
return function ({ addUtilities, config, e }) {
const utilities = _.fromPairs(_.map(config('leading'), (value, modifier) => {
return [`.${e(`leading-${modifier}`)}`, {
'line-height': value,
}]
}))
addUtilities(utilities, config('modules.leading'))
}
}

View File

@ -17,7 +17,6 @@ import float from './generators/float'
import fonts from './generators/fonts'
import fontWeights from './generators/fontWeights'
import height from './generators/height'
import leading from './generators/leading'
export default [
{ name: 'lists', generator: lists },
@ -39,5 +38,4 @@ export default [
{ name: 'fonts', generator: fonts },
{ name: 'fontWeights', generator: fontWeights },
{ name: 'height', generator: height },
{ name: 'leading', generator: leading },
]