|
18 | 18 | @use '../style/elevation';
|
19 | 19 | @use '../theming/config-validation';
|
20 | 20 | @use '../theming/definition';
|
| 21 | +@use '../theming/inspection'; |
21 | 22 | @use '../theming/m2-inspection';
|
22 | 23 | @use '../theming/palettes';
|
23 | 24 | @use '../style/sass-utils';
|
|
322 | 323 | // Unlike M3's `mat.theme()`, this mixin does not replace the need to call
|
323 | 324 | // individual component theme mixins for Angular Material components.
|
324 | 325 | @mixin m2-theme($theme-config, $overrides: ()) {
|
| 326 | + @if inspection.get-theme-version($theme-config) == 1 { |
| 327 | + @error '`m2-theme` mixin should only be called for M2 theme ' + |
| 328 | + 'configs created with define-light-theme or define-dark-theme'; |
| 329 | + } |
| 330 | + |
325 | 331 | $config: m2-inspection.get-m2-config($theme-config);
|
326 | 332 |
|
327 | 333 | $color: map.get($config, color);
|
|
350 | 356 |
|
351 | 357 | @include _define-m2-system-vars(m2.md-sys-shape-values(), $overrides);
|
352 | 358 | @include _define-m2-system-vars(m2.md-sys-state-values(), $overrides);
|
| 359 | + |
| 360 | + // The icon button's color token is set to `inherit` for M2 and intended to display |
| 361 | + // the color inherited from its parent element. This is crucial because it's unknown |
| 362 | + // whether the icon button sits on a container with background like "surface" or "primary", |
| 363 | + // where both may have different contrast colors like white or black. |
| 364 | + // However, variables set to inherit AND define a fallback will always use the fallback, |
| 365 | + // which is "on-surface-variant". This mixin now defines this value. |
| 366 | + // To avoid this, and continue using `inherit` for the icon button color, set the color explicitly |
| 367 | + // to the token without a fallback. |
| 368 | + .mat-mdc-button-base.mat-mdc-icon-button:not(.mat-mdc-button-disabled) { |
| 369 | + color: var(--mat-icon-button-icon-color); |
| 370 | + } |
353 | 371 | }
|
354 | 372 |
|
355 | 373 | @mixin _define-m2-system-vars($vars, $overrides) {
|
|
0 commit comments