Skip to content

Commit 821a9ee

Browse files
committed
fix test failures
1 parent e815afd commit 821a9ee

File tree

6 files changed

+57
-16
lines changed

6 files changed

+57
-16
lines changed

src/material/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
@if inspection.theme-has($theme, density) {
8585
@include _density($theme);
8686
}
87-
@if inspection.theme-has($theme, typoraphyg) {
87+
@if inspection.theme-has($theme, typography) {
8888
@include typography($theme);
8989
}
9090
}

src/material/core/style/_sass-utils.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
@use 'sass:color';
12
@use 'sass:map';
23
@use 'sass:meta';
34

@@ -47,3 +48,9 @@
4748
@function coerce-to-list($value) {
4849
@return if(meta.type-of($value) != 'list', ($value,), $value);
4950
}
51+
52+
/// A version of the Sass `color.change` function that is safe ot use with CSS variables.
53+
@function safe-color-change($color, $args...) {
54+
$args: meta.keywords($args);
55+
@return if(meta.type-of($color) == 'color', color.change($color, $args...), $color);
56+
}

src/material/core/theming/_m2-inspection.scss

Lines changed: 46 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@
77

88
$_internals: _mat-theming-internals-do-not-access;
99

10+
$_color-keys: (
11+
primary,
12+
accent,
13+
warn,
14+
foreground,
15+
background,
16+
is-dark,
17+
color, /* included for themes that incorrectly nest the color config: (color: (color: (....))) */
18+
);
19+
20+
$_typography-keys: (
21+
headline-1,
22+
headline-2,
23+
headline-3,
24+
headline-4,
25+
headline-5,
26+
headline-6,
27+
subtitle-1,
28+
font-famiy,
29+
subtitle-2,
30+
body-1,
31+
body-2,
32+
button,
33+
caption,
34+
overline,
35+
);
36+
1037
$_typography-properties: (font, font-family, line-height, font-size, letter-spacing, font-weight);
1138

1239
/// Checks whether the given theme contains error objects.
@@ -137,22 +164,29 @@ $_typography-properties: (font, font-family, line-height, font-size, letter-spac
137164
@return true;
138165
}
139166
@if $system == color {
140-
@if not theming.private-is-theme-object($theme) {
141-
@return map.has-key($theme, primary);
142-
}
143-
@return theming.get-color-config($theme) != null;
167+
$color: theming.get-color-config($theme);
168+
@return $color != null and _has-any-key($color, $_color-keys);
144169
}
145170
@if $system == typography {
146-
@if not theming.private-is-theme-object($theme) {
147-
@return map.has-key($theme, body-1);
148-
}
149-
@return theming.get-typography-config($theme) != null;
171+
$typography: theming.get-typography-config($theme);
172+
@return $typography != null and _has-any-key($typography, $_typography-keys);
150173
}
151174
@if $system == density {
152-
@if not theming.private-is-theme-object($theme) {
153-
@return $theme == minimum or $theme == maximum or meta.type-of($theme) == 'number';
154-
}
155-
@return theming.get-density-config($theme) != null;
175+
$density: theming.get-density-config($theme);
176+
@return $density != null and _is-density-value($density);
156177
}
157178
@error 'Valid systems are: base, color, typography, density. Got:' $system;
158179
}
180+
181+
@function _has-any-key($theme, $keys) {
182+
@each $key in $keys {
183+
@if map.has-key($theme, $key) {
184+
@return true;
185+
}
186+
}
187+
@return false;
188+
}
189+
190+
@function _is-density-value($theme) {
191+
@return $theme == minimum or $theme == maximum or meta.type-of($theme) == 'number';
192+
}

src/material/core/tokens/m2/mat/_form-field.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ $prefix: (mat, form-field);
5050
$palette-color: inspection.get-theme-color($theme, $palette-name);
5151

5252
@return (
53-
focus-select-arrow-color: rgba($palette-color, 0.87),
53+
focus-select-arrow-color: sass-utils.safe-color-change($palette-color, $alpha: 0.87),
5454
);
5555
}
5656

src/material/core/tokens/m2/mdc/_filled-text-field.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ $prefix: (mdc, filled-text-field);
138138
@return (
139139
caret-color: $palette-color,
140140
focus-active-indicator-color: $palette-color,
141-
focus-label-text-color: rgba($palette-color, 0.87),
141+
focus-label-text-color: sass-utils.safe-color-change($palette-color, $alpha: 0.87),
142142
);
143143
}
144144

src/material/core/tokens/m2/mdc/_outlined-text-field.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ $prefix: (mdc, outlined-text-field);
121121
@return (
122122
caret-color: $palette-color,
123123
focus-outline-color: $palette-color,
124-
focus-label-text-color: rgba($palette-color, 0.87),
124+
focus-label-text-color: sass-utils.safe-color-change($palette-color, $alpha: 0.87),
125125
);
126126
}
127127

0 commit comments

Comments
 (0)