Skip to content

fix(typography): handle inherit being set as a typography value #8721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: the funky formatting here is due to Stylelint complaining about having to have a newline after the brace.

// 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;
}
}