|
1 | | -@use 'sass:map'; |
2 | | -@use '@material/icon-button/icon-button' as mdc-icon-button; |
3 | | -@use '@material/icon-button/icon-button-theme' as mdc-icon-button-theme; |
4 | | -@use '@material/theme/custom-properties' as mdc-custom-properties; |
5 | | - |
6 | 1 | @use '../core/tokens/m2/mdc/icon-button' as tokens-mdc-icon-button; |
7 | 2 | @use '../core/tokens/m2/mat/icon-button' as tokens-mat-icon-button; |
8 | 3 |
|
9 | 4 | @use './button-base'; |
10 | 5 | @use '../core/style/private'; |
| 6 | +@use '../core/style/vendor-prefixes'; |
11 | 7 | @use '../core/tokens/token-utils'; |
12 | 8 |
|
13 | | -// The slots for tokens that will be configured in the theme can be emitted with no fallback. |
14 | | -@include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) { |
15 | | - $token-slots: tokens-mdc-icon-button.get-token-slots(); |
16 | | - |
17 | | - // Add the MDC component static styles. |
18 | | - @include mdc-icon-button.static-styles(); |
19 | | - |
20 | | - .mat-mdc-icon-button { |
21 | | - // Add the official slots for the MDC component. |
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 | | - ))); |
26 | | - } |
27 | | -} |
28 | 9 |
|
29 | 10 | .mat-mdc-icon-button { |
| 11 | + @include vendor-prefixes.user-select(none); |
| 12 | + display: inline-block; |
| 13 | + position: relative; |
| 14 | + box-sizing: border-box; |
| 15 | + border: none; |
| 16 | + outline: none; |
| 17 | + background-color: transparent; |
| 18 | + fill: currentColor; |
| 19 | + color: inherit; |
| 20 | + text-decoration: none; |
| 21 | + cursor: pointer; |
| 22 | + z-index: 0; |
| 23 | + overflow: visible; |
| 24 | + |
30 | 25 | // Border radius is inherited by ripple to know its shape. Set to 50% so the ripple is round. |
31 | 26 | border-radius: 50%; |
32 | 27 |
|
|
36 | 31 | // Ensure the icons are centered. |
37 | 32 | text-align: center; |
38 | 33 |
|
39 | | - svg { |
40 | | - vertical-align: baseline; |
41 | | - } |
42 | | - |
43 | 34 | @include token-utils.use-tokens( |
44 | 35 | tokens-mdc-icon-button.$prefix, tokens-mdc-icon-button.get-token-slots()) { |
45 | 36 | $button-size: var(#{token-utils.get-token-variable(state-layer-size)}, 48px); |
|
57 | 48 | // Icon size used to be placed on the host element. Now, in `theme-styles` it is placed on |
58 | 49 | // the unused `.mdc-button__icon` class. Explicitly set the font-size here. |
59 | 50 | @include token-utils.create-token-slot(font-size, icon-size); |
| 51 | + @include token-utils.create-token-slot(color, icon-color); |
60 | 52 |
|
61 | 53 | @include button-base.mat-private-button-disabled { |
62 | | - // MDC's disabled styles target the `:disabled` selector which doesn't work on links. |
63 | | - // We re-apply the disabled icon color here since we support Material buttons on links too. |
64 | 54 | @include token-utils.create-token-slot(color, disabled-icon-color); |
65 | 55 | }; |
| 56 | + |
| 57 | + img, |
| 58 | + svg { |
| 59 | + @include token-utils.create-token-slot(width, icon-size); |
| 60 | + @include token-utils.create-token-slot(height, icon-size); |
| 61 | + vertical-align: baseline; |
| 62 | + } |
66 | 63 | } |
67 | 64 |
|
68 | 65 | @include button-base.mat-private-button-interactive(); |
|
76 | 73 | border-radius: 50%; |
77 | 74 | } |
78 | 75 |
|
| 76 | + // MDC used to include this and it seems like a lot of apps depend on it. |
| 77 | + &[hidden] { |
| 78 | + display: none; |
| 79 | + } |
| 80 | + |
79 | 81 | // MDC adds some styles to icon buttons that conflict with some of our focus indicator styles |
80 | 82 | // and don't actually do anything. This undoes those conflicting styles. |
81 | 83 | &.mat-unthemed, |
|
0 commit comments