From db83f0648d283c0f3973a84a71339e20a9dac68f Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Mon, 16 Nov 2020 10:23:07 -0800 Subject: [PATCH 1/2] fix(material/core): add typography config normalization function Future PRs will adopt this function in the typography mixins for our components --- src/material/core/typography/_typography.scss | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/material/core/typography/_typography.scss b/src/material/core/typography/_typography.scss index 5469254c2d9d..a60d8640978c 100644 --- a/src/material/core/typography/_typography.scss +++ b/src/material/core/typography/_typography.scss @@ -69,6 +69,37 @@ @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) { + @if map-get($config, headline-1) { + @return true; + } + @return false; +} + +// 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') { From 696e929a656ca1e35b7797015b31c6e8b0ac6970 Mon Sep 17 00:00:00 2001 From: Miles Malerba Date: Wed, 25 Nov 2020 14:31:32 -0800 Subject: [PATCH 2/2] fixup! fix(material/core): add typography config normalization function --- src/material/core/typography/_typography.scss | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/material/core/typography/_typography.scss b/src/material/core/typography/_typography.scss index a60d8640978c..e2e3151373a5 100644 --- a/src/material/core/typography/_typography.scss +++ b/src/material/core/typography/_typography.scss @@ -71,10 +71,7 @@ // Whether a config is for the Material Design 2018 typography system. @function mat-private-typography-is-2018-config($config) { - @if map-get($config, headline-1) { - @return true; - } - @return false; + @return map-get($config, headline-1) != null; } // Given a config for either the 2014 or 2018 Material Design typography system,