Skip to content

Commit 54c4051

Browse files
committed
fix(material/core): correctly identify color input
1 parent a670949 commit 54c4051

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/material/core/theming/_config-validation.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
/// Validates that the given object is an M3 palette.
3030
/// @param {*} $palette The object to test
3131
/// @return {Boolean|null} null if it is a valid M3 palette, else true.
32-
@function _validate-palette($palette) {
32+
@function validate-palette($palette) {
3333
@if not meta.type-of($palette) == 'map' {
3434
@return true;
3535
}
@@ -108,7 +108,7 @@
108108
}
109109
@each $palette in (primary, secondary, tertiary) {
110110
@if $config and map.has-key($config, $palette) {
111-
$err: _validate-palette(map.get($config, $palette));
111+
$err: validate-palette(map.get($config, $palette));
112112
@if $err {
113113
@return (
114114
#{'Expected $config.#{$palette} to be a valid M3 palette. Got:'}

src/material/core/tokens/_m3-system.scss

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
@use '../style/elevation';
22
@use '../style/sass-utils';
3+
@use '../theming/config-validation';
34
@use '../theming/definition';
45
@use './m3/definitions';
56
@use 'sass:map';
@@ -44,9 +45,12 @@ $_system-level-prefix: sys;
4445
$color: map.get($config, color);
4546
$color-config: null;
4647
@if ($color) {
47-
$color-config: if(meta.type-of($color) == 'map',
48-
definition.define-colors($color),
49-
definition.define-colors((primary: $color)));
48+
// validate-palette returns null if it is a valid M3 palette
49+
$is-palette: config-validation.validate-palette($color) == null;
50+
51+
$color-config: if($is-palette,
52+
definition.define-colors((primary: $color)),
53+
definition.define-colors($color));
5054
@include system-level-colors($color-config, $overrides, $_system-fallback-prefix);
5155
@include system-level-elevation($color-config, $overrides, $_system-fallback-prefix);
5256
}

0 commit comments

Comments
 (0)