Skip to content

Commit

Permalink
Remove magic for modularScales api
Browse files Browse the repository at this point in the history
Explicitly set scale + maxWidth instead of string, correctly ordered
array magic.
  • Loading branch information
KyleAMathews committed Aug 13, 2015
1 parent fa49001 commit d899aa5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
9 changes: 7 additions & 2 deletions src/index.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ module.exports = test = (options) ->
baseFontSize: '18px'
baseLineHeight: '28.5px'
modularScales: [
'diminished fourth'
['768px', 'minor third']
{
scale: 'diminished fourth'
},
{
maxWidth: '768px'
scale: 'minor third'
}
]
googleFonts: []
headerFontFamily: '"Avenir Next", "Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif'
Expand Down
12 changes: 4 additions & 8 deletions src/utils/createStyles.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,8 @@ generateHeaderStyles = (vr, options) ->
baseFontSize = options.baseFontSize.slice(0, -2)

for modularScale in options.modularScales
if isString modularScale
maxWidth = false
scale = modularScale
else
maxWidth = "@media only screen and (max-width: #{modularScale[0]}) {\n"
scale = modularScale[1]
maxWidth = modularScale.maxWidth
scale = modularScale.scale

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

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


styles += createStyle([
Expand Down Expand Up @@ -110,7 +106,7 @@ generateHeaderStyles = (vr, options) ->
""")

if maxWidth
styles += "}\n"
styles += "}"

return styles

Expand Down

0 comments on commit d899aa5

Please sign in to comment.