Created
February 13, 2017 16:20
-
-
Save owain-stratton/bcd639bb67d0cb61b9e01c750746c34b to your computer and use it in GitHub Desktop.
A short example of Sass based type scale for front-end projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$baseFont: 1; | |
$fontScale: 1.618; // Golden Ratio | |
$baseLineHeight: 1.4 * $baseFont; | |
$small: $baseFont / $fontScale; | |
$regular: $baseFont; | |
$medium: $baseFont * $fontScale; | |
$large: $medium * $fontScale; | |
$xLarge: $large * $fontScale; | |
$xxLarge: $xLarge * $fontScale; | |
$type-settings: ( | |
sm: #{$small}rem, | |
reg: #{$regular}rem, | |
med: #{$medium}rem, | |
lg: #{$large}rem, | |
xl: #{$xLarge}rem, | |
xxl: #{$xxLarge}rem | |
); | |
@function typeScale($size) { | |
@return map-get($type-settings, $size); | |
} | |
@mixin type($size) { | |
font-size: typeScale($size); | |
} | |
/* | |
Use case example | |
*/ | |
body { | |
@include type(reg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment