Skip to content

Commit bf9f2ec

Browse files
authored
fix(material/core): warn when legacy theme is created (#25625)
* fix(material/core): warn when legacy theme is created * fix(material/core): update message * fix(material/core): update message * fix(material/core): update message * fix(material/core): update message * fix(material/core): update message
1 parent e0cccc7 commit bf9f2ec

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/material/core/theming/_theming.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ $_generate-default-density: true !default;
1414
$_duplicate-warning: 'Read more about how style duplication can be avoided in a dedicated ' +
1515
'guide. https://github.com/angular/components/blob/main/guides/duplicate-theming-styles.md';
1616

17+
// Warning that will be printed if the legacy theming API is used.
18+
$_legacy-theme-warning: 'Angular Material themes should be created from a map containing the ' +
19+
'keys "color", "typography", and "density". The color value should be a map containing the ' +
20+
'palette values for "primary", "accent", and "warn". ' +
21+
'See https://material.angular.io/guide/theming for more information.';
22+
1723
// These variable are not intended to be overridden externally. They use `!default` to
1824
// avoid being reset every time this file is imported.
1925
$_emitted-color: () !default;
@@ -167,6 +173,7 @@ $_emitted-density: () !default;
167173
// If the legacy pattern is used, we generate a container object only with a light-themed
168174
// configuration for the `color` theming part.
169175
@if $accent != null {
176+
@warn $_legacy-theme-warning;
170177
@return private-create-backwards-compatibility-theme(_mat-validate-theme((
171178
_is-legacy-theme: true,
172179
color: _mat-create-light-color-config($primary, $accent, $warn),
@@ -207,6 +214,7 @@ $_emitted-density: () !default;
207214
// If the legacy pattern is used, we generate a container object only with a dark-themed
208215
// configuration for the `color` theming part.
209216
@if $accent != null {
217+
@warn $_legacy-theme-warning;
210218
@return private-create-backwards-compatibility-theme(_mat-validate-theme((
211219
_is-legacy-theme: true,
212220
color: _mat-create-dark-color-config($primary, $accent, $warn),
@@ -432,6 +440,8 @@ $_emitted-density: () !default;
432440
@if private-is-theme-object($theme-or-color-config) {
433441
@return $theme-or-color-config;
434442
}
443+
444+
@warn $_legacy-theme-warning;
435445
@return private-create-backwards-compatibility-theme((
436446
_is-legacy-theme: true,
437447
color: $theme-or-color-config

0 commit comments

Comments
 (0)