Skip to content

Commit 028f89b

Browse files
committed
fix(multiple): resolve sass if function deprecation warnings (#32674)
[Sass has deprecated the `if` function](https://sass-lang.com/documentation/breaking-changes/if-function) in order to support the native CSS `if()`. These changes update all of our usages so users don't get deprecation warnings. Note that I decided to replace it with `@if`/`@else`, instead of the new syntax, because the new syntax is: 1. Harder to follow, in my opinion. 2. Likely going to break users that aren't on the absolute latest version of Sass. (cherry picked from commit f3357c1)
1 parent 3de1770 commit 028f89b

29 files changed

+243
-84
lines changed

.stylelintrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
"function-url-quotes": "always",
7272
"function-url-scheme-disallowed-list": ["data"],
7373
"function-whitespace-after": "always",
74+
"function-disallowed-list": ["if"],
7475

7576
"number-leading-zero": "always",
7677
"number-no-trailing-zeros": true,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@
132132
"rollup": "^4.52.3",
133133
"rollup-plugin-dts": "6.3.0",
134134
"rollup-plugin-sourcemaps2": "0.5.4",
135-
"sass": "^1.80.6",
135+
"sass": "^1.97.2",
136136
"selenium-webdriver": "^3.6.0",
137137
"semver": "^7.3.5",
138138
"shelljs": "^0.10.0",

pnpm-lock.yaml

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

src/cdk/a11y/_index.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,13 @@
5454
'Allowed values are "active" and "none"';
5555
}
5656

57-
@media (forced-colors: #{if($target == none, none, active)}) {
57+
$query-value: active;
58+
59+
@if ($target == none) {
60+
$query-value: none;
61+
}
62+
63+
@media (forced-colors: #{$query-value}) {
5864
@content;
5965
}
6066
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,16 @@
33
// well. We reset some properties here to prevent these container elements from introducing
44
// additional space that would throw off the scrolling calculations.
55
@mixin _clear-container-space($direction) {
6-
$start: if($direction == horizontal, 'left', 'top');
7-
$end: if($direction == horizontal, 'right', 'bottom');
6+
$start: '';
7+
$end: '';
8+
9+
@if ($direction == horizontal) {
10+
$start: 'left';
11+
$end: 'right';
12+
} @else {
13+
$start: 'top';
14+
$end: 'bottom';
15+
}
816

917
& > dl:not([cdkVirtualFor]),
1018
& > ol:not([cdkVirtualFor]),

src/material/badge/badge.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ $large-size: $default-size + 6;
1010
$fallbacks: m3-badge.get-tokens();
1111

1212
@mixin _badge-size($size) {
13-
$prefix: if($size == 'medium', '', $size + '-size-');
13+
$prefix: '';
14+
15+
@if ($size != 'medium') {
16+
$prefix: $size + '-size-';
17+
}
18+
1419
$legacy-size-var-name: 'badge-legacy-#{$prefix}container-size';
1520
$size-var-name: 'badge-#{$prefix}container-size';
1621

src/material/button/_m2-button.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,12 @@
1616
-2: 28px,
1717
-3: 24px,
1818
), $scale);
19-
$touch-target-display: if($scale < -1, none, block);
2019
$touch-target-size: 48px;
20+
$touch-target-display: block;
21+
22+
@if ($scale < -1) {
23+
$touch-target-display: none;
24+
}
2125

2226
@return (
2327
base: (

src/material/button/_m2-fab.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
$disabled-container : m3-utils.color-with-opacity(map.get($system, on-surface), 12%);
1818
$density-scale: theming.clamp-density(map.get($system, density-scale), -3);
1919
$touch-target-size: 48px;
20+
$touch-target-display: block;
21+
22+
@if ($density-scale < -1) {
23+
$touch-target-display: none;
24+
}
2025

2126
@return (
2227
base: (
@@ -70,8 +75,8 @@
7075
fab-extended-label-text-weight: map.get($system, label-small-weight)
7176
),
7277
density: (
73-
fab-small-touch-target-display: if($density-scale < -1, none, block),
74-
fab-touch-target-display: if($density-scale < -1, none, block),
78+
fab-small-touch-target-display: $touch-target-display,
79+
fab-touch-target-display: $touch-target-display,
7580
),
7681
);
7782
}

src/material/button/_m2-icon-button.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
@function get-tokens($theme) {
77
$system: m2-utils.get-system($theme);
88
$density-scale: theming.clamp-density(map.get($system, density-scale), -3);
9+
$touch-target-display: block;
10+
11+
@if ($density-scale < -1) {
12+
$touch-target-display: none;
13+
}
914

1015
@return (
1116
base: (
@@ -27,7 +32,7 @@
2732
),
2833
typography: (),
2934
density: (
30-
icon-button-touch-target-display: if($density-scale < -1, none, block),
35+
icon-button-touch-target-display: $touch-target-display,
3136
icon-button-state-layer-size: map.get((
3237
0: 48px,
3338
-1: 44px,

src/material/checkbox/_m2-checkbox.scss

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
@function get-tokens($theme) {
77
$system: m2-utils.get-system($theme);
88
$density-scale: theming.clamp-density(map.get($system, density-scale), -3);
9+
$touch-target-display: block;
10+
11+
@if ($density-scale < -1) {
12+
$touch-target-display: none;
13+
}
914

1015
@return (
1116
base: (
@@ -28,7 +33,7 @@
2833
checkbox-label-text-weight: map.get($system, body-medium-weight)
2934
),
3035
density: (
31-
checkbox-touch-target-display: if($density-scale < -1, none, block),
36+
checkbox-touch-target-display: $touch-target-display,
3237
checkbox-state-layer-size: map.get((
3338
0: 40px,
3439
-1: 36px,

0 commit comments

Comments
 (0)