Skip to content

Commit 98d5a55

Browse files
committed
Apply responsive and hover at the per-module level, in the main generator
1 parent d1828c9 commit 98d5a55

File tree

7 files changed

+79
-93
lines changed

7 files changed

+79
-93
lines changed

src/generators/backgroundColors.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import _ from 'lodash'
22
import defineClass from '../util/defineClass'
3-
import hoverable from '../util/hoverable'
43

54
export default function({ backgroundColors }) {
6-
return hoverable(
7-
_.map(backgroundColors, (color, className) => {
8-
return defineClass(`bg-${className}`, {
9-
'background-color': color,
10-
})
5+
return _.map(backgroundColors, (color, className) => {
6+
return defineClass(`bg-${className}`, {
7+
'background-color': color,
118
})
12-
)
9+
})
1310
}

src/generators/borderColors.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import _ from 'lodash'
22
import defineClass from '../util/defineClass'
3-
import hoverable from '../util/hoverable'
43

54
export default function({ borderColors }) {
6-
return hoverable(
7-
_.map(_.omit(borderColors, 'default'), (color, className) => {
8-
return defineClass(`border-${className}`, {
9-
'border-color': color,
10-
})
5+
return _.map(_.omit(borderColors, 'default'), (color, className) => {
6+
return defineClass(`border-${className}`, {
7+
'border-color': color,
118
})
12-
)
9+
})
1310
}

src/generators/fontWeights.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import _ from 'lodash'
22
import defineClass from '../util/defineClass'
3-
import hoverable from '../util/hoverable'
43

54
export default function({ fontWeights }) {
6-
return hoverable(
7-
_.map(fontWeights, (weight, modifier) => {
8-
return defineClass(`font-${modifier}`, {
9-
'font-weight': `${weight}`,
10-
})
5+
return _.map(fontWeights, (weight, modifier) => {
6+
return defineClass(`font-${modifier}`, {
7+
'font-weight': `${weight}`,
118
})
12-
)
9+
})
1310
}

src/generators/textColors.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import _ from 'lodash'
22
import defineClass from '../util/defineClass'
3-
import hoverable from '../util/hoverable'
43

54
export default function({ textColors }) {
6-
return hoverable(
7-
_.map(textColors, (color, modifier) => {
8-
return defineClass(`text-${modifier}`, {
9-
color,
10-
})
5+
return _.map(textColors, (color, modifier) => {
6+
return defineClass(`text-${modifier}`, {
7+
color,
118
})
12-
)
9+
})
1310
}

src/generators/textStyle.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
11
import defineClasses from '../util/defineClasses'
2-
import hoverable from '../util/hoverable'
32

43
export default function() {
5-
return hoverable(
6-
defineClasses({
7-
italic: { 'font-style': 'italic' },
8-
roman: { 'font-style': 'normal' },
4+
return defineClasses({
5+
italic: { 'font-style': 'italic' },
6+
roman: { 'font-style': 'normal' },
97

10-
uppercase: { 'text-transform': 'uppercase' },
11-
lowercase: { 'text-transform': 'lowercase' },
12-
capitalize: { 'text-transform': 'capitalize' },
13-
'normal-case': { 'text-transform': 'none' },
8+
uppercase: { 'text-transform': 'uppercase' },
9+
lowercase: { 'text-transform': 'lowercase' },
10+
capitalize: { 'text-transform': 'capitalize' },
11+
'normal-case': { 'text-transform': 'none' },
1412

15-
underline: { 'text-decoration': 'underline' },
16-
'line-through': { 'text-decoration': 'line-through' },
17-
'no-underline': { 'text-decoration': 'none' },
13+
underline: { 'text-decoration': 'underline' },
14+
'line-through': { 'text-decoration': 'line-through' },
15+
'no-underline': { 'text-decoration': 'none' },
1816

19-
antialiased: {
20-
'-webkit-font-smoothing': 'antialiased',
21-
'-moz-osx-font-smoothing': 'grayscale',
22-
},
23-
'subpixel-antialiased': {
24-
'-webkit-font-smoothing': 'auto',
25-
'-moz-osx-font-smoothing': 'auto',
26-
},
27-
})
28-
)
17+
antialiased: {
18+
'-webkit-font-smoothing': 'antialiased',
19+
'-moz-osx-font-smoothing': 'grayscale',
20+
},
21+
'subpixel-antialiased': {
22+
'-webkit-font-smoothing': 'auto',
23+
'-moz-osx-font-smoothing': 'auto',
24+
},
25+
})
2926
}

src/lib/generateUtilities.js

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import _ from 'lodash'
22
import postcss from 'postcss'
33
import applyClassPrefix from '../util/applyClassPrefix'
44
import responsive from '../util/responsive'
5+
import hoverable from '../util/hoverable'
56

67
import lists from '../generators/lists'
78
import appearance from '../generators/appearance'
@@ -56,47 +57,47 @@ export default function(config) {
5657
nodes: _.flatten([
5758
// The `lists` module needs to be first to allow overriding the margin and
5859
// padding values that it sets with other utilities.
59-
lists(unwrappedConfig),
60-
appearance(unwrappedConfig),
61-
backgroundColors(unwrappedConfig),
62-
backgroundPosition(unwrappedConfig),
63-
backgroundSize(unwrappedConfig),
64-
borderColors(unwrappedConfig),
65-
borderRadius(unwrappedConfig),
66-
borderStyle(unwrappedConfig),
67-
borderWidths(unwrappedConfig),
68-
cursor(unwrappedConfig),
69-
display(unwrappedConfig),
70-
flexbox(unwrappedConfig),
71-
float(unwrappedConfig),
72-
fonts(unwrappedConfig),
73-
fontWeights(unwrappedConfig),
74-
height(unwrappedConfig),
75-
leading(unwrappedConfig),
76-
margin(unwrappedConfig),
77-
maxHeight(unwrappedConfig),
78-
maxWidth(unwrappedConfig),
79-
minHeight(unwrappedConfig),
80-
minWidth(unwrappedConfig),
81-
negativeMargin(unwrappedConfig),
82-
opacity(unwrappedConfig),
83-
overflow(unwrappedConfig),
84-
padding(unwrappedConfig),
85-
pointerEvents(unwrappedConfig),
86-
position(unwrappedConfig),
87-
resize(unwrappedConfig),
88-
shadows(unwrappedConfig),
89-
textAlign(unwrappedConfig),
90-
textColors(unwrappedConfig),
91-
textSizes(unwrappedConfig),
92-
textStyle(unwrappedConfig),
93-
tracking(unwrappedConfig),
94-
userSelect(unwrappedConfig),
95-
verticalAlign(unwrappedConfig),
96-
visibility(unwrappedConfig),
97-
whitespace(unwrappedConfig),
98-
width(unwrappedConfig),
99-
zIndex(unwrappedConfig),
60+
responsive(lists(unwrappedConfig)),
61+
responsive(appearance(unwrappedConfig)),
62+
responsive(hoverable(backgroundColors(unwrappedConfig))),
63+
responsive(backgroundPosition(unwrappedConfig)),
64+
responsive(backgroundSize(unwrappedConfig)),
65+
responsive(hoverable(borderColors(unwrappedConfig))),
66+
responsive(borderRadius(unwrappedConfig)),
67+
responsive(borderStyle(unwrappedConfig)),
68+
responsive(borderWidths(unwrappedConfig)),
69+
responsive(cursor(unwrappedConfig)),
70+
responsive(display(unwrappedConfig)),
71+
responsive(flexbox(unwrappedConfig)),
72+
responsive(float(unwrappedConfig)),
73+
responsive(fonts(unwrappedConfig)),
74+
responsive(hoverable(fontWeights(unwrappedConfig))),
75+
responsive(height(unwrappedConfig)),
76+
responsive(leading(unwrappedConfig)),
77+
responsive(margin(unwrappedConfig)),
78+
responsive(maxHeight(unwrappedConfig)),
79+
responsive(maxWidth(unwrappedConfig)),
80+
responsive(minHeight(unwrappedConfig)),
81+
responsive(minWidth(unwrappedConfig)),
82+
responsive(negativeMargin(unwrappedConfig)),
83+
responsive(opacity(unwrappedConfig)),
84+
responsive(overflow(unwrappedConfig)),
85+
responsive(padding(unwrappedConfig)),
86+
responsive(pointerEvents(unwrappedConfig)),
87+
responsive(position(unwrappedConfig)),
88+
responsive(resize(unwrappedConfig)),
89+
responsive(shadows(unwrappedConfig)),
90+
responsive(textAlign(unwrappedConfig)),
91+
responsive(hoverable(textColors(unwrappedConfig))),
92+
responsive(textSizes(unwrappedConfig)),
93+
responsive(hoverable(textStyle(unwrappedConfig))),
94+
responsive(tracking(unwrappedConfig)),
95+
responsive(userSelect(unwrappedConfig)),
96+
responsive(verticalAlign(unwrappedConfig)),
97+
responsive(visibility(unwrappedConfig)),
98+
responsive(whitespace(unwrappedConfig)),
99+
responsive(width(unwrappedConfig)),
100+
responsive(zIndex(unwrappedConfig)),
100101
]),
101102
})
102103

@@ -105,7 +106,7 @@ export default function(config) {
105106
}
106107

107108
const tailwindClasses = postcss.root({
108-
nodes: [...container(unwrappedConfig), responsive(utilities)],
109+
nodes: [...container(unwrappedConfig), ...utilities.nodes],
109110
})
110111

111112
applyClassPrefix(tailwindClasses, _.get(unwrappedConfig, 'options.prefix', ''))

src/util/responsive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export default function responsive(rules) {
77
.atRule({
88
name: 'responsive',
99
})
10-
.append(cloneNodes(_.isArray(rules) ? rules : rules.nodes))
10+
.append(cloneNodes(_.isArray(rules) ? rules : [rules]))
1111
}

0 commit comments

Comments
 (0)