Skip to content

Commit 4a4980d

Browse files
committed
fix(typography): handle inherit being set as a typography value
Fixes the `mat-typography-level-to-styles` mixin generating an invalid style declaration if any of its value are set to `inherit`. Fixes #8700.
1 parent 9e35bf0 commit 4a4980d

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

src/lib/core/typography/_typography-utils.scss

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,22 @@
3636
$line-height: mat-line-height($config, $level);
3737
$font-family: mat-font-family($config, $level);
3838

39-
// Use the shorthand `font` to represent a typography level, because it's the shortest. Notes that
40-
// we need to use interpolation for `font-size/line-height` in order to prevent SASS from dividing
41-
// the two values.
42-
font: $font-weight #{$font-size}/#{$line-height} $font-family;
39+
// If any of the values are set to `inherit`, we can't use the shorthand
40+
// so we fall back to passing in the individual properties.
41+
@if ($font-size == inherit or
42+
$font-weight == inherit or
43+
$line-height == inherit or
44+
$font-family == inherit) {
45+
46+
font-size: $font-size;
47+
font-weight: $font-weight;
48+
line-height: $line-height;
49+
font-family: $font-family;
50+
}
51+
@else {
52+
// Otherwise use the shorthand `font` to represent a typography level, because it's the the
53+
// least amount of bytes. Note that we need to use interpolation for `font-size/line-height`
54+
// in order to prevent SASS from dividing the two values.
55+
font: $font-weight #{$font-size}/#{$line-height} $font-family;
56+
}
4357
}

0 commit comments

Comments
 (0)