|
2 | 2 | @use 'sass:math';
|
3 | 3 | @use 'sass:meta';
|
4 | 4 | @use 'sass:string';
|
5 |
| -@use '@material/typography' as mdc-typography; |
6 | 5 |
|
7 | 6 | $_default-font-family: string.unquote('Roboto, sans-serif');
|
8 | 7 |
|
| 8 | +@function _px-to-rem($px) { |
| 9 | + @return math.div($px, 16px) * 1rem; |
| 10 | +} |
| 11 | + |
| 12 | +@function _get-letter-spacing($tracking, $font-size) { |
| 13 | + @return math.div($tracking, $font-size * 16) * 1em; |
| 14 | +} |
| 15 | + |
| 16 | +$_mdc-levels: ( |
| 17 | + headline1: ( |
| 18 | + font-family: $_default-font-family, |
| 19 | + font-size: _px-to-rem(96px), |
| 20 | + line-height: _px-to-rem(96px), |
| 21 | + font-weight: 300, |
| 22 | + letter-spacing: _get-letter-spacing(-1.5, 6), |
| 23 | + text-decoration: inherit, |
| 24 | + text-transform: inherit, |
| 25 | + ), |
| 26 | + headline2: ( |
| 27 | + font-family: $_default-font-family, |
| 28 | + font-size: _px-to-rem(60px), |
| 29 | + line-height: _px-to-rem(60px), |
| 30 | + font-weight: 300, |
| 31 | + letter-spacing: _get-letter-spacing(-0.5, 3.75), |
| 32 | + text-decoration: inherit, |
| 33 | + text-transform: inherit, |
| 34 | + ), |
| 35 | + headline3: ( |
| 36 | + font-family: $_default-font-family, |
| 37 | + font-size: _px-to-rem(48px), |
| 38 | + line-height: _px-to-rem(50px), |
| 39 | + font-weight: 400, |
| 40 | + letter-spacing: normal, |
| 41 | + text-decoration: inherit, |
| 42 | + text-transform: inherit, |
| 43 | + ), |
| 44 | + headline4: ( |
| 45 | + font-family: $_default-font-family, |
| 46 | + font-size: _px-to-rem(34px), |
| 47 | + line-height: _px-to-rem(40px), |
| 48 | + font-weight: 400, |
| 49 | + letter-spacing: _get-letter-spacing(0.25, 2.125), |
| 50 | + text-decoration: inherit, |
| 51 | + text-transform: inherit, |
| 52 | + ), |
| 53 | + headline5: ( |
| 54 | + font-family: $_default-font-family, |
| 55 | + font-size: _px-to-rem(24px), |
| 56 | + line-height: _px-to-rem(32px), |
| 57 | + font-weight: 400, |
| 58 | + letter-spacing: normal, |
| 59 | + text-decoration: inherit, |
| 60 | + text-transform: inherit, |
| 61 | + ), |
| 62 | + headline6: ( |
| 63 | + font-family: $_default-font-family, |
| 64 | + font-size: _px-to-rem(20px), |
| 65 | + line-height: _px-to-rem(32px), |
| 66 | + font-weight: 500, |
| 67 | + letter-spacing: _get-letter-spacing(0.25, 1.25), |
| 68 | + text-decoration: inherit, |
| 69 | + text-transform: inherit, |
| 70 | + ), |
| 71 | + subtitle1: ( |
| 72 | + font-family: $_default-font-family, |
| 73 | + font-size: _px-to-rem(16px), |
| 74 | + line-height: _px-to-rem(28px), |
| 75 | + font-weight: 400, |
| 76 | + letter-spacing: _get-letter-spacing(0.15, 1), |
| 77 | + text-decoration: inherit, |
| 78 | + text-transform: inherit, |
| 79 | + ), |
| 80 | + subtitle2: ( |
| 81 | + font-family: $_default-font-family, |
| 82 | + font-size: _px-to-rem(14px), |
| 83 | + line-height: _px-to-rem(22px), |
| 84 | + font-weight: 500, |
| 85 | + letter-spacing: _get-letter-spacing(0.1, 0.875), |
| 86 | + text-decoration: inherit, |
| 87 | + text-transform: inherit, |
| 88 | + ), |
| 89 | + body1: ( |
| 90 | + font-family: $_default-font-family, |
| 91 | + font-size: _px-to-rem(16px), |
| 92 | + line-height: _px-to-rem(24px), |
| 93 | + font-weight: 400, |
| 94 | + letter-spacing: _get-letter-spacing(0.5, 1), |
| 95 | + text-decoration: inherit, |
| 96 | + text-transform: inherit, |
| 97 | + ), |
| 98 | + body2: ( |
| 99 | + font-family: $_default-font-family, |
| 100 | + font-size: _px-to-rem(14px), |
| 101 | + line-height: _px-to-rem(20px), |
| 102 | + font-weight: 400, |
| 103 | + letter-spacing: _get-letter-spacing(0.25, 0.875), |
| 104 | + text-decoration: inherit, |
| 105 | + text-transform: inherit, |
| 106 | + ), |
| 107 | + caption: ( |
| 108 | + font-family: $_default-font-family, |
| 109 | + font-size: _px-to-rem(12px), |
| 110 | + line-height: _px-to-rem(20px), |
| 111 | + font-weight: 400, |
| 112 | + letter-spacing: _get-letter-spacing(0.4, 0.75), |
| 113 | + text-decoration: inherit, |
| 114 | + text-transform: inherit, |
| 115 | + ), |
| 116 | + button: ( |
| 117 | + font-family: $_default-font-family, |
| 118 | + font-size: _px-to-rem(14px), |
| 119 | + line-height: _px-to-rem(36px), |
| 120 | + font-weight: 500, |
| 121 | + letter-spacing: _get-letter-spacing(1.25, 0.875), |
| 122 | + text-decoration: none, |
| 123 | + text-transform: uppercase, |
| 124 | + ), |
| 125 | + overline: ( |
| 126 | + font-family: $_default-font-family, |
| 127 | + font-size: _px-to-rem(12px), |
| 128 | + line-height: _px-to-rem(32px), |
| 129 | + font-weight: 500, |
| 130 | + letter-spacing: _get-letter-spacing(2, 0.75), |
| 131 | + text-decoration: none, |
| 132 | + text-transform: uppercase, |
| 133 | + ), |
| 134 | +); |
| 135 | + |
9 | 136 | /// Defines a typography level from the Material Design spec.
|
10 | 137 | /// @param {String} $font-size The font-size for this level.
|
11 | 138 | /// @param {String | Number} $line-height The line-height for this level.
|
@@ -217,7 +344,7 @@ $_default-font-family: string.unquote('Roboto, sans-serif');
|
217 | 344 |
|
218 | 345 | // Converts an MDC typography level config to an Angular Material one.
|
219 | 346 | @function typography-config-level-from-mdc($mdc-level, $font-family: null) {
|
220 |
| - $mdc-level-config: map.get(mdc-typography.$styles, $mdc-level); |
| 347 | + $mdc-level-config: map.get($_mdc-levels, $mdc-level); |
221 | 348 |
|
222 | 349 | // Explicitly default the font family to null since we'll apply it globally
|
223 | 350 | // through the `define-typgraphy-config`/`define-legacy-typography-config`.
|
|
0 commit comments