Skip to content

Commit bb2bb9c

Browse files
authored
refactor(material-experimental/mdc-core): remove underscores from imported mixins (#21060)
* Removes the underscores from the names of mixins that are used in other files. This will become an error when we switch to the Sass module system. * Renames some mixins that were starting with `mdc-` since they can be confused with mixins actually coming from MDC.
1 parent 4399757 commit bb2bb9c

23 files changed

+61
-53
lines changed

src/material-experimental/mdc-button/_button-base.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// color and opacity for states like hover, active, and focus. Additionally, adds styles to the
66
// ripple and state container so that they fill the button, match the border radius, and avoid
77
// pointer events.
8-
@mixin _mat-button-interactive() {
8+
@mixin mat-private-button-interactive() {
99
.mdc-button__ripple::before, .mdc-button__ripple::after {
1010
content: '';
1111
pointer-events: none;
@@ -52,7 +52,7 @@
5252
// TODO(andrewseguin): Discuss with the MDC team about a mixin we can call for applying this style,
5353
// and note that having pointer-events may have unintended side-effects, e.g. allowing the user
5454
// to click the target underneath the button.
55-
@mixin _mat-button-disabled() {
55+
@mixin mat-private-button-disabled() {
5656
&[disabled] {
5757
cursor: default;
5858
pointer-events: none;

src/material-experimental/mdc-button/button.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
@include mdc-button-without-ripple($query: $mat-base-styles-query);
99

1010
.mat-mdc-button, .mat-mdc-unelevated-button, .mat-mdc-raised-button, .mat-mdc-outlined-button {
11-
@include _mat-button-interactive();
12-
@include _mat-button-disabled();
11+
@include mat-private-button-interactive();
12+
@include mat-private-button-disabled();
1313

1414
// MDC expects button icons to contain this HTML content:
1515
// ```html

src/material-experimental/mdc-button/fab.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
@include mdc-fab-without-ripple($query: $mat-base-styles-query);
88

99
.mat-mdc-fab, .mat-mdc-mini-fab {
10-
@include _mat-button-interactive();
11-
@include _mat-button-disabled();
10+
@include mat-private-button-interactive();
11+
@include mat-private-button-disabled();
1212

1313
// MDC adds some styles to fab and mini-fab that conflict with some of our focus indicator
1414
// styles and don't actually do anything. This undoes those conflicting styles.

src/material-experimental/mdc-button/icon-button.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
@include mdc-icon-button-without-ripple($query: $mat-base-styles-query);
66

77
.mat-mdc-icon-button {
8-
@include _mat-button-interactive() {
8+
@include mat-private-button-interactive() {
99
border-radius: 50%;
1010
}
1111

1212
// Border radius is inherited by ripple to know its shape. Set to 50% so the ripple is round.
1313
border-radius: 50%;
1414

15-
@include _mat-button-disabled();
15+
@include mat-private-button-disabled();
1616

1717
// MDC adds some styles to icon buttons that conflict with some of our focus indicator styles
1818
// and don't actually do anything. This undoes those conflicting styles.

src/material-experimental/mdc-checkbox/_checkbox-theme.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// Mixin that includes the checkbox theme styles with a given palette.
1212
// By default, the MDC checkbox always uses the `secondary` palette.
13-
@mixin _mdc-checkbox-styles-with-color($color) {
13+
@mixin mat-mdc-private-checkbox-styles-with-color($color) {
1414
@include checkbox-theme.theme((
1515
density-scale: null,
1616
checkmark-color: mdc-theme-prop-value(on-#{$color}),
@@ -42,7 +42,7 @@
4242
$mdc-checkbox-disabled-color: rgba(mdc-theme-prop-value(on-surface), 0.26) !global;
4343

4444
.mat-mdc-checkbox {
45-
@include _mdc-checkbox-styles-with-color(primary);
45+
@include mat-mdc-private-checkbox-styles-with-color(primary);
4646
@include mdc-form-field-core-styles($query: $mat-theme-styles-query);
4747
}
4848

@@ -60,15 +60,15 @@
6060
}
6161

6262
&.mat-accent {
63-
@include _mdc-checkbox-styles-with-color(secondary);
63+
@include mat-mdc-private-checkbox-styles-with-color(secondary);
6464

6565
.mdc-checkbox--selected ~ .mat-mdc-checkbox-ripple .mat-ripple-element {
6666
background: $accent;
6767
}
6868
}
6969

7070
&.mat-warn {
71-
@include _mdc-checkbox-styles-with-color(error);
71+
@include mat-mdc-private-checkbox-styles-with-color(error);
7272

7373
.mdc-checkbox--selected ~ .mat-mdc-checkbox-ripple .mat-ripple-element {
7474
background: $warn;

src/material-experimental/mdc-dialog/_mdc-dialog-structure-overrides.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Mixin that can be included to override the default MDC dialog styles to fit
22
// our needs. See individual comments for context on why certain styles need to be modified.
3-
@mixin _mdc-dialog-structure-overrides() {
3+
@mixin mat-mdc-private-dialog-structure-overrides() {
44
// MDC dialog sets max-height and max-width on the `mdc-dialog__surface` element. This
55
// element is the parent of the portal outlet. This means that the actual user-content
66
// is scrollable, but as per Material Design specification, only the dialog content

src/material-experimental/mdc-dialog/dialog.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ $mat-dialog-content-max-height: 65vh !default;
1212
$mat-dialog-button-horizontal-margin: 8px !default;
1313

1414
@include mdc-dialog-core-styles($query: $mat-base-styles-query);
15-
@include _mdc-dialog-structure-overrides();
15+
@include mat-mdc-private-dialog-structure-overrides();
1616

1717
// The dialog container is focusable. We remove the default outline shown in browsers.
1818
.mat-mdc-dialog-container {

src/material-experimental/mdc-form-field/_form-field-density.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// provide spacing that makes arbitrary controls align as specified in the Material Design
3636
// specification. In order to support density, we need to adjust the vertical spacing to be
3737
// based on the density scale.
38-
@mixin _mat-mdc-form-field-density($config-or-theme) {
38+
@mixin mat-mdc-private-form-field-density($config-or-theme) {
3939
$density-scale: mat-get-density-config($config-or-theme);
4040
// Height of the form field that is based on the current density scale.
4141
$height: mdc-density-prop-value(

src/material-experimental/mdc-form-field/_form-field-focus-overlay.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99
// runtime code for launching interaction ripples at pointer location. This is not needed
1010
// for the text-field, so we create our own minimal focus overlay styles. Our focus overlay
1111
// uses the exact same logic to compute the colors as in the default MDC text-field ripples.
12-
@mixin _mat-mdc-form-field-focus-overlay() {
12+
@mixin mat-mdc-private-form-field-focus-overlay() {
1313
.mat-mdc-form-field-focus-overlay {
1414
@include mat-fill;
1515
opacity: 0;
1616
}
1717
}
1818

19-
@mixin _mat-mdc-form-field-focus-overlay-color() {
19+
@mixin mat-mdc-private-form-field-focus-overlay-color() {
2020
$focus-opacity: ripple-functions.states-opacity($mdc-text-field-ink-color, focus);
2121
$hover-opacity: ripple-functions.states-opacity($mdc-text-field-ink-color, hover);
2222

src/material-experimental/mdc-form-field/_form-field-native-select.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $mat-form-field-select-arrow-height: 5px;
1010
$mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-width + 5px;
1111

1212
// Mixin that creates styles for native select controls in a form-field.
13-
@mixin _mat-mdc-form-field-native-select() {
13+
@mixin mat-mdc-private-form-field-native-select() {
1414
// Remove the native select down arrow and ensure that the native appearance
1515
// does not conflict with the form-field. e.g. Focus indication of the native
1616
// select is undesired since we handle focus as part of the form-field.
@@ -90,7 +90,7 @@ $mat-form-field-select-horizontal-end-padding: $mat-form-field-select-arrow-widt
9090
}
9191
}
9292

93-
@mixin _mat-mdc-form-field-native-select-color($config) {
93+
@mixin mat-mdc-private-form-field-native-select-color($config) {
9494
select.mat-mdc-input-element {
9595
// On dark themes we set the native `select` color to some shade of white,
9696
// however the color propagates to all of the `option` elements, which are

src/material-experimental/mdc-form-field/_form-field-subscript.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@import 'form-field-sizing';
22
@import '../mdc-helpers/mdc-helpers';
33

4-
@mixin _mat-mdc-form-field-subscript() {
4+
@mixin mat-mdc-private-form-field-subscript() {
55
// Wrapper for the hints and error messages.
66
.mat-mdc-form-field-subscript-wrapper {
77
box-sizing: border-box;
@@ -34,14 +34,14 @@
3434
}
3535
}
3636

37-
@mixin _mat-mdc-form-field-subscript-color() {
37+
@mixin mat-mdc-private-form-field-subscript-color() {
3838
// MDC does not have built-in error treatment.
3939
.mat-mdc-form-field-error {
4040
@include mdc-theme-prop(color, $mdc-text-field-error);
4141
}
4242
}
4343

44-
@mixin _mat-mdc-form-field-subscript-typography($config-or-theme) {
44+
@mixin mat-mdc-private-form-field-subscript-typography($config-or-theme) {
4545
$config: mat-get-typography-config($config-or-theme);
4646
// The unit-less line-height from the font config.
4747
$line-height: mat-line-height($config, input);

src/material-experimental/mdc-form-field/_form-field-theme.scss

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
// Mixin that overwrites the default MDC text-field color styles to be based on
1515
// the given theme palette. The MDC text-field is styled using `primary` by default.
16-
@mixin _mdc-text-field-color-styles($palette-name, $query: $mat-theme-styles-query) {
16+
@mixin _mat-mdc-text-field-color-styles($palette-name, $query: $mat-theme-styles-query) {
1717
$_mdc-text-field-focused-label-color: $mdc-text-field-focused-label-color;
1818
$mdc-text-field-focused-label-color: rgba(mdc-theme-prop-value($palette-name), 0.87) !global;
1919

@@ -38,21 +38,21 @@
3838
@mixin mat-mdc-form-field-color($config-or-theme) {
3939
$config: mat-get-color-config($config-or-theme);
4040
@include mat-using-mdc-theme($config) {
41-
@include _mdc-text-field-refresh-theme-variables() {
41+
@include mat-mdc-private-text-field-refresh-theme-variables() {
4242
@include mdc-text-field-without-ripple($query: $mat-theme-styles-query);
4343
@include mdc-floating-label-core-styles($query: $mat-theme-styles-query);
4444
@include mdc-notched-outline-core-styles($query: $mat-theme-styles-query);
4545
@include mdc-line-ripple-core-styles($query: $mat-theme-styles-query);
46-
@include _mat-mdc-form-field-subscript-color();
47-
@include _mat-mdc-form-field-focus-overlay-color();
48-
@include _mat-mdc-form-field-native-select-color($config);
46+
@include mat-mdc-private-form-field-subscript-color();
47+
@include mat-mdc-private-form-field-focus-overlay-color();
48+
@include mat-mdc-private-form-field-native-select-color($config);
4949

5050
.mat-mdc-form-field.mat-accent {
51-
@include _mdc-text-field-color-styles(secondary);
51+
@include _mat-mdc-text-field-color-styles(secondary);
5252
}
5353

5454
.mat-mdc-form-field.mat-warn {
55-
@include _mdc-text-field-color-styles(error);
55+
@include _mat-mdc-text-field-color-styles(error);
5656
}
5757
}
5858
}
@@ -65,7 +65,7 @@
6565
@include mdc-floating-label-core-styles($query: $mat-typography-styles-query);
6666
@include mdc-notched-outline-core-styles($query: $mat-typography-styles-query);
6767
@include mdc-line-ripple-core-styles($query: $mat-typography-styles-query);
68-
@include _mat-mdc-form-field-subscript-typography($config);
68+
@include mat-mdc-private-form-field-subscript-typography($config);
6969

7070
.mat-mdc-form-field {
7171
@include mat-typography-level-to-styles($config, input);
@@ -75,7 +75,7 @@
7575

7676
@mixin mat-mdc-form-field-density($config-or-theme) {
7777
$density-scale: mat-get-density-config($config-or-theme);
78-
@include _mat-mdc-form-field-density($density-scale);
78+
@include mat-mdc-private-form-field-density($density-scale);
7979
}
8080

8181
@mixin mat-mdc-form-field-theme($theme-or-color-config) {

src/material-experimental/mdc-form-field/_mdc-text-field-structure-overrides.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Mixin that can be included to override the default MDC text-field
66
// styles to fit our needs. See individual comments for context on why
77
// certain MDC styles need to be modified.
8-
@mixin _mat-mdc-text-field-structure-overrides() {
8+
@mixin mat-mdc-private-text-field-structure-overrides() {
99
// Unset the border set by MDC. We move the border (which serves as the Material Design
1010
// text-field bottom line) into its own element. This is necessary because we want the
1111
// bottom-line to span across the whole form-field (including prefixes and suffixes). Also

src/material-experimental/mdc-form-field/_mdc-text-field-textarea-overrides.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
// Mixin that can be included to override the default MDC text-field styles
1111
// to properly support textareas.
12-
@mixin _mat-mdc-text-field-textarea-overrides() {
12+
@mixin mat-mdc-private-text-field-textarea-overrides() {
1313
// Ensures that textarea elements inside of the form-field have proper vertical spacing
1414
// to account for the floating label. Also ensures that there is no vertical text overflow.
1515
.mat-mdc-textarea-input {

src/material-experimental/mdc-form-field/_mdc-text-field-theme-variable-refresh.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// the base MDC theming variables have been explicitly updated, but the component specific
88
// theming-based variables are still based on the old MDC base theming variables. The mixin
99
// restores the previous values for the variables to avoid unexpected global side effects.
10-
@mixin _mdc-text-field-refresh-theme-variables() {
10+
@mixin mat-mdc-private-text-field-refresh-theme-variables() {
1111
$_mdc-text-field-disabled-border-border: $mdc-text-field-disabled-border-border;
1212
$mdc-text-field-disabled-border: rgba(theme-variables.prop-value(on-surface), 0.06) !global;
1313
$_mdc-text-field-bottom-line-hover: $mdc-text-field-bottom-line-hover;

src/material-experimental/mdc-form-field/form-field.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
@include mdc-line-ripple-core-styles($query: $mat-base-styles-without-animation-query);
1515

1616
// MDC text-field overwrites.
17-
@include _mat-mdc-text-field-textarea-overrides();
18-
@include _mat-mdc-text-field-structure-overrides();
17+
@include mat-mdc-private-text-field-textarea-overrides();
18+
@include mat-mdc-private-text-field-structure-overrides();
1919

2020
// Include the subscript, focus-overlay and native select styles.
21-
@include _mat-mdc-form-field-subscript();
22-
@include _mat-mdc-form-field-focus-overlay();
23-
@include _mat-mdc-form-field-native-select();
21+
@include mat-mdc-private-form-field-subscript();
22+
@include mat-mdc-private-form-field-focus-overlay();
23+
@include mat-mdc-private-form-field-native-select();
2424

2525
// Host element of the form-field. It contains the mdc-text-field wrapper
2626
// and the subscript wrapper.

src/material-experimental/mdc-list/_interactive-list-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
// Mixin that provides colors for the various states of an interactive list-item. MDC
55
// has integrated styles for these states but relies on their complex ripples for it.
6-
@mixin _mat-mdc-interactive-list-item-state-colors($config) {
6+
@mixin mat-mdc-private-interactive-list-item-state-colors($config) {
77
$is-dark-theme: map-get($config, is-dark);
88
$state-opacities:
99
if($is-dark-theme, $mdc-ripple-light-ink-opacities, $mdc-ripple-dark-ink-opacities);

src/material-experimental/mdc-list/_list-option-theme.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// Mixin that overrides the selected item and checkbox colors for list options. By
88
// default, the MDC list uses the `primary` color for list items. The MDC checkbox
99
// inside list options by default uses the `primary` color too.
10-
@mixin _mat-mdc-list-option-color-override($color) {
10+
@mixin mat-mdc-private-list-option-color-override($color) {
1111
& .mdc-list-item__meta, & .mdc-list-item__graphic {
12-
@include _mdc-checkbox-styles-with-color($color);
12+
@include mat-mdc-private-checkbox-styles-with-color($color);
1313
}
1414

1515
&.mdc-list-item--selected {
@@ -22,7 +22,7 @@
2222
}
2323
}
2424

25-
@mixin _mat-mdc-list-option-density-styles($density-scale) {
25+
@mixin mat-mdc-private-list-option-density-styles($density-scale) {
2626
.mat-mdc-list-option {
2727
.mdc-list-item__meta, .mdc-list-item__graphic {
2828
.mdc-checkbox {
@@ -32,7 +32,7 @@
3232
}
3333
}
3434

35-
@mixin _mat-mdc-list-option-typography-styles() {
35+
@mixin mat-mdc-private-list-option-typography-styles() {
3636
.mat-mdc-list-option {
3737
.mdc-list-item__meta, .mdc-list-item__graphic {
3838
@include mdc-checkbox-without-ripple($query: $mat-typography-styles-query);

src/material-experimental/mdc-list/_list-theme.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515

1616
// MDC's state styles are tied in with their ripple. Since we don't use the MDC
1717
// ripple, we need to add the hover, focus and selected states manually.
18-
@include _mat-mdc-interactive-list-item-state-colors($config);
18+
@include mat-mdc-private-interactive-list-item-state-colors($config);
1919

2020
@include mat-using-mdc-theme($config) {
2121
@include mdc-list-without-ripple($query: $mat-theme-styles-query);
2222

2323
.mat-mdc-list-option {
24-
@include _mat-mdc-list-option-color-override(primary);
24+
@include mat-mdc-private-list-option-color-override(primary);
2525
}
2626
.mat-mdc-list-option.mat-accent {
27-
@include _mat-mdc-list-option-color-override(secondary);
27+
@include mat-mdc-private-list-option-color-override(secondary);
2828
}
2929
.mat-mdc-list-option.mat-warn {
30-
@include _mat-mdc-list-option-color-override(error);
30+
@include mat-mdc-private-list-option-color-override(error);
3131
}
3232
}
3333
}
@@ -48,14 +48,14 @@
4848
@include mdc-list-single-line-height($height);
4949
}
5050

51-
@include _mat-mdc-list-option-density-styles($density-scale);
51+
@include mat-mdc-private-list-option-density-styles($density-scale);
5252
}
5353

5454
@mixin mat-mdc-list-typography($config-or-theme) {
5555
$config: mat-get-typography-config($config-or-theme);
5656
@include mat-using-mdc-typography($config) {
5757
@include mdc-list-without-ripple($query: $mat-typography-styles-query);
58-
@include _mat-mdc-list-option-typography-styles();
58+
@include mat-mdc-private-list-option-typography-styles();
5959
}
6060
}
6161

src/material-experimental/mdc-paginator/_paginator-theme.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@import '@material/theme/variables.import';
22
@import '@material/typography/variables.import';
33
@import '../../material/core/theming/private';
4+
@import '../../material/core/density/private/compatibility';
45
@import './paginator-variables';
56

67
@mixin mat-mdc-paginator-color($config-or-theme) {

src/material/button-toggle/_button-toggle-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@import '../core/theming/theming';
55
@import '../core/theming/private';
66
@import '../core/typography/typography-utils';
7-
@import '../core/density/private/all-density';
7+
@import '../core/density/private/compatibility';
88
@import './button-toggle-variables';
99

1010
@mixin mat-button-toggle-color($config-or-theme) {

tools/stylelint/no-top-level-ampersand-in-mixin.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,13 @@ const plugin = createPlugin(ruleName, (isEnabled: boolean, _options?) => {
3232

3333
root.walkAtRules(node => {
3434
// Skip non-mixin atrules and internal mixins.
35-
if (!node.nodes || node.name !== 'mixin' || node.params.indexOf('_') === 0) {
35+
if (!node.nodes || node.name !== 'mixin' || node.params.startsWith('_') ||
36+
node.params.startsWith('mat-private-') || node.params.startsWith('mat-mdc-private-')) {
3637
return;
3738
}
3839

3940
node.nodes.forEach(childNode => {
40-
if (childNode.type === 'rule' && childNode.selector.indexOf('&') === 0) {
41+
if (childNode.type === 'rule' && childNode.selector.startsWith('&')) {
4142
utils.report({
4243
result,
4344
ruleName,

0 commit comments

Comments
 (0)