// Create a modular font scale. // Returns a nested list of font-size and line-height values. @function ss-make-font-scale( $base-size, $base-line-height, $max-size, $max-line-height, $numb-smaller-sizes: 1, $numb-larger-sizes: 4, $rounding: false ) { // If line-height params are unitless values, // covert to unit values. $base-line-height: if(unitless($base-line-height), $base-size * $base-line-height, $base-line-height); $max-line-height: if(unitless($max-line-height), $max-size * $max-line-height, $max-line-height); // Create font-size and line-height scales $font-size-scale: ss-make-scale($base-size, $max-size, $numb-smaller-sizes, $numb-larger-sizes, $rounding); $line-height-scale: ss-make-scale($base-line-height, $max-line-height, $numb-smaller-sizes, $numb-larger-sizes, $rounding); $font-scale: (); // Pair each size with the correponding font-size // and line-height, then add the size to the scale. @for $i from -$numb-smaller-sizes to $numb-larger-sizes + 1 { // Calculate array position in order to lookup sizes in lists. $arr-position: $i + $numb-smaller-sizes + 1; // Key for size $name-of-size: $i; // Values for size $values: ( font-size: nth($font-size-scale, $arr-position), line-height: nth($line-height-scale, $arr-position) ); // Merge into $font-scale. $font-scale: map-merge($font-scale, ($name-of-size: $values)); } @return $font-scale; }