|
| 1 | +@import '@material/typography/variables.import'; |
1 | 2 | @import '../mdc-theming/all-theme';
|
2 | 3 |
|
| 4 | +@function mat-mdc-typography-config( |
| 5 | + $font-family: $mdc-typography-font-family, |
| 6 | + $headline-1: mat-typography-config-level-from-mdc(headline1), |
| 7 | + $headline-2: mat-typography-config-level-from-mdc(headline2), |
| 8 | + $headline-3: mat-typography-config-level-from-mdc(headline3), |
| 9 | + $headline-4: mat-typography-config-level-from-mdc(headline4), |
| 10 | + $headline-5: mat-typography-config-level-from-mdc(headline5), |
| 11 | + $headline-6: mat-typography-config-level-from-mdc(headline6), |
| 12 | + $subtitle-1: mat-typography-config-level-from-mdc(subtitle1), |
| 13 | + $subtitle-2: mat-typography-config-level-from-mdc(subtitle2), |
| 14 | + $body-1: mat-typography-config-level-from-mdc(body1), |
| 15 | + $body-2: mat-typography-config-level-from-mdc(body2), |
| 16 | + $caption: mat-typography-config-level-from-mdc(caption), |
| 17 | + $button: mat-typography-config-level-from-mdc(button), |
| 18 | + $overline: mat-typography-config-level-from-mdc(overline), |
| 19 | +) { |
| 20 | + // Declare an initial map with all of the levels. |
| 21 | + $config: ( |
| 22 | + headline-1: $headline-1, |
| 23 | + headline-2: $headline-2, |
| 24 | + headline-3: $headline-3, |
| 25 | + headline-4: $headline-4, |
| 26 | + headline-5: $headline-5, |
| 27 | + headline-6: $headline-6, |
| 28 | + subtitle-1: $subtitle-1, |
| 29 | + subtitle-2: $subtitle-2, |
| 30 | + body-1: $body-1, |
| 31 | + body-2: $body-2, |
| 32 | + caption: $caption, |
| 33 | + button: $button, |
| 34 | + overline: $overline, |
| 35 | + ); |
| 36 | + |
| 37 | + // Loop through the levels and set the `font-family` of the ones that don't have one to the base. |
| 38 | + // Note that Sass can't modify maps in place, which means that we need to merge and re-assign. |
| 39 | + @each $key, $level in $config { |
| 40 | + @if map-get($level, font-family) == null { |
| 41 | + $new-level: map-merge($level, (font-family: $font-family)); |
| 42 | + $config: map-merge($config, ($key: $new-level)); |
| 43 | + } |
| 44 | + } |
| 45 | + |
| 46 | + // Add the base font family to the config. |
| 47 | + @return map-merge($config, (font-family: $font-family)); |
| 48 | +} |
| 49 | + |
3 | 50 | @mixin angular-material-mdc-typography($config-or-theme: null) {
|
4 | 51 | $config: if(mat-private-is-theme-object($config-or-theme),
|
5 | 52 | mat-get-typography-config($config-or-theme), $config-or-theme);
|
|
0 commit comments