From bd22582b174ae6f31d795de24deed1b16a2e0326 Mon Sep 17 00:00:00 2001 From: Andrew Seguin Date: Mon, 12 Sep 2022 12:30:09 -0600 Subject: [PATCH] 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 --- src/material/core/theming/_theming.scss | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/material/core/theming/_theming.scss b/src/material/core/theming/_theming.scss index 851d71aa4bed..f04e0560249b 100644 --- a/src/material/core/theming/_theming.scss +++ b/src/material/core/theming/_theming.scss @@ -14,6 +14,12 @@ $_generate-default-density: true !default; $_duplicate-warning: 'Read more about how style duplication can be avoided in a dedicated ' + 'guide. https://github.com/angular/components/blob/main/guides/duplicate-theming-styles.md'; +// Warning that will be printed if the legacy theming API is used. +$_legacy-theme-warning: 'Angular Material themes should be created from a map containing the ' + + 'keys "color", "typography", and "density". The color value should be a map containing the ' + + 'palette values for "primary", "accent", and "warn". ' + + 'See https://material.angular.io/guide/theming for more information.'; + // 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; @@ -167,6 +173,7 @@ $_emitted-density: () !default; // If the legacy pattern is used, we generate a container object only with a light-themed // configuration for the `color` theming part. @if $accent != null { + @warn $_legacy-theme-warning; @return private-create-backwards-compatibility-theme(_mat-validate-theme(( _is-legacy-theme: true, color: _mat-create-light-color-config($primary, $accent, $warn), @@ -207,6 +214,7 @@ $_emitted-density: () !default; // If the legacy pattern is used, we generate a container object only with a dark-themed // configuration for the `color` theming part. @if $accent != null { + @warn $_legacy-theme-warning; @return private-create-backwards-compatibility-theme(_mat-validate-theme(( _is-legacy-theme: true, color: _mat-create-dark-color-config($primary, $accent, $warn), @@ -432,6 +440,8 @@ $_emitted-density: () !default; @if private-is-theme-object($theme-or-color-config) { @return $theme-or-color-config; } + + @warn $_legacy-theme-warning; @return private-create-backwards-compatibility-theme(( _is-legacy-theme: true, color: $theme-or-color-config