|
| 1 | +@use 'sass:map'; |
1 | 2 | @use '@material/icon-button/icon-button' as mdc-icon-button;
|
2 | 3 | @use '@material/icon-button/icon-button-theme' as mdc-icon-button-theme;
|
3 | 4 | @use '@material/theme/custom-properties' as mdc-custom-properties;
|
|
18 | 19 |
|
19 | 20 | .mat-mdc-icon-button {
|
20 | 21 | // Add the official slots for the MDC component.
|
21 |
| - @include mdc-icon-button-theme.theme-styles($token-slots); |
| 22 | + @include mdc-icon-button-theme.theme-styles(map.merge($token-slots, ( |
| 23 | + // Exclude the state layer size since we'll re-emit it below with a default value. |
| 24 | + state-layer-size: null, |
| 25 | + ))); |
22 | 26 | }
|
23 | 27 | }
|
24 | 28 |
|
25 | 29 | .mat-mdc-icon-button {
|
26 |
| - // Not all applications import the theming which would apply a default padding. |
27 |
| - // TODO: Determine how to enforce theming exists, otherwise padding will be unset. |
28 |
| - padding: 12px; |
29 |
| - |
30 | 30 | // Border radius is inherited by ripple to know its shape. Set to 50% so the ripple is round.
|
31 | 31 | border-radius: 50%;
|
32 | 32 |
|
|
42 | 42 |
|
43 | 43 | @include token-utils.use-tokens(
|
44 | 44 | tokens-mdc-icon-button.$prefix, tokens-mdc-icon-button.get-token-slots()) {
|
| 45 | + $button-size: var(#{token-utils.get-token-variable(state-layer-size)}, 48px); |
| 46 | + $icon-size: var(#{token-utils.get-token-variable(icon-size)}, 24px); |
| 47 | + |
| 48 | + // We emit these tokens ourselves here so we can provide a default value. |
| 49 | + // This avoids a lot internal breakages in apps that didn't include the icon button theme. |
| 50 | + width: $button-size; |
| 51 | + height: $button-size; |
| 52 | + |
| 53 | + // Note: this is wrapped in an interpolation, because of an internal lint rule that bans |
| 54 | + // interpolations in `calc`, even though this is the only way to achieve what we're looking for. |
| 55 | + padding: #{calc(#{calc(#{$button-size} - #{$icon-size})} / 2)}; |
| 56 | + |
45 | 57 | // Icon size used to be placed on the host element. Now, in `theme-styles` it is placed on
|
46 | 58 | // the unused `.mdc-button__icon` class. Explicitly set the font-size here.
|
47 | 59 | @include token-utils.create-token-slot(font-size, icon-size);
|
|
0 commit comments