Port height module to plugin

This commit is contained in:
Adam Wathan 2019-01-09 21:16:16 -05:00
parent c8802df40d
commit 964bf81ee3
4 changed files with 15 additions and 16 deletions

View file

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

View file

@ -1,14 +0,0 @@
import _ from 'lodash'
import defineClass from '../util/defineClass'
function defineHeights(heights) {
return _.map(heights, (size, modifer) => {
return defineClass(`h-${modifer}`, {
height: `${size}`,
})
})
}
export default function(config) {
return _.flatten([defineHeights(config.height)])
}

13
src/plugins/height.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('height'), (value, modifier) => {
return [`.${e(`h-${modifier}`)}`, {
'height': value,
}]
}))
addUtilities(utilities, config('modules.height'))
}
}

View file

@ -16,7 +16,6 @@ import flexbox from './generators/flexbox'
import float from './generators/float'
import fonts from './generators/fonts'
import fontWeights from './generators/fontWeights'
import height from './generators/height'
export default [
{ name: 'lists', generator: lists },
@ -37,5 +36,4 @@ export default [
{ name: 'float', generator: float },
{ name: 'fonts', generator: fonts },
{ name: 'fontWeights', generator: fontWeights },
{ name: 'height', generator: height },
]