Skip to content

Commit 53cd99a

Browse files
crisbetowagnermaciel
authored andcommitted
refactor(material/core): clean up prefixes from internal Sass symbols (#22378)
The Sass migration script doesn't migrate private symbols (starting with `_`) so we were left with some prefixes. These changes clean up the prefixes, as well as some unnecessary `!global` declarations. (cherry picked from commit 278f2ab)
1 parent f3dcfa9 commit 53cd99a

File tree

55 files changed

+284
-292
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+284
-292
lines changed

src/cdk/a11y/_index.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/// Emits the mixin's content nested under `$selector-context` if `$selector-context`
2727
/// is non-empty.
2828
/// @param selector-context The selector under which to nest the mixin's content.
29-
@mixin _cdk-optionally-nest-content($selector-context) {
29+
@mixin _optionally-nest-content($selector-context) {
3030
@if ($selector-context == '') {
3131
@content;
3232
}
@@ -68,15 +68,15 @@
6868
// Note that if this selector is updated, the same change has to be made inside
6969
// `_overlay.scss` which can't depend on this mixin due to some infrastructure limitations.
7070
.cdk-high-contrast-#{$target} {
71-
@include _cdk-optionally-nest-content($selector-context) {
71+
@include _optionally-nest-content($selector-context) {
7272
@content;
7373
}
7474
}
7575
}
7676

7777
@if ($encapsulation != 'off') {
7878
.cdk-high-contrast-#{$target} :host {
79-
@include _cdk-optionally-nest-content($selector-context) {
79+
@include _optionally-nest-content($selector-context) {
8080
@content;
8181
}
8282
}

src/cdk/scrolling/virtual-scroll-viewport.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// their container element (e.g. `<table>`, `<ul>`, etc.) needs to be placed in the viewport as
33
// well. We reset some properties here to prevent these container elements from introducing
44
// additional space that would throw off the scrolling calculations.
5-
@mixin _cdk-virtual-scroll-clear-container-space($direction) {
5+
@mixin _clear-container-space($direction) {
66
$start: if($direction == horizontal, 'left', 'top');
77
$end: if($direction == horizontal, 'right', 'bottom');
88

@@ -57,12 +57,12 @@ cdk-virtual-scroll-viewport {
5757

5858
.cdk-virtual-scroll-orientation-horizontal .cdk-virtual-scroll-content-wrapper {
5959
min-height: 100%;
60-
@include _cdk-virtual-scroll-clear-container-space(horizontal);
60+
@include _clear-container-space(horizontal);
6161
}
6262

6363
.cdk-virtual-scroll-orientation-vertical .cdk-virtual-scroll-content-wrapper {
6464
min-width: 100%;
65-
@include _cdk-virtual-scroll-clear-container-space(vertical);
65+
@include _clear-container-space(vertical);
6666
}
6767

6868
// Spacer element that whose width or height will be adjusted to match the size of the entire data

src/cdk/text-field/_index.scss

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// removed when measuring is complete. We use `!important` rules here to make sure user-specified
1111
// rules do not interfere with the measurement.
1212
textarea.cdk-textarea-autosize-measuring {
13-
@include _cdk-textarea-autosize-measuring-base;
13+
@include _autosize-measuring-base;
1414
height: auto !important;
1515
overflow: hidden !important;
1616
}
@@ -22,7 +22,7 @@
2222
// browsers they are, e.g. Chrome detects longer text and IE does't resize back to normal.
2323
// Identical issue report: https://bugzilla.mozilla.org/show_bug.cgi?id=448784
2424
textarea.cdk-textarea-autosize-measuring-firefox {
25-
@include _cdk-textarea-autosize-measuring-base;
25+
@include _autosize-measuring-base;
2626
height: 0 !important;
2727
}
2828
}
@@ -47,7 +47,7 @@
4747
}
4848
}
4949

50-
@mixin _cdk-textarea-autosize-measuring-base {
50+
@mixin _autosize-measuring-base {
5151
// Having 2px top and bottom padding seems to fix a bug where Chrome gets an incorrect
5252
// measurement. We just have to account for it later and subtract it off the final result.
5353
padding: 2px 0 !important;
@@ -79,8 +79,7 @@ $autofill-color-frame-count: 0;
7979
cdk-text-field-autofill-color-#{$autofill-color-frame-count} both;
8080
}
8181

82-
$autofill-color-frame-count:
83-
$autofill-color-frame-count + 1 !global;
82+
$autofill-color-frame-count: $autofill-color-frame-count + 1 !global;
8483
}
8584

8685
// @deprecated Use `autosize` and `autofill` instead.

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

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $mat-button-state-target: '.mdc-button__ripple';
1919
$mat-fab-state-target: '.mdc-fab__ripple';
2020

2121
// Applies the disabled theme color to the text color.
22-
@mixin _mat-button-disabled-color() {
22+
@mixin _disabled-color() {
2323
@include mdc-theme.prop(color,
2424
mdc-theme-color.ink-color-for-fill_(disabled, mdc-theme-color.$background));
2525
}
@@ -30,7 +30,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
3030
// previously set theme color, so it must be ordered after the theme styles.
3131
// TODO(andrewseguin): Discuss with the MDC team to see if we can avoid the :not(:disabled) by
3232
// manually styling disabled buttons with a [disabled] selector.
33-
@mixin _mat-button-apply-disabled-style() {
33+
@mixin _apply-disabled-style() {
3434
&[disabled][disabled] {
3535
@content;
3636
}
@@ -39,7 +39,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
3939
// The MDC button's ripple ink color is based on the theme color, not on the foreground base
4040
// which is what the ripple mixin uses. This creates a new theme that sets the color to the
4141
// foreground base to appropriately color the ink.
42-
@mixin _mat-button-ripple-ink-color($mdcColor) {
42+
@mixin _ripple-color($mdcColor) {
4343
@include ripple-theme.theme((
4444
foreground: (
4545
base: mdc-theme-color.prop-value($mdcColor)
@@ -51,7 +51,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
5151
// mixin `mdc-button--filled`.
5252
// TODO(andrewseguin): Discuss with the MDC team about providing a variable for the 0.12 value
5353
// or otherwise have a mixin we can call to apply this style for both button and anchors.
54-
@mixin _mat-button-disabled-background() {
54+
@mixin _disabled-background() {
5555
@include mdc-theme.prop(background-color,
5656
rgba(mdc-theme-color.prop-value(on-surface), 0.12));
5757
}
@@ -78,23 +78,23 @@ $mat-fab-state-target: '.mdc-fab__ripple';
7878
@include mdc-ripple-theme.states-base-color(primary,
7979
$query: mdc-helpers.$mat-theme-styles-query,
8080
$ripple-target: $mat-button-state-target);
81-
@include _mat-button-ripple-ink-color(primary);
81+
@include _ripple-color(primary);
8282
}
8383

8484
&.mat-accent {
8585
@include mdc-button-theme.ink-color(secondary, $query: mdc-helpers.$mat-theme-styles-query);
8686
@include mdc-ripple-theme.states-base-color(secondary,
8787
$query: mdc-helpers.$mat-theme-styles-query,
8888
$ripple-target: $mat-button-state-target);
89-
@include _mat-button-ripple-ink-color(secondary);
89+
@include _ripple-color(secondary);
9090
}
9191

9292
&.mat-warn {
9393
@include mdc-button-theme.ink-color(error, $query: mdc-helpers.$mat-theme-styles-query);
9494
@include mdc-ripple-theme.states-base-color(error,
9595
$query: mdc-helpers.$mat-theme-styles-query,
9696
$ripple-target: $mat-button-state-target);
97-
@include _mat-button-ripple-ink-color(error);
97+
@include _ripple-color(error);
9898
}
9999
}
100100

@@ -117,7 +117,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
117117
@include mdc-ripple-theme.states-base-color(on-primary,
118118
$query: mdc-helpers.$mat-theme-styles-query,
119119
$ripple-target: $mat-button-state-target);
120-
@include _mat-button-ripple-ink-color(on-primary);
120+
@include _ripple-color(on-primary);
121121
}
122122

123123
&.mat-accent {
@@ -128,7 +128,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
128128
@include mdc-ripple-theme.states-base-color(on-secondary,
129129
$query: mdc-helpers.$mat-theme-styles-query,
130130
$ripple-target: $mat-button-state-target);
131-
@include _mat-button-ripple-ink-color(on-secondary);
131+
@include _ripple-color(on-secondary);
132132
}
133133

134134
&.mat-warn {
@@ -138,11 +138,11 @@ $mat-fab-state-target: '.mdc-fab__ripple';
138138
@include mdc-ripple-theme.states-base-color(on-error,
139139
$query: mdc-helpers.$mat-theme-styles-query,
140140
$ripple-target: $mat-button-state-target);
141-
@include _mat-button-ripple-ink-color(on-error);
141+
@include _ripple-color(on-error);
142142
}
143143

144-
@include _mat-button-apply-disabled-style() {
145-
@include _mat-button-disabled-background();
144+
@include _apply-disabled-style() {
145+
@include _disabled-background();
146146
}
147147
}
148148

@@ -167,21 +167,21 @@ $mat-fab-state-target: '.mdc-fab__ripple';
167167
$query: mdc-helpers.$mat-theme-styles-query);
168168
}
169169

170-
@include _mat-button-apply-disabled-style() {
170+
@include _apply-disabled-style() {
171171
@include mdc-theme.prop(border-color,
172172
mdc-theme-color.ink-color-for-fill_(disabled, mdc-theme-color.$background));
173173
}
174174
}
175175

176176
.mat-mdc-raised-button {
177-
@include _mat-button-apply-disabled-style() {
177+
@include _apply-disabled-style() {
178178
@include mdc-elevation-theme.elevation(0, $query: mdc-helpers.$mat-theme-styles-query);
179179
}
180180
}
181181

182182
.mat-mdc-button, .mat-mdc-raised-button, .mat-mdc-unelevated-button, .mat-mdc-outlined-button {
183-
@include _mat-button-apply-disabled-style() {
184-
@include _mat-button-disabled-color();
183+
@include _apply-disabled-style() {
184+
@include _disabled-color();
185185
}
186186
}
187187

@@ -249,7 +249,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
249249
@include mdc-fab-theme.container-color(primary,
250250
$query: mdc-helpers.$mat-theme-styles-query);
251251
@include mdc-fab-theme.ink-color(on-primary, $query: mdc-helpers.$mat-theme-styles-query);
252-
@include _mat-button-ripple-ink-color(on-primary);
252+
@include _ripple-color(on-primary);
253253
}
254254

255255
&.mat-accent {
@@ -259,7 +259,7 @@ $mat-fab-state-target: '.mdc-fab__ripple';
259259
@include mdc-fab-theme.container-color(secondary,
260260
$query: mdc-helpers.$mat-theme-styles-query);
261261
@include mdc-fab-theme.ink-color(on-secondary, $query: mdc-helpers.$mat-theme-styles-query);
262-
@include _mat-button-ripple-ink-color(on-secondary);
262+
@include _ripple-color(on-secondary);
263263
}
264264

265265
&.mat-warn {
@@ -268,12 +268,12 @@ $mat-fab-state-target: '.mdc-fab__ripple';
268268
$ripple-target: $mat-fab-state-target);
269269
@include mdc-fab-theme.container-color(error, $query: mdc-helpers.$mat-theme-styles-query);
270270
@include mdc-fab-theme.ink-color(on-error, $query: mdc-helpers.$mat-theme-styles-query);
271-
@include _mat-button-ripple-ink-color(on-error);
271+
@include _ripple-color(on-error);
272272
}
273273

274-
@include _mat-button-apply-disabled-style() {
275-
@include _mat-button-disabled-color();
276-
@include _mat-button-disabled-background();
274+
@include _apply-disabled-style() {
275+
@include _disabled-color();
276+
@include _disabled-background();
277277
@include mdc-elevation-theme.elevation(0, $query: mdc-helpers.$mat-theme-styles-query);
278278
}
279279
}
@@ -324,27 +324,27 @@ $mat-fab-state-target: '.mdc-fab__ripple';
324324
$query: mdc-helpers.$mat-theme-styles-query,
325325
$ripple-target: $mat-button-state-target);
326326
@include mdc-icon-button.ink-color(primary, $query: mdc-helpers.$mat-theme-styles-query);
327-
@include _mat-button-ripple-ink-color(primary);
327+
@include _ripple-color(primary);
328328
}
329329

330330
&.mat-accent {
331331
@include mdc-ripple-theme.states-base-color(secondary,
332332
$query: mdc-helpers.$mat-theme-styles-query,
333333
$ripple-target: $mat-button-state-target);
334334
@include mdc-icon-button.ink-color(secondary, $query: mdc-helpers.$mat-theme-styles-query);
335-
@include _mat-button-ripple-ink-color(secondary);
335+
@include _ripple-color(secondary);
336336
}
337337

338338
&.mat-warn {
339339
@include mdc-ripple-theme.states-base-color(error,
340340
$query: mdc-helpers.$mat-theme-styles-query,
341341
$ripple-target: $mat-button-state-target);
342342
@include mdc-icon-button.ink-color(error, $query: mdc-helpers.$mat-theme-styles-query);
343-
@include _mat-button-ripple-ink-color(error);
343+
@include _ripple-color(error);
344344
}
345345

346-
@include _mat-button-apply-disabled-style() {
347-
@include _mat-button-disabled-color();
346+
@include _apply-disabled-style() {
347+
@include _disabled-color();
348348
}
349349
}
350350

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Mixin that sets the vertical spacing for the infix container of filled form fields.
88
// We need to apply spacing to the infix container because we removed the input padding
99
// provided by MDC in order to support arbitrary form-field controls.
10-
@mixin _mat-mdc-form-field-infix-vertical-spacing-filled($with-label-padding, $no-label-padding) {
10+
@mixin _infix-vertical-spacing-filled($with-label-padding, $no-label-padding) {
1111
.mat-mdc-text-field-wrapper:not(.mdc-text-field--outlined) .mat-mdc-form-field-infix {
1212
padding-top: map.get($with-label-padding, top);
1313
padding-bottom: map.get($with-label-padding, bottom);
@@ -23,7 +23,7 @@
2323
// Mixin that sets the vertical spacing for the infix container of outlined form fields.
2424
// We need to apply spacing to the infix container because we removed the input padding
2525
// provided by MDC in order to support arbitrary form-field controls.
26-
@mixin _mat-mdc-form-field-infix-vertical-spacing-outlined($padding) {
26+
@mixin _infix-vertical-spacing-outlined($padding) {
2727
.mat-mdc-text-field-wrapper.mdc-text-field--outlined .mat-mdc-form-field-infix {
2828
padding-top: map.get($padding, top);
2929
padding-bottom: map.get($padding, bottom);
@@ -98,13 +98,13 @@
9898
// aligned as if there is no label. This is done similarly in MDC and is specified in the
9999
// Material Design specification. Outline form fields position the control as if there is no
100100
// label. This is because the label overflows the form-field and doesn't need space at the top.
101-
@include _mat-mdc-form-field-infix-vertical-spacing-outlined($no-label-padding);
101+
@include _infix-vertical-spacing-outlined($no-label-padding);
102102

103103
// MDC hides labels for filled form fields when the form field height decreases. We match
104104
// this behavior in our custom density styles.
105105
@if $hide-filled-floating-label {
106106
// Update the spacing for filled form fields to account for the hidden floating label.
107-
@include _mat-mdc-form-field-infix-vertical-spacing-filled(
107+
@include _infix-vertical-spacing-filled(
108108
$no-label-padding, $no-label-padding);
109109
.mat-mdc-text-field-wrapper:not(.mdc-text-field--outlined) .mdc-floating-label {
110110
display: none;
@@ -114,7 +114,7 @@
114114
// By default, filled form fields align their controls differently based on whether there
115115
// is a label or not. MDC does this too, but we cannot rely on their styles as we support
116116
// arbitrary form field controls and MDC only applies their spacing to the `<input>` elements.
117-
@include _mat-mdc-form-field-infix-vertical-spacing-filled(
117+
@include _infix-vertical-spacing-filled(
118118
$with-label-padding, $no-label-padding);
119119
}
120120
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
// Mixin that overwrites the default MDC text-field color styles to be based on
1818
// the given theme palette. The MDC text-field is styled using `primary` by default.
19-
@mixin _mat-mdc-text-field-color-styles($palette-name,
19+
@mixin _color-styles($palette-name,
2020
$query: mdc-helpers.$mat-theme-styles-query) {
21-
$_mdc-text-field-focused-label-color: mdc-textfield.$focused-label-color;
21+
$orig-focused-label-color: mdc-textfield.$focused-label-color;
2222
mdc-textfield.$focused-label-color: rgba(mdc-theme-color.prop-value($palette-name), 0.87);
2323

2424
@include mdc-textfield.caret-color($palette-name, $query);
@@ -36,7 +36,7 @@
3636
@include mdc-textfield.focused-outline-color($palette-name, $query);
3737
}
3838

39-
mdc-textfield.$focused-label-color: $_mdc-text-field-focused-label-color;
39+
mdc-textfield.$focused-label-color: $orig-focused-label-color;
4040
}
4141

4242
@mixin color($config-or-theme) {
@@ -52,11 +52,11 @@
5252
@include form-field-native-select.private-form-field-native-select-color($config);
5353

5454
.mat-mdc-form-field.mat-accent {
55-
@include _mat-mdc-text-field-color-styles(secondary);
55+
@include _color-styles(secondary);
5656
}
5757

5858
.mat-mdc-form-field.mat-warn {
59-
@include _mat-mdc-text-field-color-styles(error);
59+
@include _color-styles(error);
6060
}
6161
}
6262
}

src/material-experimental/mdc-helpers/_focus-indicators-theme.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@use '../../material/core/theming/theming';
44

55
// Mixin that applies the border color for the focus indicators.
6-
@mixin _mat-mdc-strong-focus-indicators-border-color($color) {
6+
@mixin _border-color($color) {
77
.mat-mdc-focus-indicator::before {
88
border-color: $color;
99
}
@@ -12,7 +12,7 @@
1212
@mixin color($config-or-theme) {
1313
$config: theming.get-color-config($config-or-theme);
1414
$border-color: theming.get-color-from-palette(map.get($config, primary));
15-
@include _mat-mdc-strong-focus-indicators-border-color($border-color);
15+
@include _border-color($border-color);
1616
}
1717

1818
/// Mixin that sets the color of the focus indicators.
@@ -33,7 +33,7 @@
3333
// stylelint-disable-next-line material/theme-mixin-api
3434
@mixin theme($theme-or-color) {
3535
@if meta.type-of($theme-or-color) != 'map' {
36-
@include _mat-mdc-strong-focus-indicators-border-color($theme-or-color);
36+
@include _border-color($theme-or-color);
3737
}
3838
@else {
3939
$theme: theming.private-legacy-get-theme($theme-or-color);

0 commit comments

Comments
 (0)