|
1 | 1 | @use 'sass:map';
|
2 | 2 | @use 'sass:math';
|
3 | 3 | @use 'sass:meta';
|
4 |
| -@use '@material/typography' as mdc-typography; |
5 | 4 | @use './typography';
|
6 | 5 | @use '../../autocomplete/autocomplete-theme';
|
7 | 6 | @use '../../badge/badge-theme';
|
|
88 | 87 | @function define-typography-config(
|
89 | 88 | // TODO(mmalerba): rename this function to define-typography-config,
|
90 | 89 | // and create a predefined px based config for people that need it.
|
91 |
| - $font-family: mdc-typography.$font-family, |
92 |
| - $headline-1: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(headline1)), |
93 |
| - $headline-2: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(headline2)), |
94 |
| - $headline-3: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(headline3)), |
95 |
| - $headline-4: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(headline4)), |
96 |
| - $headline-5: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(headline5)), |
97 |
| - $headline-6: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(headline6)), |
98 |
| - $subtitle-1: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(subtitle1)), |
99 |
| - $subtitle-2: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(subtitle2)), |
100 |
| - $body-1: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(body1)), |
101 |
| - $body-2: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(body2)), |
102 |
| - $caption: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(caption)), |
103 |
| - $button: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(button)), |
104 |
| - $overline: _rem-to-px(mdc-helpers.typography-config-level-from-mdc(overline)), |
| 90 | + $font-family: null, |
| 91 | + $headline-1: null, |
| 92 | + $headline-2: null, |
| 93 | + $headline-3: null, |
| 94 | + $headline-4: null, |
| 95 | + $headline-5: null, |
| 96 | + $headline-6: null, |
| 97 | + $subtitle-1: null, |
| 98 | + $subtitle-2: null, |
| 99 | + $body-1: null, |
| 100 | + $body-2: null, |
| 101 | + $caption: null, |
| 102 | + $button: null, |
| 103 | + $overline: null, |
105 | 104 | ) {
|
106 | 105 | // Declare an initial map with all of the levels.
|
107 |
| - $config: ( |
108 |
| - headline-1: $headline-1, |
109 |
| - headline-2: $headline-2, |
110 |
| - headline-3: $headline-3, |
111 |
| - headline-4: $headline-4, |
112 |
| - headline-5: $headline-5, |
113 |
| - headline-6: $headline-6, |
114 |
| - subtitle-1: $subtitle-1, |
115 |
| - subtitle-2: $subtitle-2, |
116 |
| - body-1: $body-1, |
117 |
| - body-2: $body-2, |
118 |
| - caption: $caption, |
119 |
| - button: $button, |
120 |
| - overline: $overline, |
121 |
| - ); |
| 106 | + $overrides: if($font-family, (font-family: $font-family), ()); |
122 | 107 |
|
123 |
| - // Loop through the levels and set the `font-family` of the ones that don't have one to the base. |
124 |
| - // Note that Sass can't modify maps in place, which means that we need to merge and re-assign. |
125 |
| - @each $key, $level in $config { |
126 |
| - @if map.get($level, font-family) == null { |
127 |
| - $new-level: map.merge($level, (font-family: $font-family)); |
128 |
| - $config: map.merge($config, ($key: $new-level)); |
129 |
| - } |
130 |
| - } |
131 |
| - |
132 |
| - // Add the base font family to the config. |
133 |
| - @return map.merge($config, (font-family: $font-family)); |
| 108 | + @return ( |
| 109 | + headline-1: $headline-1 or _rem-to-px( |
| 110 | + mdc-helpers.typography-config-level-from-mdc(headline1, $overrides)), |
| 111 | + headline-2: $headline-2 or _rem-to-px( |
| 112 | + mdc-helpers.typography-config-level-from-mdc(headline2, $overrides)), |
| 113 | + headline-3: $headline-3 or _rem-to-px( |
| 114 | + mdc-helpers.typography-config-level-from-mdc(headline3, $overrides)), |
| 115 | + headline-4: $headline-4 or _rem-to-px( |
| 116 | + mdc-helpers.typography-config-level-from-mdc(headline4, $overrides)), |
| 117 | + headline-5: $headline-5 or _rem-to-px( |
| 118 | + mdc-helpers.typography-config-level-from-mdc(headline5, $overrides)), |
| 119 | + headline-6: $headline-6 or _rem-to-px( |
| 120 | + mdc-helpers.typography-config-level-from-mdc(headline6, $overrides)), |
| 121 | + subtitle-1: $subtitle-1 or _rem-to-px( |
| 122 | + mdc-helpers.typography-config-level-from-mdc(subtitle1, $overrides)), |
| 123 | + subtitle-2: $subtitle-2 or _rem-to-px( |
| 124 | + mdc-helpers.typography-config-level-from-mdc(subtitle2, $overrides)), |
| 125 | + body-1: $body-1 or _rem-to-px( |
| 126 | + mdc-helpers.typography-config-level-from-mdc(body1, $overrides)), |
| 127 | + body-2: $body-2 or _rem-to-px( |
| 128 | + mdc-helpers.typography-config-level-from-mdc(body2, $overrides)), |
| 129 | + caption: $caption or _rem-to-px( |
| 130 | + mdc-helpers.typography-config-level-from-mdc(caption, $overrides)), |
| 131 | + button: $button or _rem-to-px( |
| 132 | + mdc-helpers.typography-config-level-from-mdc(button, $overrides)), |
| 133 | + overline: $overline or _rem-to-px( |
| 134 | + mdc-helpers.typography-config-level-from-mdc(overline, $overrides)), |
| 135 | + ); |
134 | 136 | }
|
135 | 137 |
|
136 | 138 | /// Generates an Angular Material typography config based on values from the official Material
|
|
158 | 160 | @function define-rem-typography-config(
|
159 | 161 | // TODO(mmalerba): rename this function to define-typography-config,
|
160 | 162 | // and create a predefined px based config for people that need it.
|
161 |
| - $font-family: mdc-typography.$font-family, |
162 |
| - $headline-1: mdc-helpers.typography-config-level-from-mdc(headline1), |
163 |
| - $headline-2: mdc-helpers.typography-config-level-from-mdc(headline2), |
164 |
| - $headline-3: mdc-helpers.typography-config-level-from-mdc(headline3), |
165 |
| - $headline-4: mdc-helpers.typography-config-level-from-mdc(headline4), |
166 |
| - $headline-5: mdc-helpers.typography-config-level-from-mdc(headline5), |
167 |
| - $headline-6: mdc-helpers.typography-config-level-from-mdc(headline6), |
168 |
| - $subtitle-1: mdc-helpers.typography-config-level-from-mdc(subtitle1), |
169 |
| - $subtitle-2: mdc-helpers.typography-config-level-from-mdc(subtitle2), |
170 |
| - $body-1: mdc-helpers.typography-config-level-from-mdc(body1), |
171 |
| - $body-2: mdc-helpers.typography-config-level-from-mdc(body2), |
172 |
| - $caption: mdc-helpers.typography-config-level-from-mdc(caption), |
173 |
| - $button: mdc-helpers.typography-config-level-from-mdc(button), |
174 |
| - $overline: mdc-helpers.typography-config-level-from-mdc(overline), |
| 163 | + $font-family: null, |
| 164 | + $headline-1: null, |
| 165 | + $headline-2: null, |
| 166 | + $headline-3: null, |
| 167 | + $headline-4: null, |
| 168 | + $headline-5: null, |
| 169 | + $headline-6: null, |
| 170 | + $subtitle-1: null, |
| 171 | + $subtitle-2: null, |
| 172 | + $body-1: null, |
| 173 | + $body-2: null, |
| 174 | + $caption: null, |
| 175 | + $button: null, |
| 176 | + $overline: null, |
175 | 177 | ) {
|
176 | 178 | // Declare an initial map with all of the levels.
|
177 |
| - $config: ( |
178 |
| - headline-1: $headline-1, |
179 |
| - headline-2: $headline-2, |
180 |
| - headline-3: $headline-3, |
181 |
| - headline-4: $headline-4, |
182 |
| - headline-5: $headline-5, |
183 |
| - headline-6: $headline-6, |
184 |
| - subtitle-1: $subtitle-1, |
185 |
| - subtitle-2: $subtitle-2, |
186 |
| - body-1: $body-1, |
187 |
| - body-2: $body-2, |
188 |
| - caption: $caption, |
189 |
| - button: $button, |
190 |
| - overline: $overline, |
191 |
| - ); |
| 179 | + $overrides: if($font-family, (font-family: $font-family), ()); |
192 | 180 |
|
193 |
| - // Loop through the levels and set the `font-family` of the ones that don't have one to the base. |
194 |
| - // Note that Sass can't modify maps in place, which means that we need to merge and re-assign. |
195 |
| - @each $key, $level in $config { |
196 |
| - @if map.get($level, font-family) == null { |
197 |
| - $new-level: map.merge($level, (font-family: $font-family)); |
198 |
| - $config: map.merge($config, ($key: $new-level)); |
199 |
| - } |
200 |
| - } |
201 |
| - |
202 |
| - // Add the base font family to the config. |
203 |
| - @return map.merge($config, (font-family: $font-family)); |
| 181 | + @return ( |
| 182 | + headline-1: $headline-1 or mdc-helpers.typography-config-level-from-mdc(headline1, $overrides), |
| 183 | + headline-2: $headline-2 or mdc-helpers.typography-config-level-from-mdc(headline2, $overrides), |
| 184 | + headline-3: $headline-3 or mdc-helpers.typography-config-level-from-mdc(headline3, $overrides), |
| 185 | + headline-4: $headline-4 or mdc-helpers.typography-config-level-from-mdc(headline4, $overrides), |
| 186 | + headline-5: $headline-5 or mdc-helpers.typography-config-level-from-mdc(headline5, $overrides), |
| 187 | + headline-6: $headline-6 or mdc-helpers.typography-config-level-from-mdc(headline6, $overrides), |
| 188 | + subtitle-1: $subtitle-1 or mdc-helpers.typography-config-level-from-mdc(subtitle1, $overrides), |
| 189 | + subtitle-2: $subtitle-2 or mdc-helpers.typography-config-level-from-mdc(subtitle2, $overrides), |
| 190 | + body-1: $body-1 or mdc-helpers.typography-config-level-from-mdc(body1, $overrides), |
| 191 | + body-2: $body-2 or mdc-helpers.typography-config-level-from-mdc(body2, $overrides), |
| 192 | + caption: $caption or mdc-helpers.typography-config-level-from-mdc(caption, $overrides), |
| 193 | + button: $button or mdc-helpers.typography-config-level-from-mdc(button, $overrides), |
| 194 | + overline: $overline or mdc-helpers.typography-config-level-from-mdc(overline, $overrides), |
| 195 | + ); |
204 | 196 | }
|
205 | 197 |
|
206 | 198 | @mixin private-all-unmigrated-component-typographies($config) {
|
|
0 commit comments