/****************************************************** * MIXINS ******************************************************/ // Apply styles for a specific font, breakpoint, and size. @mixin td-apply-font-styles($font, $size, $scale-name, $opts: ()) { // Extend default opts $opts: map-merge(( "uppercase": false, "line-height": "normal" ), $opts); // FONT SIZE // Get and apply adjustments. $unadjusted-font-size: map-deep-get($typography, $scale-name, "sizes", $size, "font-size"); $font-size-adjustment: map-get($font, "font-size-adjustment") or 1.00; $uppercase-adjustment: map-get($font, "uppercase-adjustment") or 1.00; @if map-get($opts, "uppercase") { $font-size-adjustment: $font-size-adjustment * $uppercase-adjustment; } $font-size: $unadjusted-font-size * $font-size-adjustment; // Round font-size. $font-size-precision: map-deep-get($typography, $scale-name, "font-size-precision") or null; @if ($font-size-precision) { $font-size: td-round($font-size, $font-size-precision); } // LINE HEIGHT // Get and apply adjustments. $line-height-setting: map-get($opts, "line-height"); $unadjusted-line-height: null; $line-height: null; // Use line-height associated with scale and size. $normal-line-height: map-deep-get($typography, $scale-name, "sizes", $size, "line-height"); // No space between lines. 1.0 if unitless, otherwise equal to font-size. $solid-line-height: if(unitless($normal-line-height), 1.0, $font-size); // Halfway between default and solid line-height. $tight-line-height: (($normal-line-height - $solid-line-height) / 2) + $solid-line-height; // If line-height is set to solid, use 1.0 or font-size. @if $line-height-setting == "solid" { $line-height: $solid-line-height; } @else { // Line-height setting determines corresponding basis. @if $line-height-setting == "tight" { $unadjusted-line-height: $tight-line-height; } @else { $unadjusted-line-height: $normal-line-height; } // Apply adjustments. $line-height-adjustment: map-get($font, "line-height-adjustment") or 1.00; // If using relative line heights, the font-size-adjustment will // affect the line-height. This removes the unwanted effect. @if unitless($unadjusted-line-height) { $line-height-adjustment: $line-height-adjustment * (1 / $font-size-adjustment); } $line-height: $unadjusted-line-height * $line-height-adjustment; } // Round line-height. $line-height-precision: map-deep-get($typography, $scale-name, "line-height-precision") or null; @if ($line-height-precision) { $line-height: td-round($line-height, $line-height-precision); } font-size: $font-size; line-height: $line-height; } // Apply non-responsive styling. Only the size used for // the specified media query will be applied. @mixin td-set-font-size($font, $size, $scale-name, $opts: ()) { // Extend default opts $opts: map-merge(( "uppercase": false, "line-height": "normal" ), $opts); font-family: map-get($font, "family"); @if map-get($opts, "uppercase") { text-transform: uppercase; } @include td-apply-font-styles($font, $size, $scale-name, $opts); } // Apply responsive styling. Corresponding sizes for // each media query will be applied. @mixin td-set-responsive-font-size($font, $size: 0, $opts: ()) { // Extend default opts $opts: map-merge(( "uppercase": false, "line-height": "normal" ), $opts); font-family: map-get($font, "family"); @if map-get($opts, "uppercase") { text-transform: uppercase; } @each $scale-name, $scale-value in $typography { // For the default styles, don't include a media query. @if $scale-name == "default" { @include td-apply-font-styles($font, $size, $scale-name, $opts); } // For other breakpoints, set style with a media query. @else { $media-query: map-deep-get($typography, $scale-name, "media-query"); @media #{$media-query} { @include td-apply-font-styles($font, $size, $scale-name, $opts); } } } }