Skip to content

Commit

Permalink
fixup! test: Add additional tests and validation for theme definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Aug 14, 2023
1 parent 6d27dd3 commit 8afc00e
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/material-experimental/theming/_config-validation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
@use '@angular/material' as mat;
@use './m3-palettes';

/// Updates an error message by finding `$config` and appending a suffix to it.
/// Creates an error message by finding `$config` in the existing message and appending a suffix to
/// it.
/// @param {List|String} $err The error message.
/// @param {String} $suffix The suffix to add.
/// @return {List|String} The updated error message.
@function _update-dollar-config($err, $suffix) {
@function _create-dollar-config-error-message($err, $suffix) {
@if meta.type-of($err) == 'list' {
@for $i from 1 through list.length($err) {
$err: list.set-nth($err, $i, _update-dollar-config(list.nth($err, $i), $suffix));
$err: list.set-nth($err, $i,
_create-dollar-config-error-message(list.nth($err, $i), $suffix));
}
}
@else if meta.type-of($err) == 'string' {
} @else if meta.type-of($err) == 'string' {
$start: string.index($err, '$config');
@if $start {
$err: string.insert($err, $suffix, $start + 7);
Expand Down Expand Up @@ -66,15 +67,15 @@
}
$err: validate-color-config(map.get($config, color));
@if $err {
@return _update-dollar-config($err, '.color');
@return _create-dollar-config-error-message($err, '.color');
}
$err: validate-typography-config(map.get($config, typography));
@if $err {
@return _update-dollar-config($err, '.typography');
@return _create-dollar-config-error-message($err, '.typography');
}
$err: validate-density-config(map.get($config, density));
@if $err {
@return _update-dollar-config($err, '.density');
@return _create-dollar-config-error-message($err, '.density');
}
@return null;
}
Expand Down

0 comments on commit 8afc00e

Please sign in to comment.