Port maxWidth module to plugin
This commit is contained in:
parent
645de657a1
commit
3c99be09ca
4 changed files with 15 additions and 16 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import maxWidth from './plugins/maxWidth'
|
||||
import minHeight from './plugins/minHeight'
|
||||
import minWidth from './plugins/minWidth'
|
||||
import negativeMargin from './plugins/negativeMargin'
|
||||
|
|
@ -28,6 +29,7 @@ import zIndex from './plugins/zIndex'
|
|||
|
||||
export default function (config) {
|
||||
return [
|
||||
config.modules.maxWidth === false ? () => {} : maxWidth(),
|
||||
config.modules.minHeight === false ? () => {} : minHeight(),
|
||||
config.modules.minWidth === false ? () => {} : minWidth(),
|
||||
config.modules.negativeMargin === false ? () => {} : negativeMargin(),
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
import _ from 'lodash'
|
||||
import defineClass from '../util/defineClass'
|
||||
|
||||
function defineMaxWidths(widths) {
|
||||
return _.map(widths, (size, modifer) => {
|
||||
return defineClass(`max-w-${modifer}`, {
|
||||
'max-width': `${size}`,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
export default function(config) {
|
||||
return _.flatten([defineMaxWidths(config.maxWidth)])
|
||||
}
|
||||
13
src/plugins/maxWidth.js
Normal file
13
src/plugins/maxWidth.js
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import _ from 'lodash'
|
||||
|
||||
export default function () {
|
||||
return function ({ addUtilities, config, e }) {
|
||||
const utilities = _.fromPairs(_.map(config('maxWidth'), (value, modifier) => {
|
||||
return [`.${e(`max-w-${modifier}`)}`, {
|
||||
'max-width': value,
|
||||
}]
|
||||
}))
|
||||
|
||||
addUtilities(utilities, config('modules.maxWidth'))
|
||||
}
|
||||
}
|
||||
|
|
@ -20,7 +20,6 @@ import height from './generators/height'
|
|||
import leading from './generators/leading'
|
||||
import margin from './generators/margin'
|
||||
import maxHeight from './generators/maxHeight'
|
||||
import maxWidth from './generators/maxWidth'
|
||||
|
||||
export default [
|
||||
{ name: 'lists', generator: lists },
|
||||
|
|
@ -45,5 +44,4 @@ export default [
|
|||
{ name: 'leading', generator: leading },
|
||||
{ name: 'margin', generator: margin },
|
||||
{ name: 'maxHeight', generator: maxHeight },
|
||||
{ name: 'maxWidth', generator: maxWidth },
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue