Skip to content

Commit

Permalink
fix(material/core): add optional warning for incomplete themes (#25654)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewseguin committed Sep 18, 2022
1 parent d082d4d commit c14d176
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/material/core/theming/_theming.scss
Expand Up @@ -20,6 +20,11 @@ $_legacy-theme-warning: 'Angular Material themes should be created from a map co
'palette values for "primary", "accent", and "warn". ' +
'See https://material.angular.io/guide/theming for more information.';

// Flag whether theme config getter functions should warn if a key is expected to exist but not
// present in the config. This can be transformed internally in Google to ensure all clients have
// comprehensive theme configurations.
$_enable-strict-theme-config: false;

// These variable are not intended to be overridden externally. They use `!default` to
// avoid being reset every time this file is imported.
$_emitted-color: () !default;
Expand Down Expand Up @@ -255,6 +260,9 @@ $_emitted-density: () !default;
@if map.has-key($theme, color) {
@return map.get($theme, color);
}
@else if ($_enable-strict-theme-config) {
@error 'Angular Material theme configuration is missing a "color" value';
}
@return $default;
}

Expand All @@ -274,6 +282,9 @@ $_emitted-density: () !default;
@if map.has-key($theme-or-config, density) {
@return map.get($theme-or-config, density);
}
@else if ($_enable-strict-theme-config) {
@error 'Angular Material theme configuration is missing a "density" value';
}
@return $default;
}

Expand All @@ -294,6 +305,9 @@ $_emitted-density: () !default;
@if (map.has-key($theme-or-config, typography)) {
@return map.get($theme-or-config, typography);
}
@else if ($_enable-strict-theme-config) {
@error 'Angular Material theme configuration is missing a "typography" value';
}
@return $default;
}

Expand Down

0 comments on commit c14d176

Please sign in to comment.