Skip to content

fix(material/core): correctly identify color input #29909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/material/core/theming/_config-validation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/// Validates that the given object is an M3 palette.
/// @param {*} $palette The object to test
/// @return {Boolean|null} null if it is a valid M3 palette, else true.
@function _validate-palette($palette) {
@function validate-palette($palette) {
@if not meta.type-of($palette) == 'map' {
@return true;
}
Expand Down Expand Up @@ -108,7 +108,7 @@
}
@each $palette in (primary, secondary, tertiary) {
@if $config and map.has-key($config, $palette) {
$err: _validate-palette(map.get($config, $palette));
$err: validate-palette(map.get($config, $palette));
@if $err {
@return (
#{'Expected $config.#{$palette} to be a valid M3 palette. Got:'}
Expand Down
12 changes: 8 additions & 4 deletions src/material/core/tokens/_m3-system.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@use '../style/elevation';
@use '../style/sass-utils';
@use '../theming/config-validation';
@use '../theming/definition';
@use './m3/definitions';
@use 'sass:map';
Expand Down Expand Up @@ -44,14 +45,17 @@ $_system-level-prefix: sys;
$color: map.get($config, color);
$color-config: null;
@if ($color) {
// validate-palette returns null if it is a valid M3 palette
$is-palette: config-validation.validate-palette($color) == null;

// Default to "color-scheme" theme type if the config's color does not provide one.
@if (meta.type-of($color) == 'map' and not map.has-key($color, theme-type)) {
@if (not $is-palette and not map.has-key($color, theme-type)) {
$color: map.set($color, theme-type, color-scheme);
}

$color-config: if(meta.type-of($color) == 'map',
definition.define-colors($color),
definition.define-colors((primary: $color, theme-type: color-scheme)));
$color-config: if($is-palette,
definition.define-colors((primary: $color, theme-type: color-scheme)),
definition.define-colors($color));
@include system-level-colors($color-config, $overrides, $_system-fallback-prefix);
@include system-level-elevation($color-config, $overrides, $_system-fallback-prefix);
}
Expand Down
Loading