Port maxHeight module to plugin

This commit is contained in:
Adam Wathan 2019-01-09 21:12:45 -05:00
parent 3c99be09ca
commit b5a51e879d
4 changed files with 15 additions and 16 deletions

View File

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

View File

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

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

View File

@ -19,7 +19,6 @@ import fontWeights from './generators/fontWeights'
import height from './generators/height'
import leading from './generators/leading'
import margin from './generators/margin'
import maxHeight from './generators/maxHeight'
export default [
{ name: 'lists', generator: lists },
@ -43,5 +42,4 @@ export default [
{ name: 'height', generator: height },
{ name: 'leading', generator: leading },
{ name: 'margin', generator: margin },
{ name: 'maxHeight', generator: maxHeight },
]