|
1 |
| -@use 'sass:map'; |
2 | 1 | @use '@angular/cdk';
|
3 |
| -@use '@material/checkbox/checkbox' as mdc-checkbox; |
4 |
| -@use '@material/checkbox/checkbox-theme' as mdc-checkbox-theme; |
5 |
| -@use '@material/touch-target' as mdc-touch-target; |
6 |
| -@use '@material/theme/custom-properties' as mdc-custom-properties; |
7 |
| -@use '../core/mdc-helpers/mdc-helpers'; |
8 | 2 | @use '../core/style/layout-common';
|
9 | 3 | @use '../core/style/vendor-prefixes';
|
10 |
| -@use '../core/tokens/m2/mdc/checkbox' as tokens-mdc-checkbox; |
11 | 4 | @use '../core/tokens/m2/mat/checkbox' as tokens-mat-checkbox;
|
12 | 5 | @use '../core/tokens/token-utils';
|
| 6 | +@use './checkbox-common'; |
13 | 7 |
|
14 |
| -@include mdc-custom-properties.configure($emit-fallback-values: false, $emit-fallback-vars: false) { |
15 |
| - // Add the checkbox static styles. |
16 |
| - @include mdc-checkbox.static-styles(); |
17 |
| - |
18 |
| - $mdc-checkbox-slots: tokens-mdc-checkbox.get-token-slots(); |
19 |
| - |
20 |
| - .mdc-checkbox { |
21 |
| - // Add the slots for MDC checkbox. |
22 |
| - @include mdc-checkbox-theme.theme-styles( |
23 |
| - map.merge( |
24 |
| - $mdc-checkbox-slots, |
25 |
| - ( |
26 |
| - // Angular Material focuses the native input. rather than the element MDC expects, |
27 |
| - // so we create this slot ourselves. |
28 |
| - selected-focus-icon-color: null, |
29 |
| - unselected-focus-icon-color: null, |
30 |
| - // MDC expects `.mdc-checkbox__ripple::before` to be the state layer, but we use |
31 |
| - // `.mdc-checkbox__ripple` instead, so we emit the state layer slots ourselves. |
32 |
| - unselected-hover-state-layer-opacity: null, |
33 |
| - unselected-hover-state-layer-color: null, |
34 |
| - unselected-focus-state-layer-opacity: null, |
35 |
| - unselected-focus-state-layer-color: null, |
36 |
| - unselected-pressed-state-layer-opacity: null, |
37 |
| - unselected-pressed-state-layer-color: null, |
38 |
| - selected-hover-state-layer-opacity: null, |
39 |
| - selected-hover-state-layer-color: null, |
40 |
| - selected-focus-state-layer-opacity: null, |
41 |
| - selected-focus-state-layer-color: null, |
42 |
| - selected-pressed-state-layer-opacity: null, |
43 |
| - selected-pressed-state-layer-color: null |
44 |
| - ) |
45 |
| - ) |
46 |
| - ); |
47 |
| - |
48 |
| - @include token-utils.use-tokens(tokens-mdc-checkbox.$prefix, $mdc-checkbox-slots) { |
49 |
| - // MDC expects focus on .mdc-checkbox, but we focus the native element instead, so we need to |
50 |
| - // emit a our own slot for the focus styles. |
51 |
| - .mdc-checkbox__native-control:enabled:focus { |
52 |
| - // Extra `:focus` included to achieve higher specificity than MDC's `:hover` style. |
53 |
| - &:focus:not(:checked):not(:indeterminate) ~ .mdc-checkbox__background { |
54 |
| - @include token-utils.create-token-slot(border-color, unselected-focus-icon-color); |
55 |
| - } |
56 |
| - |
57 |
| - &:checked, |
58 |
| - &:indeterminate { |
59 |
| - & ~ .mdc-checkbox__background { |
60 |
| - @include token-utils.create-token-slot(border-color, selected-focus-icon-color); |
61 |
| - @include token-utils.create-token-slot(background-color, selected-focus-icon-color); |
62 |
| - } |
63 |
| - } |
64 |
| - } |
65 |
| - |
66 |
| - // MDC expects `.mdc-checkbox__ripple::before` to be the state layer, but we use |
67 |
| - // `.mdc-checkbox__ripple` instead, so we emit the state layer slots ourselves. |
68 |
| - &:hover { |
69 |
| - .mdc-checkbox__ripple { |
70 |
| - @include token-utils.create-token-slot(opacity, unselected-hover-state-layer-opacity); |
71 |
| - @include token-utils.create-token-slot( |
72 |
| - background-color, |
73 |
| - unselected-hover-state-layer-color |
74 |
| - ); |
75 |
| - } |
76 |
| - |
77 |
| - .mat-mdc-checkbox-ripple .mat-ripple-element { |
78 |
| - @include token-utils.create-token-slot( |
79 |
| - background-color, |
80 |
| - unselected-hover-state-layer-color |
81 |
| - ); |
82 |
| - } |
83 |
| - } |
84 |
| - |
85 |
| - .mdc-checkbox__native-control:focus { |
86 |
| - & ~ .mdc-checkbox__ripple { |
87 |
| - @include token-utils.create-token-slot(opacity, unselected-focus-state-layer-opacity); |
88 |
| - @include token-utils.create-token-slot( |
89 |
| - background-color, |
90 |
| - unselected-focus-state-layer-color |
91 |
| - ); |
92 |
| - } |
93 |
| - |
94 |
| - & ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
95 |
| - @include token-utils.create-token-slot( |
96 |
| - background-color, |
97 |
| - unselected-focus-state-layer-color |
98 |
| - ); |
99 |
| - } |
100 |
| - } |
101 |
| - |
102 |
| - &:active .mdc-checkbox__native-control { |
103 |
| - & ~ .mdc-checkbox__ripple { |
104 |
| - @include token-utils.create-token-slot(opacity, unselected-pressed-state-layer-opacity); |
105 |
| - @include token-utils.create-token-slot( |
106 |
| - background-color, |
107 |
| - unselected-pressed-state-layer-color |
108 |
| - ); |
109 |
| - } |
110 |
| - |
111 |
| - & ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
112 |
| - @include token-utils.create-token-slot( |
113 |
| - background-color, |
114 |
| - unselected-pressed-state-layer-color |
115 |
| - ); |
116 |
| - } |
117 |
| - } |
118 |
| - |
119 |
| - &:hover .mdc-checkbox__native-control:checked { |
120 |
| - & ~ .mdc-checkbox__ripple { |
121 |
| - @include token-utils.create-token-slot(opacity, selected-hover-state-layer-opacity); |
122 |
| - @include token-utils.create-token-slot( |
123 |
| - background-color, |
124 |
| - selected-hover-state-layer-color |
125 |
| - ); |
126 |
| - } |
127 |
| - |
128 |
| - & ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
129 |
| - @include token-utils.create-token-slot( |
130 |
| - background-color, |
131 |
| - selected-hover-state-layer-color |
132 |
| - ); |
133 |
| - } |
134 |
| - } |
135 |
| - |
136 |
| - .mdc-checkbox__native-control:focus:checked { |
137 |
| - & ~ .mdc-checkbox__ripple { |
138 |
| - @include token-utils.create-token-slot(opacity, selected-focus-state-layer-opacity); |
139 |
| - @include token-utils.create-token-slot( |
140 |
| - background-color, |
141 |
| - selected-focus-state-layer-color |
142 |
| - ); |
143 |
| - } |
144 |
| - |
145 |
| - & ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
146 |
| - @include token-utils.create-token-slot( |
147 |
| - background-color, |
148 |
| - selected-focus-state-layer-color |
149 |
| - ); |
150 |
| - } |
151 |
| - } |
152 |
| - |
153 |
| - &:active .mdc-checkbox__native-control:checked { |
154 |
| - & ~ .mdc-checkbox__ripple { |
155 |
| - @include token-utils.create-token-slot(opacity, selected-pressed-state-layer-opacity); |
156 |
| - @include token-utils.create-token-slot( |
157 |
| - background-color, |
158 |
| - selected-pressed-state-layer-color |
159 |
| - ); |
160 |
| - } |
161 |
| - |
162 |
| - & ~ .mat-mdc-checkbox-ripple .mat-ripple-element { |
163 |
| - @include token-utils.create-token-slot( |
164 |
| - background-color, |
165 |
| - selected-pressed-state-layer-color |
166 |
| - ); |
167 |
| - } |
168 |
| - } |
169 |
| - } |
170 |
| - } |
171 |
| -} |
| 8 | +@include checkbox-common.checkbox-structure(true); |
172 | 9 |
|
173 | 10 | .mat-mdc-checkbox {
|
| 11 | + @include checkbox-common.checkbox-noop-animations; |
| 12 | + |
174 | 13 | // The host node defaults to `display: inline`, we have to change it in order for margins to work.
|
175 | 14 | display: inline-block;
|
176 | 15 | // Avoids issues in some CSS grid layouts (see #25153).
|
|
183 | 22 | @include vendor-prefixes.color-adjust(exact);
|
184 | 23 | }
|
185 | 24 |
|
186 |
| - // Angular Material supports disabling all animations when NoopAnimationsModule is imported. |
187 |
| - &._mat-animation-noopable { |
188 |
| - *, |
189 |
| - *::before { |
190 |
| - transition: none !important; |
191 |
| - animation: none !important; |
192 |
| - } |
193 |
| - } |
194 |
| - |
195 | 25 | // Clicking the label toggles the checkbox, but MDC does not include any styles that inform the
|
196 | 26 | // user of this. Therefore we add the pointer cursor on top of MDC's styles.
|
197 | 27 | label {
|
|
269 | 99 |
|
270 | 100 | // Element used to provide a larger tap target for users on touch devices.
|
271 | 101 | .mat-mdc-checkbox-touch-target {
|
272 |
| - @include mdc-touch-target.touch-target( |
273 |
| - $set-width: true, |
274 |
| - $query: mdc-helpers.$mdc-base-styles-query |
275 |
| - ); |
| 102 | + position: absolute; |
| 103 | + top: 50%; |
| 104 | + left: 50%; |
| 105 | + height: 48px; |
| 106 | + width: 48px; |
| 107 | + transform: translate(-50%, -50%); |
276 | 108 |
|
277 | 109 | @include token-utils.use-tokens(
|
278 | 110 | tokens-mat-checkbox.$prefix,
|
|
0 commit comments