Skip to content

Commit a3840ed

Browse files
authored
refactor(multiple): disable CSS variable fallbacks in MDC components (#24415)
Since we don't support IE, we don't have to include a fallback for CSS variables in the MDC components.
1 parent 3e10809 commit a3840ed

File tree

8 files changed

+44
-22
lines changed

8 files changed

+44
-22
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ $mat-card-header-size: 40px !default;
1010
// Default padding for text content within a card.
1111
$mat-card-default-padding: 16px !default;
1212

13-
// Include all MDC card styles except for color and typography.
14-
@include mdc-card.without-ripple($query: mdc-helpers.$mat-base-styles-query);
13+
@include mdc-helpers.disable-fallback-declarations {
14+
// Include all MDC card styles except for color and typography.
15+
@include mdc-card.without-ripple($query: mdc-helpers.$mat-base-styles-query);
16+
}
1517

1618
// Title text and subtitles text within a card. MDC doesn't have pre-made title sections for cards.
1719
// Maintained here for backwards compatibility with the previous generation MatCard.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ $mat-dialog-content-max-height: 65vh !default;
99
// don't expose this value as variable.
1010
$mat-dialog-button-horizontal-margin: 8px !default;
1111

12-
@include mdc-dialog.core-styles($query: mdc-helpers.$mat-base-styles-query);
12+
@include mdc-helpers.disable-fallback-declarations {
13+
@include mdc-dialog.core-styles($query: mdc-helpers.$mat-base-styles-query);
14+
}
15+
1316
@include mdc-dialog-structure-overrides.private-dialog-structure-overrides(
1417
$mat-dialog-content-max-height);
1518

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
@use '../mdc-helpers/mdc-helpers';
1313

1414
// Base styles for MDC text-field, notched-outline, floating label and line-ripple.
15-
@include mdc-textfield.without-ripple(
16-
$query: mdc-helpers.$mat-base-styles-without-animation-query);
17-
@include mdc-floating-label.core-styles(
18-
$query: mdc-helpers.$mat-base-styles-without-animation-query);
19-
@include mdc-notched-outline.core-styles(
20-
$query: mdc-helpers.$mat-base-styles-without-animation-query);
21-
@include mdc-line-ripple.core-styles($query: mdc-helpers.$mat-base-styles-without-animation-query);
15+
@include mdc-helpers.disable-fallback-declarations {
16+
@include mdc-textfield.without-ripple(
17+
$query: mdc-helpers.$mat-base-styles-without-animation-query);
18+
@include mdc-floating-label.core-styles(
19+
$query: mdc-helpers.$mat-base-styles-without-animation-query);
20+
@include mdc-notched-outline.core-styles(
21+
$query: mdc-helpers.$mat-base-styles-without-animation-query);
22+
@include mdc-line-ripple.core-styles(
23+
$query: mdc-helpers.$mat-base-styles-without-animation-query);
24+
}
2225

2326
// MDC text-field overwrites.
2427
@include mdc-text-field-textarea-overrides.private-text-field-textarea-overrides();
@@ -119,8 +122,10 @@
119122
// In order to make it possible for developers to disable animations for form-fields,
120123
// we only activate the animation styles if animations are not explicitly disabled.
121124
.mat-mdc-form-field:not(.mat-form-field-no-animations) {
122-
@include mdc-textfield.without-ripple($query: animation);
123-
@include mdc-floating-label.core-styles($query: animation);
124-
@include mdc-notched-outline.core-styles($query: animation);
125-
@include mdc-line-ripple.core-styles($query: animation);
125+
@include mdc-helpers.disable-fallback-declarations {
126+
@include mdc-textfield.without-ripple($query: animation);
127+
@include mdc-floating-label.core-styles($query: animation);
128+
@include mdc-notched-outline.core-styles($query: animation);
129+
@include mdc-line-ripple.core-styles($query: animation);
130+
}
126131
}

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
@use '../../cdk/a11y';
88
@use '../mdc-helpers/mdc-helpers';
99

10-
@include mdc-menu-surface.core-styles($query: structure);
10+
@include mdc-helpers.disable-fallback-declarations {
11+
@include mdc-menu-surface.core-styles($query: structure);
12+
}
1113

1214
// Prevent rendering mat-menu as it can affect the flex layout.
1315
mat-menu {
@@ -37,9 +39,11 @@ mat-menu {
3739
}
3840

3941
.mat-mdc-menu-item {
40-
@include mdc-list-mixins.item-base;
41-
@include mdc-list-mixins.item-spacing(
42-
mdc-list-variables.$side-padding, $query: mdc-helpers.$mat-base-styles-query);
42+
@include mdc-helpers.disable-fallback-declarations {
43+
@include mdc-list-mixins.item-base;
44+
@include mdc-list-mixins.item-spacing(
45+
mdc-list-variables.$side-padding, $query: mdc-helpers.$mat-base-styles-query);
46+
}
4347

4448
// MDC's menu items are `<li>` nodes which don't need resets, however ours
4549
// can be anything, including buttons, so we need to do the reset ourselves.

src/material-experimental/mdc-progress-bar/progress-bar.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@use '@material/linear-progress' as mdc-linear-progress;
22
@use '../mdc-helpers/mdc-helpers';
33

4-
@include mdc-linear-progress.core-styles($query: mdc-helpers.$mat-base-styles-query);
4+
@include mdc-helpers.disable-fallback-declarations {
5+
@include mdc-linear-progress.core-styles($query: mdc-helpers.$mat-base-styles-query);
6+
}
57

68
.mat-mdc-progress-bar {
79
// Explicitly set to `block` since the browser defaults custom elements to `inline`.

src/material-experimental/mdc-progress-spinner/progress-spinner.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
@use '../mdc-helpers/mdc-helpers';
33
@use '../../cdk/a11y';
44

5-
@include mdc-circular-progress.core-styles($query: mdc-helpers.$mat-base-styles-query);
5+
@include mdc-helpers.disable-fallback-declarations {
6+
@include mdc-circular-progress.core-styles($query: mdc-helpers.$mat-base-styles-query);
7+
}
68

79
.mat-mdc-progress-spinner {
810
// Explicitly set to `block` since the browser defaults custom elements to `inline`.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
@use '@material/slider/slider' as mdc-slider;
22
@use '../mdc-helpers/mdc-helpers';
33

4-
@include mdc-slider.without-ripple($query: mdc-helpers.$mat-base-styles-query);
4+
@include mdc-helpers.disable-fallback-declarations {
5+
@include mdc-slider.without-ripple($query: mdc-helpers.$mat-base-styles-query);
6+
}
57

68
$mat-slider-min-size: 128px !default;
79
$mat-slider-horizontal-margin: 8px !default;

src/material-experimental/mdc-snack-bar/snack-bar-container.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
@use '../mdc-helpers/mdc-helpers';
33
@use '../../cdk/a11y';
44

5-
@include mdc-snackbar.core-styles($query: mdc-helpers.$mat-base-styles-query);
5+
@include mdc-helpers.disable-fallback-declarations {
6+
@include mdc-snackbar.core-styles($query: mdc-helpers.$mat-base-styles-query);
7+
}
68

79
// MDC sets the position as fixed and sets the container on the bottom center of the page (or
810
// otherwise can be set to be "leading"). Our overlay handles a more advanced configuration

0 commit comments

Comments
 (0)