Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit f53aacc

Browse files
mmalerbaKenneth G. Franqueiro
authored andcommitted
fix(feature-targeting): Move ripple styles into separate mixins (#4454)
(cherry picked from commit 720bef0)
1 parent 6372ae7 commit f53aacc

File tree

8 files changed

+155
-62
lines changed

8 files changed

+155
-62
lines changed

packages/mdc-button/_mixins.scss

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@
3333
@import "./variables";
3434

3535
@mixin mdc-button-core-styles($query: mdc-feature-all()) {
36+
@include mdc-button-without-ripple($query);
37+
@include mdc-button-ripple($query);
38+
}
39+
40+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
41+
// button styles. It is recommended that most users use `mdc-button-core-styles` instead.
42+
@mixin mdc-button-without-ripple($query: mdc-feature-all()) {
3643
$feat-color: mdc-feature-create-target($query, color);
3744
$feat-structure: mdc-feature-create-target($query, structure);
3845

39-
@include mdc-ripple-common($query);
40-
4146
// postcss-bem-linter: define button
4247
.mdc-button {
4348
@include mdc-button-base_($query);
@@ -55,7 +60,6 @@
5560
}
5661

5762
@include mdc-button-ink-color(primary, $query);
58-
@include mdc-states(primary, false, $query);
5963
}
6064

6165
.mdc-button__label + .mdc-button__icon {
@@ -93,7 +97,6 @@
9397
@include mdc-button--filled_($query);
9498
@include mdc-button-container-fill-color(primary, $query);
9599
@include mdc-button-ink-color(on-primary, $query);
96-
@include mdc-states(on-primary, false, $query);
97100
}
98101

99102
.mdc-button--raised {
@@ -114,6 +117,23 @@
114117
// postcss-bem-linter: end
115118
}
116119

120+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
121+
// button styles. It is recommended that most users use `mdc-button-core-styles` instead.
122+
@mixin mdc-button-ripple($query: mdc-feature-all()) {
123+
@include mdc-ripple-common($query);
124+
125+
.mdc-button {
126+
@include mdc-ripple-surface($query);
127+
@include mdc-ripple-radius-bounded($query: $query);
128+
@include mdc-states(primary, false, $query);
129+
}
130+
131+
.mdc-button--raised,
132+
.mdc-button--unelevated {
133+
@include mdc-states(on-primary, false, $query);
134+
}
135+
}
136+
117137
@mixin mdc-button-filled-accessible($container-fill-color, $query: mdc-feature-all()) {
118138
$fill-tone: mdc-theme-tone($container-fill-color);
119139

@@ -216,8 +236,6 @@
216236
$feat-structure: mdc-feature-create-target($query, structure);
217237

218238
@include mdc-typography(button, $query);
219-
@include mdc-ripple-surface($query);
220-
@include mdc-ripple-radius-bounded($query: $query);
221239
@include mdc-button-horizontal-padding($mdc-button-horizontal-padding, $query);
222240

223241
@include mdc-feature-targets($feat-structure) {

packages/mdc-card/_mixins.scss

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
//
3535

3636
@mixin mdc-card-core-styles($query: mdc-feature-all()) {
37+
@include mdc-card-without-ripple($query);
38+
@include mdc-card-ripple($query);
39+
}
40+
41+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
42+
// card styles. It is recommended that most users use `mdc-card-core-styles` instead.
43+
@mixin mdc-card-without-ripple($query: mdc-feature-all()) {
3744
// postcss-bem-linter: define card
3845

3946
$feat-color: mdc-feature-create-target($query, color);
@@ -113,9 +120,6 @@
113120
//
114121

115122
.mdc-card__primary-action {
116-
@include mdc-ripple-surface($query);
117-
@include mdc-ripple-radius-bounded($query: $query);
118-
119123
@include mdc-feature-targets($feat-structure) {
120124
@include mdc-card-container-layout_;
121125

@@ -126,8 +130,6 @@
126130
cursor: pointer;
127131
overflow: hidden;
128132
}
129-
130-
@include mdc-states($query: $query);
131133
}
132134

133135
.mdc-card__primary-action:first-child {
@@ -268,6 +270,18 @@
268270
// postcss-bem-linter: end
269271
}
270272

273+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
274+
// card styles. It is recommended that most users use `mdc-card-core-styles` instead.
275+
@mixin mdc-card-ripple($query: mdc-feature-all()) {
276+
@include mdc-ripple-common($query);
277+
278+
.mdc-card__primary-action {
279+
@include mdc-ripple-surface($query);
280+
@include mdc-ripple-radius-bounded($query: $query);
281+
@include mdc-states($query: $query);
282+
}
283+
}
284+
271285
@mixin mdc-card-fill-color($color, $query: mdc-feature-all()) {
272286
$feat-color: mdc-feature-create-target($query, color);
273287

packages/mdc-checkbox/_mixins.scss

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,19 @@
3434
//
3535

3636
@mixin mdc-checkbox-core-styles($query: mdc-feature-all()) {
37+
@include mdc-checkbox-without-ripple($query);
38+
@include mdc-checkbox-ripple($query);
39+
}
40+
41+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
42+
// checkbox styles. It is recommended that most users use `mdc-checkbox-core-styles` instead.
43+
@mixin mdc-checkbox-without-ripple($query: mdc-feature-all()) {
3744
// postcss-bem-linter: define checkbox
3845

3946
$feat-animation: mdc-feature-create-target($query, animation);
4047
$feat-color: mdc-feature-create-target($query, color);
4148
$feat-structure: mdc-feature-create-target($query, structure);
4249

43-
@include mdc-ripple-common($query);
44-
4550
@include mdc-feature-targets($feat-animation) {
4651
@include mdc-checkbox-mark-keyframes_;
4752
}
@@ -50,10 +55,6 @@
5055
@include mdc-feature-targets($feat-structure) {
5156
@include mdc-checkbox-base_;
5257
}
53-
54-
@include mdc-ripple-surface($query);
55-
@include mdc-states($mdc-checkbox-baseline-theme-color, $query: $query);
56-
@include mdc-ripple-radius-unbounded($query: $query);
5758
}
5859

5960
@include mdc-checkbox-container-colors($query: $query);
@@ -131,12 +132,6 @@
131132
@include mdc-checkbox__focus-indicator_($query);
132133
}
133134

134-
.mdc-ripple-upgraded--background-focused .mdc-checkbox__background::before {
135-
@include mdc-feature-targets($feat-structure) {
136-
@include mdc-checkbox__focus-indicator--ripple-upgraded-unbounded_;
137-
}
138-
}
139-
140135
.mdc-checkbox__native-control:focus ~ .mdc-checkbox__background::before {
141136
@include mdc-checkbox__focus-indicator--focused_($query);
142137
}
@@ -180,6 +175,26 @@
180175
// postcss-bem-linter: end
181176
}
182177

178+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
179+
// checkbox styles. It is recommended that most users use `mdc-checkbox-core-styles` instead.
180+
@mixin mdc-checkbox-ripple($query: mdc-feature-all()) {
181+
$feat-structure: mdc-feature-create-target($query, structure);
182+
183+
@include mdc-ripple-common($query);
184+
185+
.mdc-checkbox {
186+
@include mdc-ripple-surface($query);
187+
@include mdc-states($mdc-checkbox-baseline-theme-color, $query: $query);
188+
@include mdc-ripple-radius-unbounded($query: $query);
189+
}
190+
191+
.mdc-ripple-upgraded--background-focused .mdc-checkbox__background::before {
192+
@include mdc-feature-targets($feat-structure) {
193+
content: none;
194+
}
195+
}
196+
}
197+
183198
@mixin mdc-checkbox-container-colors(
184199
$unmarked-stroke-color: $mdc-checkbox-border-color,
185200
$unmarked-fill-color: transparent,
@@ -508,10 +523,6 @@
508523
}
509524
}
510525

511-
@mixin mdc-checkbox__focus-indicator--ripple-upgraded-unbounded_ {
512-
content: none;
513-
}
514-
515526
// Native input
516527

517528
@mixin mdc-checkbox__native-control_ {

packages/mdc-dom/package-lock.json

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/mdc-list/_mixins.scss

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
//
3535

3636
@mixin mdc-list-core-styles($query: mdc-feature-all()) {
37+
@include mdc-list-without-ripple($query);
38+
@include mdc-list-ripple($query);
39+
}
40+
41+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
42+
// list styles. It is recommended that most users use `mdc-list-core-styles` instead.
43+
@mixin mdc-list-without-ripple($query: mdc-feature-all()) {
3744
$feat-color: mdc-feature-create-target($query, color);
3845
$feat-structure: mdc-feature-create-target($query, structure);
3946
$feat-typography: mdc-feature-create-target($query, typography);
@@ -47,8 +54,6 @@
4754
$mdc-list-divider-color-on-light-bg
4855
);
4956

50-
@include mdc-ripple-common($query);
51-
5257
.mdc-list {
5358
@include mdc-list-base_($query);
5459
}
@@ -213,13 +218,6 @@
213218
}
214219
}
215220

216-
// List items should support states by default, but it should be possible to opt out.
217-
// Direct child combinator is necessary for non-interactive modifier on parent to not
218-
// match this selector.
219-
:not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item {
220-
@include mdc-list-item-interactive-ripple_($query);
221-
}
222-
223221
// Override anchor tag styles for the use-case of a list being used for navigation
224222
// stylelint-disable selector-max-type,selector-no-qualifying-type
225223
a.mdc-list-item {
@@ -287,6 +285,19 @@
287285
}
288286
}
289287

