|
4 | 4 | @use 'sass:map';
|
5 | 5 | @use '../mdc-helpers/mdc-helpers';
|
6 | 6 | @use '../../material/core/theming/theming';
|
| 7 | +@use '../../material/core/ripple/ripple'; |
7 | 8 |
|
8 | 9 | @import '@material/checkbox/mixins.import';
|
9 | 10 | @import '@material/checkbox/variables.import';
|
|
29 | 30 | ripple-checked-opacity: ripple-theme.$dark-ink-opacities,
|
30 | 31 | )
|
31 | 32 | );
|
32 |
| - @include _background-focus-indicator-color(mdc-theme-prop-value(on-surface)); |
33 |
| - @include _background-focus-indicator-checked-color($color); |
34 | 33 | }
|
35 | 34 |
|
36 |
| -// TODO(b/175233410): Use ripple element to show focus indicator. |
37 |
| -@mixin _background-focus-indicator-color($color) { |
38 |
| - .mdc-checkbox__background::before { |
39 |
| - @include theme.property(background-color, on-surface); |
40 |
| - } |
41 |
| -} |
| 35 | +// Apply ripple colors to the MatRipple element and the MDC ripple element when the |
| 36 | +// checkbox is selected. |
| 37 | +@mixin _selected-ripple-colors($theme, $mdcColor) { |
| 38 | + .mdc-checkbox--selected ~ { |
| 39 | + .mat-mdc-checkbox-ripple { |
| 40 | + @include ripple.theme(( |
| 41 | + foreground: ( |
| 42 | + base: mdc-theme-prop-value($mdcColor) |
| 43 | + ), |
| 44 | + )); |
| 45 | + } |
42 | 46 |
|
43 |
| -// TODO(b/175233410): Use ripple element to show focus indicator. |
44 |
| -@mixin _background-focus-indicator-checked-color($color) { |
45 |
| - .mdc-checkbox__native-control:checked ~ .mdc-checkbox__background::before, |
46 |
| - .mdc-checkbox__native-control:indeterminate ~ .mdc-checkbox__background::before, |
47 |
| - .mdc-checkbox__native-control[data-indeterminate='true'] ~ .mdc-checkbox__background::before { |
48 |
| - @include theme.property(background-color, $color); |
| 47 | + .mdc-checkbox__ripple { |
| 48 | + background: $theme; |
| 49 | + } |
49 | 50 | }
|
50 | 51 | }
|
51 | 52 |
|
|
73 | 74 | .mat-mdc-checkbox {
|
74 | 75 | @include private-checkbox-styles-with-color(primary);
|
75 | 76 | @include mdc-form-field-core-styles($query: mdc-helpers.$mat-theme-styles-query);
|
76 |
| - } |
| 77 | + @include ripple.theme(( |
| 78 | + foreground: ( |
| 79 | + base: mdc-theme-prop-value(on-surface) |
| 80 | + ), |
| 81 | + )); |
77 | 82 |
|
78 |
| - // MDC's checkbox doesn't support a `color` property. We add support for it by adding a CSS |
79 |
| - // class for accent and warn style, and applying the appropriate overrides below. Since we don't |
80 |
| - // use MDC's ripple, we also need to set the color for our replacement ripple. |
81 |
| - .mat-mdc-checkbox { |
82 |
| - .mat-ripple-element, |
83 |
| - .mdc-checkbox__background::before { |
| 83 | + .mdc-checkbox__ripple { |
84 | 84 | background: mdc-theme-prop-value(on-surface);
|
85 | 85 | }
|
86 | 86 |
|
87 |
| - .mdc-checkbox--selected ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
88 |
| - background: $primary; |
| 87 | + // MDC's checkbox doesn't support a `color` property. We add support for it by adding a CSS |
| 88 | + // class for accent and warn style, and applying the appropriate overrides below. Since we |
| 89 | + // don't use MDC's ripple, we also need to set the color for our replacement ripple. |
| 90 | + &.mat-primary { |
| 91 | + @include private-checkbox-styles-with-color(primary); |
| 92 | + @include _selected-ripple-colors($primary, primary); |
89 | 93 | }
|
90 | 94 |
|
91 | 95 | &.mat-accent {
|
92 | 96 | @include private-checkbox-styles-with-color(secondary);
|
93 |
| - |
94 |
| - .mdc-checkbox--selected ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
95 |
| - background: $accent; |
96 |
| - } |
| 97 | + @include _selected-ripple-colors($accent, secondary); |
97 | 98 | }
|
98 | 99 |
|
99 | 100 | &.mat-warn {
|
100 | 101 | @include private-checkbox-styles-with-color(error);
|
101 |
| - |
102 |
| - .mdc-checkbox--selected ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
103 |
| - background: $warn; |
104 |
| - } |
| 102 | + @include _selected-ripple-colors($warn, error); |
105 | 103 | }
|
106 | 104 | }
|
107 | 105 | }
|
|
119 | 117 | }
|
120 | 118 | }
|
121 | 119 |
|
122 |
| -// TODO(b/175233410): Use ripple element to show focus indicator. |
123 |
| -@mixin _background-focus-density($density-scale) { |
124 |
| - $ripple-size: checkbox-theme.get-ripple-size($density-scale); |
125 |
| - $checkbox-padding: ($ripple-size - checkbox-theme.$icon-size) / 2; |
126 |
| - |
127 |
| - .mdc-checkbox__background::before { |
128 |
| - top: -(checkbox-theme.$border-width) - $checkbox-padding; |
129 |
| - left: -(checkbox-theme.$border-width) - $checkbox-padding; |
130 |
| - width: $ripple-size; |
131 |
| - height: $ripple-size; |
132 |
| - } |
133 |
| -} |
134 |
| - |
135 | 120 | @mixin density($config-or-theme) {
|
136 | 121 | $density-scale: theming.get-density-config($config-or-theme);
|
137 | 122 | .mat-mdc-checkbox .mdc-checkbox {
|
138 | 123 | @include mdc-checkbox-density(
|
139 | 124 | $density-scale,
|
140 | 125 | $query: mdc-helpers.$mat-base-styles-query
|
141 | 126 | );
|
142 |
| - @include _background-focus-density($density-scale); |
143 | 127 | }
|
144 | 128 | }
|
145 | 129 |
|
|
0 commit comments