Skip to content

Commit e120f59

Browse files
committed
Simplify defaultPlugins module
1 parent 057b4ea commit e120f59

1 file changed

Lines changed: 58 additions & 53 deletions

File tree

src/defaultPlugins.js

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -49,58 +49,63 @@ import whitespace from './plugins/whitespace'
4949
import width from './plugins/width'
5050
import zIndex from './plugins/zIndex'
5151

52-
// eslint-disable-next-line complexity
52+
function loadPlugins(modules, plugins) {
53+
return Object.keys(plugins)
54+
.filter(plugin => modules[plugin] !== false)
55+
.map(plugin => plugins[plugin]())
56+
}
57+
5358
export default function(config) {
54-
return [
55-
config.modules.lists === false ? () => {} : lists(),
56-
config.modules.appearance === false ? () => {} : appearance(),
57-
config.modules.backgroundAttachment === false ? () => {} : backgroundAttachment(),
58-
config.modules.backgroundColors === false ? () => {} : backgroundColors(),
59-
config.modules.backgroundPosition === false ? () => {} : backgroundPosition(),
60-
config.modules.backgroundRepeat === false ? () => {} : backgroundRepeat(),
61-
config.modules.backgroundSize === false ? () => {} : backgroundSize(),
62-
config.modules.borderCollapse === false ? () => {} : borderCollapse(),
63-
config.modules.borderColors === false ? () => {} : borderColors(),
64-
config.modules.borderRadius === false ? () => {} : borderRadius(),
65-
config.modules.borderStyle === false ? () => {} : borderStyle(),
66-
config.modules.borderWidths === false ? () => {} : borderWidths(),
67-
config.modules.cursor === false ? () => {} : cursor(),
68-
config.modules.display === false ? () => {} : display(),
69-
config.modules.flexbox === false ? () => {} : flexbox(),
70-
config.modules.float === false ? () => {} : float(),
71-
config.modules.fonts === false ? () => {} : fonts(),
72-
config.modules.fontWeights === false ? () => {} : fontWeights(),
73-
config.modules.height === false ? () => {} : height(),
74-
config.modules.leading === false ? () => {} : leading(),
75-
config.modules.margin === false ? () => {} : margin(),
76-
config.modules.maxHeight === false ? () => {} : maxHeight(),
77-
config.modules.maxWidth === false ? () => {} : maxWidth(),
78-
config.modules.minHeight === false ? () => {} : minHeight(),
79-
config.modules.minWidth === false ? () => {} : minWidth(),
80-
config.modules.negativeMargin === false ? () => {} : negativeMargin(),
81-
config.modules.objectFit === false ? () => {} : objectFit(),
82-
config.modules.objectPosition === false ? () => {} : objectPosition(),
83-
config.modules.opacity === false ? () => {} : opacity(),
84-
config.modules.outline === false ? () => {} : outline(),
85-
config.modules.overflow === false ? () => {} : overflow(),
86-
config.modules.padding === false ? () => {} : padding(),
87-
config.modules.pointerEvents === false ? () => {} : pointerEvents(),
88-
config.modules.position === false ? () => {} : position(),
89-
config.modules.resize === false ? () => {} : resize(),
90-
config.modules.shadows === false ? () => {} : shadows(),
91-
config.modules.svgFill === false ? () => {} : svgFill(),
92-
config.modules.svgStroke === false ? () => {} : svgStroke(),
93-
config.modules.tableLayout === false ? () => {} : tableLayout(),
94-
config.modules.textAlign === false ? () => {} : textAlign(),
95-
config.modules.textColors === false ? () => {} : textColors(),
96-
config.modules.textSizes === false ? () => {} : textSizes(),
97-
config.modules.textStyle === false ? () => {} : textStyle(),
98-
config.modules.tracking === false ? () => {} : tracking(),
99-
config.modules.userSelect === false ? () => {} : userSelect(),
100-
config.modules.verticalAlign === false ? () => {} : verticalAlign(),
101-
config.modules.visibility === false ? () => {} : visibility(),
102-
config.modules.whitespace === false ? () => {} : whitespace(),
103-
config.modules.width === false ? () => {} : width(),
104-
config.modules.zIndex === false ? () => {} : zIndex(),
105-
]
59+
return loadPlugins(config.modules, {
60+
lists,
61+
appearance,
62+
backgroundAttachment,
63+
backgroundColors,
64+
backgroundPosition,
65+
backgroundRepeat,
66+
backgroundSize,
67+
borderCollapse,
68+
borderColors,
69+
borderRadius,
70+
borderStyle,
71+
borderWidths,
72+
cursor,
73+
display,
74+
flexbox,
75+
float,
76+
fonts,
77+
fontWeights,
78+
height,
79+
leading,
80+
margin,
81+
maxHeight,
82+
maxWidth,
83+
minHeight,
84+
minWidth,
85+
negativeMargin,
86+
objectFit,
87+
objectPosition,
88+
opacity,
89+
outline,
90+
overflow,
91+
padding,
92+
pointerEvents,
93+
position,
94+
resize,
95+
shadows,
96+
svgFill,
97+
svgStroke,
98+
tableLayout,
99+
textAlign,
100+
textColors,
101+
textSizes,
102+
textStyle,
103+
tracking,
104+
userSelect,
105+
verticalAlign,
106+
visibility,
107+
whitespace,
108+
width,
109+
zIndex,
110+
})
106111
}

0 commit comments

Comments
 (0)