Skip to content

Commit d899aa5

Browse files
committed
Remove magic for modularScales api
Explicitly set scale + maxWidth instead of string, correctly ordered array magic.
1 parent fa49001 commit d899aa5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

src/index.coffee

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ module.exports = test = (options) ->
1313
baseFontSize: '18px'
1414
baseLineHeight: '28.5px'
1515
modularScales: [
16-
'diminished fourth'
17-
['768px', 'minor third']
16+
{
17+
scale: 'diminished fourth'
18+
},
19+
{
20+
maxWidth: '768px'
21+
scale: 'minor third'
22+
}
1823
]
1924
googleFonts: []
2025
headerFontFamily: '"Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif'

src/utils/createStyles.coffee

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ generateHeaderStyles = (vr, options) ->
4848
baseFontSize = options.baseFontSize.slice(0, -2)
4949

5050
for modularScale in options.modularScales
51-
if isString modularScale
52-
maxWidth = false
53-
scale = modularScale
54-
else
55-
maxWidth = "@media only screen and (max-width: #{modularScale[0]}) {\n"
56-
scale = modularScale[1]
51+
maxWidth = modularScale.maxWidth
52+
scale = modularScale.scale
5753

5854
h1 = vr.adjustFontSizeTo(ms(3, scale) * baseFontSize + "px")
5955
h2 = vr.adjustFontSizeTo(ms(2, scale) * baseFontSize + "px")
@@ -63,7 +59,7 @@ generateHeaderStyles = (vr, options) ->
6359
h6 = vr.adjustFontSizeTo(ms(0, scale) * baseFontSize + "px")
6460

6561
if maxWidth
66-
styles += maxWidth
62+
styles += "@media only screen and (max-width: #{maxWidth}) {\n"
6763

6864

6965
styles += createStyle([
@@ -110,7 +106,7 @@ generateHeaderStyles = (vr, options) ->
110106
""")
111107

112108
if maxWidth
113-
styles += "}\n"
109+
styles += "}"
114110

115111
return styles
116112

0 commit comments

Comments
 (0)