Skip to content

Commit

Permalink
fix(typography): handle inherit being set as a typography value
Browse files Browse the repository at this point in the history
Fixes the `mat-typography-level-to-styles` mixin generating an invalid style declaration if any of its value are set to `inherit`.

Fixes angular#8700.
  • Loading branch information
crisbeto committed Nov 30, 2017
1 parent 9e35bf0 commit 4a4980d
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/lib/core/typography/_typography-utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,22 @@
$line-height: mat-line-height($config, $level);
$font-family: mat-font-family($config, $level);

// Use the shorthand `font` to represent a typography level, because it's the shortest. Notes that
// we need to use interpolation for `font-size/line-height` in order to prevent SASS from dividing
// the two values.
font: $font-weight #{$font-size}/#{$line-height} $font-family;
// If any of the values are set to `inherit`, we can't use the shorthand
// so we fall back to passing in the individual properties.
@if ($font-size == inherit or
$font-weight == inherit or
$line-height == inherit or
$font-family == inherit) {

font-size: $font-size;
font-weight: $font-weight;
line-height: $line-height;
font-family: $font-family;
}
@else {
// Otherwise use the shorthand `font` to represent a typography level, because it's the the
// least amount of bytes. Note that we need to use interpolation for `font-size/line-height`
// in order to prevent SASS from dividing the two values.
font: $font-weight #{$font-size}/#{$line-height} $font-family;
}
}

0 comments on commit 4a4980d

Please sign in to comment.