|
1 | 1 | @use 'sass:math'; |
2 | 2 | @use '@material/density/functions' as mdc-density-functions; |
3 | 3 | @use '@material/icon-button/icon-button-theme' as mdc-icon-button-theme; |
4 | | -@use '@material/theme/theme-color' as mdc-theme-color; |
5 | 4 | @use '../core/tokens/m2/mdc/icon-button' as tokens-mdc-icon-button; |
6 | 5 |
|
7 | 6 | @use './button-theme-private'; |
|
10 | 9 |
|
11 | 10 | $_icon-size: 24px; |
12 | 11 |
|
| 12 | +// TODO(crisbeto): move these into tokens |
13 | 13 | @mixin _ripple-color($color) { |
14 | 14 | --mat-mdc-button-persistent-ripple-color: #{$color}; |
15 | 15 | --mat-mdc-button-ripple-color: #{rgba($color, 0.1)}; |
16 | 16 | } |
17 | 17 |
|
18 | | -@function _variable-safe-contrast-tone($value, $is-dark) { |
19 | | - @if ($value == 'dark' or $value == 'light' or type-of($value) == 'color') { |
20 | | - @return mdc-theme-color.contrast-tone($value); |
21 | | - } |
22 | | - |
23 | | - @return if($is-dark, 'light', 'dark'); |
24 | | -} |
25 | | - |
26 | 18 | @mixin base($theme) { |
27 | 19 | // TODO(mmalerba): Move icon button base tokens here |
28 | 20 | } |
29 | 21 |
|
30 | 22 | @mixin color($theme) { |
31 | 23 | $color-tokens: tokens-mdc-icon-button.get-color-tokens($theme); |
32 | | - $surface: inspection.get-theme-color($theme, background, card); |
33 | 24 | $is-dark: inspection.get-theme-type($theme) == dark; |
34 | | - $on-surface: if(_variable-safe-contrast-tone($surface, $is-dark) == 'dark', #000, #fff); |
35 | 25 |
|
36 | 26 | .mat-mdc-icon-button { |
37 | 27 | @include button-theme-private.ripple-theme-styles($theme, false); |
38 | 28 | @include mdc-icon-button-theme.theme($color-tokens); |
39 | | - @include _ripple-color($on-surface); |
| 29 | + @include _ripple-color(if($is-dark, #fff, #000)); |
40 | 30 |
|
41 | 31 | &.mat-primary { |
42 | | - $color: inspection.get-theme-color($theme, primary); |
43 | | - @include mdc-icon-button-theme.theme((icon-color: $color)); |
44 | | - @include _ripple-color($color); |
| 32 | + @include _ripple-color(inspection.get-theme-color($theme, primary)); |
| 33 | + @include mdc-icon-button-theme.theme( |
| 34 | + tokens-mdc-icon-button.private-get-color-palette-color-tokens($theme, primary)); |
45 | 35 | } |
46 | 36 |
|
47 | 37 | &.mat-accent { |
48 | | - $color: inspection.get-theme-color($theme, accent); |
49 | | - @include mdc-icon-button-theme.theme((icon-color: $color)); |
50 | | - @include _ripple-color($color); |
| 38 | + @include _ripple-color(inspection.get-theme-color($theme, accent)); |
| 39 | + @include mdc-icon-button-theme.theme( |
| 40 | + tokens-mdc-icon-button.private-get-color-palette-color-tokens($theme, accent)); |
51 | 41 | } |
52 | 42 |
|
53 | 43 | &.mat-warn { |
54 | | - $color: inspection.get-theme-color($theme, warn); |
55 | | - @include mdc-icon-button-theme.theme((icon-color: $color)); |
56 | | - @include _ripple-color($color); |
57 | | - } |
58 | | - |
59 | | - @include button-theme-private.apply-disabled-style() { |
60 | | - $disabled-color: rgba($on-surface, if($is-dark, 0.5, 0.38)); |
61 | | - @include mdc-icon-button-theme.theme(( |
62 | | - icon-color: $disabled-color, |
63 | | - disabled-icon-color: $disabled-color, |
64 | | - )); |
| 44 | + @include _ripple-color(inspection.get-theme-color($theme, warn)); |
| 45 | + @include mdc-icon-button-theme.theme( |
| 46 | + tokens-mdc-icon-button.private-get-color-palette-color-tokens($theme, warn)); |
65 | 47 | } |
66 | 48 | } |
67 | 49 | } |
68 | 50 |
|
69 | | -@mixin typography($theme) { |
70 | | -} |
| 51 | +@mixin typography($theme) {} |
71 | 52 |
|
72 | 53 | @mixin density($theme) { |
73 | 54 | $density-scale: inspection.get-theme-density($theme); |
|
0 commit comments