Port shadows module to plugin

This commit is contained in:
Adam Wathan 2019-01-09 13:17:49 -05:00
parent e6c0da03df
commit 6a3ed59fa6
4 changed files with 16 additions and 12 deletions

View File

@ -1,3 +1,4 @@
import shadows from './plugins/shadows'
import svgFill from './plugins/svgFill'
import svgStroke from './plugins/svgStroke'
import tableLayout from './plugins/tableLayout'
@ -14,6 +15,7 @@ import width from './plugins/width'
import zIndex from './plugins/zIndex'
export default [
shadows(),
svgFill(),
svgStroke(),
tableLayout(),

View File

@ -1,10 +0,0 @@
import _ from 'lodash'
import defineClass from '../util/defineClass'
export default function({ shadows }) {
return _.map(shadows, (shadow, modifier) => {
return defineClass(modifier === 'default' ? 'shadow' : `shadow-${modifier}`, {
'box-shadow': shadow,
})
})
}

14
src/plugins/shadows.js Normal file
View File

@ -0,0 +1,14 @@
import _ from 'lodash'
export default function () {
return function ({ addUtilities, config, e }) {
const utilities = _.fromPairs(_.map(config('shadows'), (value, modifier) => {
const className = modifier === 'default' ? 'shadow' : `shadow-${modifier}`
return [`.${className}`, {
'box-shadow': value,
}]
}))
addUtilities(utilities, config('modules.shadows'))
}
}

View File

@ -33,7 +33,6 @@ import padding from './generators/padding'
import pointerEvents from './generators/pointerEvents'
import position from './generators/position'
import resize from './generators/resize'
import shadows from './generators/shadows'
export default [
{ name: 'lists', generator: lists },
@ -71,5 +70,4 @@ export default [
{ name: 'pointerEvents', generator: pointerEvents },
{ name: 'position', generator: position },
{ name: 'resize', generator: resize },
{ name: 'shadows', generator: shadows },
]