22// "theming", "typography", "core".
33
44@use ' ../theming/theming' ;
5+ @use ' ../theming/inspection' ;
56@use ' ../typography/typography' ;
67@use ' ../typography/typography-utils' ;
78@use ' @material/feature-targeting' as mdc-feature-targeting ;
@@ -36,7 +37,7 @@ $mat-typography-mdc-level-mappings: (
3637);
3738
3839// Converts an Angular Material typography level config to an MDC one.
39- @function typography-level-config-to-mdc ($mat-config , $mat-level ) {
40+ @function typography-level-config-to-mdc ($theme , $mat-level ) {
4041 $mdc-level : map .get ($mat-typography-mdc-level-mappings , $mat-level );
4142
4243 $result-with-nulls : map .merge (
@@ -49,11 +50,11 @@ $mat-typography-mdc-level-mappings: (
4950 )),
5051 if ($mat-level ,
5152 (
52- font-size : typography-utils . font-size ( $mat-config , $mat-level ),
53- line-height : typography-utils . line-height ( $mat-config , $mat-level ),
54- font-weight : typography-utils . font-weight ( $mat-config , $mat-level ),
55- letter-spacing : typography-utils . letter-spacing ( $mat-config , $mat-level ),
56- font-family : typography-utils . font-family ( $mat-config , $mat-level ),
53+ font-size : inspection . get-theme-typography ( $theme , $mat-level , font-size ),
54+ line-height : inspection . get-theme-typography ( $theme , $mat-level , line-height ),
55+ font-weight : inspection . get-theme-typography ( $theme , $mat-level , font-weight ),
56+ letter-spacing : inspection . get-theme-typography ( $theme , $mat-level , letter-spacing ),
57+ font-family : inspection . get-theme-typography ( $theme , $mat-level , font-family ),
5758 // Angular Material doesn't use text-transform, so disable it.
5859 text-transform : none ,
5960 ),
@@ -71,13 +72,13 @@ $mat-typography-mdc-level-mappings: (
7172}
7273
7374// Converts an Angular Material typography config to an MDC one.
74- @function typography-config-to-mdc ($mat-config ) {
75+ @function typography-config-to-mdc ($theme ) {
7576 $mdc-config : ();
7677
7778 @each $mat-level , $mdc-level in $mat-typography-mdc-level-mappings {
7879 $mdc-config : map .merge (
7980 $mdc-config ,
80- ($mdc-level : typography-level-config-to-mdc ($mat-config , $mat-level )));
81+ ($mdc-level : typography-level-config-to-mdc ($theme , $mat-level )));
8182 }
8283
8384 @return $mdc-config ;
@@ -100,12 +101,11 @@ $mat-typography-mdc-level-mappings: (
100101
101102// Configures MDC's global variables to reflect the given theme, applies the given styles,
102103// then resets the global variables to prevent unintended side effects.
103- @mixin using-mdc-theme ($config ) {
104- $primary : theming .get-color-from-palette (map .get ($config , primary ));
105- $accent : theming .get-color-from-palette (map .get ($config , accent ));
106- $warn : theming .get-color-from-palette (map .get ($config , warn ));
107- $background-palette : map .get ($config , background );
108- $is-dark : map .get ($config , is-dark );
104+ @mixin using-mdc-theme ($theme ) {
105+ $primary : inspection .get-theme-color ($theme , primary );
106+ $accent : inspection .get-theme-color ($theme , accent );
107+ $warn : inspection .get-theme-color ($theme , warn );
108+ $is-dark : inspection .get-theme-type ($theme ) == dark ;
109109
110110 // Save the original values.
111111 $orig-primary : mdc-theme-color .$primary ;
@@ -126,8 +126,8 @@ $mat-typography-mdc-level-mappings: (
126126 mdc-theme-color .$secondary : $accent ;
127127 mdc-theme-color .$on-secondary :
128128 if (variable-safe-contrast-tone (mdc-theme-color .$secondary , $is-dark ) == ' dark' , #000 , #fff );
129- mdc-theme-color .$background : theming .get-color-from-palette ( $ background-palette , background );
130- mdc-theme-color .$surface : theming .get-color-from-palette ( $ background-palette , card );
129+ mdc-theme-color .$background : inspection .get-theme-color ( $theme , background , background );
130+ mdc-theme-color .$surface : inspection .get-theme-color ( $theme , background , card );
131131 mdc-theme-color .$on-surface :
132132 if (variable-safe-contrast-tone (mdc-theme-color .$surface , $is-dark ) == ' dark' , #000 , #fff );
133133 mdc-theme-color .$error : $warn ;
@@ -193,13 +193,13 @@ $mat-typography-mdc-level-mappings: (
193193
194194// Configures MDC's global variables to reflect the given typography config,
195195// applies the given styles, then resets the global variables to prevent unintended side effects.
196- @mixin using-mdc-typography ($config ) {
196+ @mixin using-mdc-typography ($theme ) {
197197 // Save the original values.
198198 $orig-mdc-typography-styles : mdc-typography .$styles ;
199199
200200 // Set new values based on the given Angular Material typography configuration.
201- @if $config {
202- mdc-typography .$styles : typography-config-to-mdc ($config );
201+ @if inspection . theme-has ( $theme , typography ) {
202+ mdc-typography .$styles : typography-config-to-mdc ($theme );
203203 }
204204
205205 // Apply given rules.
0 commit comments