|
184 | 184 | /// @param {String} $selector Ancestor selector under which native elements, such as h1, will
|
185 | 185 | /// be styled.
|
186 | 186 | @mixin typography-hierarchy($config-or-theme, $selector: '.mat-typography') {
|
| 187 | + $config: private-typography-to-2018-config(theming.get-typography-config($config-or-theme)); |
| 188 | + |
| 189 | + // Note that it seems redundant to prefix the class rules with the `$selector`, however it's |
| 190 | + // necessary if we want to allow people to overwrite the tag selectors. This is due to |
| 191 | + // selectors like `#{$selector} h1` being more specific than ones like `.mat-title`. |
| 192 | + .mat-h1, |
| 193 | + .mat-headline-5, |
| 194 | + #{$selector} .mat-h1, |
| 195 | + #{$selector} .mat-headline-5, |
| 196 | + #{$selector} h1 { |
| 197 | + @include typography-utils.typography-level($config, headline-5); |
| 198 | + margin: 0 0 16px; |
| 199 | + } |
| 200 | + |
| 201 | + .mat-h2, |
| 202 | + .mat-headline-6, |
| 203 | + #{$selector} .mat-h2, |
| 204 | + #{$selector} .mat-headline-6, |
| 205 | + #{$selector} h2 { |
| 206 | + @include typography-utils.typography-level($config, headline-6); |
| 207 | + margin: 0 0 16px; |
| 208 | + } |
| 209 | + |
| 210 | + .mat-h3, |
| 211 | + .mat-subtitle-1, |
| 212 | + #{$selector} .mat-h3, |
| 213 | + #{$selector} .mat-subtitle-1, |
| 214 | + #{$selector} h3 { |
| 215 | + @include typography-utils.typography-level($config, subtitle-1); |
| 216 | + margin: 0 0 16px; |
| 217 | + } |
| 218 | + |
| 219 | + .mat-h4, |
| 220 | + .mat-body-1, |
| 221 | + #{$selector} .mat-h4, |
| 222 | + #{$selector} .mat-body-1, |
| 223 | + #{$selector} h4 { |
| 224 | + @include typography-utils.typography-level($config, body-1); |
| 225 | + margin: 0 0 16px; |
| 226 | + } |
| 227 | + |
| 228 | + // Note: the spec doesn't have anything that would correspond to h5 and h6, but we add these for |
| 229 | + // consistency. The font sizes come from the Chrome user agent styles which have h5 at 0.83em |
| 230 | + // and h6 at 0.67em. |
| 231 | + .mat-h5, |
| 232 | + #{$selector} .mat-h5, |
| 233 | + #{$selector} h5 { |
| 234 | + @include typography-utils.font-shorthand( |
| 235 | + // calc is used here to support css variables |
| 236 | + calc(#{typography-utils.font-size($config, body-2)} * 0.83), |
| 237 | + typography-utils.font-weight($config, body-2), |
| 238 | + typography-utils.line-height($config, body-2), |
| 239 | + typography-utils.font-family($config, body-2) |
| 240 | + ); |
| 241 | + |
| 242 | + margin: 0 0 12px; |
| 243 | + } |
| 244 | + |
| 245 | + .mat-h6, |
| 246 | + #{$selector} .mat-h6, |
| 247 | + #{$selector} h6 { |
| 248 | + @include typography-utils.font-shorthand( |
| 249 | + // calc is used here to support css variables |
| 250 | + calc(#{typography-utils.font-size($config, body-2)} * 0.67), |
| 251 | + typography-utils.font-weight($config, body-2), |
| 252 | + typography-utils.line-height($config, body-2), |
| 253 | + typography-utils.font-family($config, body-2) |
| 254 | + ); |
| 255 | + |
| 256 | + margin: 0 0 12px; |
| 257 | + } |
| 258 | + |
| 259 | + .mat-body-strong, |
| 260 | + .mat-subtitle-2, |
| 261 | + #{$selector} .mat-body-strong, |
| 262 | + #{$selector} .mat-subtitle-2 { |
| 263 | + @include typography-utils.typography-level($config, subtitle-2); |
| 264 | + } |
| 265 | + |
| 266 | + .mat-body, |
| 267 | + .mat-body-2, |
| 268 | + #{$selector} .mat-body, |
| 269 | + #{$selector} .mat-body-2, |
| 270 | + #{$selector} { |
| 271 | + @include typography-utils.typography-level($config, body-2); |
| 272 | + |
| 273 | + p { |
| 274 | + margin: 0 0 12px; |
| 275 | + } |
| 276 | + } |
| 277 | + |
| 278 | + .mat-small, |
| 279 | + .mat-caption, |
| 280 | + #{$selector} .mat-small, |
| 281 | + #{$selector} .mat-caption { |
| 282 | + @include typography-utils.typography-level($config, caption); |
| 283 | + } |
| 284 | + |
| 285 | + .mat-headline-1, |
| 286 | + #{$selector} .mat-headline-1 { |
| 287 | + @include typography-utils.typography-level($config, headline-1); |
| 288 | + margin: 0 0 56px; |
| 289 | + } |
| 290 | + |
| 291 | + .mat-headline-2, |
| 292 | + #{$selector} .mat-headline-2 { |
| 293 | + @include typography-utils.typography-level($config, headline-2); |
| 294 | + margin: 0 0 64px; |
| 295 | + } |
| 296 | + |
| 297 | + .mat-headline-3, |
| 298 | + #{$selector} .mat-headline-3 { |
| 299 | + @include typography-utils.typography-level($config, headline-3); |
| 300 | + margin: 0 0 64px; |
| 301 | + } |
| 302 | + |
| 303 | + .mat-headline-4, |
| 304 | + #{$selector} .mat-headline-4 { |
| 305 | + @include typography-utils.typography-level($config, headline-4); |
| 306 | + margin: 0 0 64px; |
| 307 | + } |
| 308 | +} |
| 309 | + |
| 310 | +/// Emits baseline typographic styles based on a given config. |
| 311 | +/// @param {Map} $config-or-theme A typography config for an entire theme. |
| 312 | +/// @param {String} $selector Ancestor selector under which native elements, such as h1, will |
| 313 | +/// be styled. |
| 314 | +/// @deprecated Use `mat.typography-hierarchy` instead. See https://material.angular.io/guide/mdc-migration for information about migrating. |
| 315 | +/// @breaking-change 17.0.0 |
| 316 | +@mixin legacy-typography-hierarchy($config-or-theme, $selector: '.mat-typography') { |
187 | 317 | $config: private-typography-to-2014-config(theming.get-typography-config($config-or-theme));
|
188 | 318 |
|
189 | 319 | // Note that it seems redundant to prefix the class rules with the `$selector`, however it's
|
|
0 commit comments