288+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
289+
// list styles. It is recommended that most users use `mdc-list-core-styles` instead.
290+
@mixin mdc-list-ripple($query: mdc-feature-all()) {
291+
@include mdc-ripple-common($query);
292+
293+
// List items should support states by default, but it should be possible to opt out.
294+
// Direct child combinator is necessary for non-interactive modifier on parent to not
295+
// match this selector.
296+
:not(.mdc-list--non-interactive) > :not(.mdc-list-item--disabled).mdc-list-item {
297+
@include mdc-list-item-interactive-ripple_($query);
298+
}
299+
}
300+
290301
@mixin mdc-list-item-primary-text-ink-color($color, $query: mdc-feature-all()) {
291302
$feat-color: mdc-feature-create-target($query, color);
292303

packages/mdc-radio/_mixins.scss

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,24 @@
3131
@import "./variables";
3232

3333
@mixin mdc-radio-core-styles($query: mdc-feature-all()) {
34+
@include mdc-radio-without-ripple($query);
35+
@include mdc-radio-ripple($query);
36+
}
37+
38+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
39+
// radio styles. It is recommended that most users use `mdc-radio-core-styles` instead.
40+
@mixin mdc-radio-without-ripple($query: mdc-feature-all()) {
3441
// postcss-bem-linter: define radio
3542

3643
$feat-animation: mdc-feature-create-target($query, animation);
3744
$feat-color: mdc-feature-create-target($query, color);
3845
$feat-structure: mdc-feature-create-target($query, structure);
3946

40-
@include mdc-ripple-common($query);
41-
4247
.mdc-radio {
4348
@include mdc-radio-unchecked-stroke-color($mdc-radio-unchecked-color, $query);
4449
@include mdc-radio-checked-stroke-color($mdc-radio-baseline-theme-color, $query);
4550
@include mdc-radio-ink-color($mdc-radio-baseline-theme-color, $query);
4651
@include mdc-radio-focus-indicator-color($mdc-radio-baseline-theme-color, $query);
47-
@include mdc-ripple-surface($query);
48-
@include mdc-ripple-radius-unbounded($query: $query);
49-
@include mdc-states($mdc-radio-baseline-theme-color, $query: $query);
5052

5153
@include mdc-feature-targets($feat-structure) {
5254
display: inline-block;
@@ -145,17 +147,6 @@
145147
z-index: 1;
146148
}
147149
}
148-
149-
// stylelint-disable plugin/selector-bem-pattern
150-
151-
&.mdc-ripple-upgraded--background-focused {
152-
.mdc-radio__background::before {
153-
@include mdc-feature-targets($feat-structure) {
154-
content: none;
155-
}
156-
}
157-
}
158-
// stylelint-enable plugin/selector-bem-pattern
159150
}
160151

161152
.mdc-radio__native-control:checked,
@@ -245,6 +236,28 @@
245236
// postcss-bem-linter: end
246237
}
247238

239+
// This API is intended for use by frameworks that may want to separate the ripple-related styles from the other
240+
// radio styles. It is recommended that most users use `mdc-radio-core-styles` instead.
241+
@mixin mdc-radio-ripple($query: mdc-feature-all()) {
242+
$feat-structure: mdc-feature-create-target($query, structure);
243+
244+
@include mdc-ripple-common($query);
245+
246+
.mdc-radio {
247+
@include mdc-ripple-surface($query);
248+
@include mdc-ripple-radius-unbounded($query: $query);
249+
@include mdc-states($mdc-radio-baseline-theme-color, $query: $query);
250+
251+
&.mdc-ripple-upgraded--background-focused {
252+
.mdc-radio__background::before {
253+
@include mdc-feature-targets($feat-structure) {
254+
content: none;
255+
}
256+
}
257+
}
258+
}
259+
}
260+
248261
@mixin mdc-radio-unchecked-stroke-color($color, $query: mdc-feature-all()) {
249262
$feat-color: mdc-feature-create-target($query, color);
250263

0 commit comments

Comments
 (0)