Skip to content

feat(material/core): add typography config normalization function #21059

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 2 commits into from
Dec 3, 2020
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
28 changes: 28 additions & 0 deletions src/material/core/typography/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,34 @@
@return map-merge($config, (font-family: $font-family));
}

// Whether a config is for the Material Design 2018 typography system.
@function mat-private-typography-is-2018-config($config) {
@return map-get($config, headline-1) != null;
}

// Given a config for either the 2014 or 2018 Material Design typography system,
// produces a normalized typography config for the 2014 Material Design typography system.
// 2014 - https://material.io/archive/guidelines/style/typography.html#typography-styles
// 2018 - https://material.io/design/typography/the-type-system.html#type-scale
@function mat-typography-normalized-config($config) {
@if mat-private-typography-is-2018-config($config) {
@return mat-typography-config(
$display-3: map-get($config, display-1),
$display-2: map-get($config, display-2),
$display-1: map-get($config, display-3),
$headline: map-get($config, headline-4),
$title: map-get($config, subtitle-1),
$subheading-2: map-get($config, subhead-1),
$subheading-1: map-get($config, subhead-2),
$body-2: map-get($config, body-1),
$body-1: map-get($config, body-2),
$caption: map-get($config, caption),
$button: map-get($config, button),
);
}
@return $config;
}

// Adds the base typography styles, based on a config.
/* stylelint-disable-next-line material/theme-mixin-api */
@mixin mat-base-typography($config, $selector: '.mat-typography') {
Expand Down