Skip to content

Commit 1e969dd

Browse files
authored
fix(material/core): add flag whether to copy color theme values (#25695)
* fix(material/core): add flag whether to copy color theme values * fix(material/core): remove legacy theming in devapp
1 parent 74825c8 commit 1e969dd

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/dev-app/theme.scss

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,17 @@ $candy-app-theme: mat.define-light-theme((
4545
$dark-primary: mat.define-palette(mat.$blue-grey-palette);
4646
$dark-accent: mat.define-palette(mat.$amber-palette, A200, A100, A400);
4747
$dark-warn: mat.define-palette(mat.$deep-orange-palette);
48-
$dark-colors: mat.define-dark-theme($dark-primary, $dark-accent, $dark-warn);
48+
$dark-colors: mat.define-dark-theme(
49+
(
50+
color: (
51+
primary: $dark-primary,
52+
accent: $dark-accent,
53+
warn: $dark-warn
54+
),
55+
density: 0,
56+
typography: mat.define-typography-config(),
57+
)
58+
);
4959

5060
// Include the dark theme color styles.
5161
@include mat.all-component-colors($dark-colors);
@@ -55,7 +65,7 @@ $candy-app-theme: mat.define-light-theme((
5565

5666
// Include the dark theme colors for focus indicators.
5767
&.demo-strong-focus {
58-
@include mat.strong-focus-indicators-theme($dark-colors);
68+
@include mat.strong-focus-indicators-color($dark-colors);
5969
}
6070
}
6171

src/material/core/theming/_theming.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ $_legacy-theme-warning: 'Angular Material themes should be created from a map co
2525
// comprehensive theme configurations.
2626
$_enable-strict-theme-config: false;
2727

28+
// Flag whether to disable theme definitions copying color values to the top-level theme config.
29+
// This copy is to preserve backwards compatibility.
30+
$_disable-color-backwards-compatibility: false;
31+
2832
// These variable are not intended to be overridden externally. They use `!default` to
2933
// avoid being reset every time this file is imported.
3034
$_emitted-color: () !default;
@@ -436,7 +440,7 @@ $_emitted-density: () !default;
436440
// is stored in `$theme.color` which contains a property for `primary`. This method copies
437441
// the map from `$theme.color` to `$theme` for backwards compatibility.
438442
@function private-create-backwards-compatibility-theme($theme) {
439-
@if not map.get($theme, color) {
443+
@if ($_disable-color-backwards-compatibility or not map.get($theme, color)) {
440444
@return $theme;
441445
}
442446
$color: map.get($theme, color);

0 commit comments

Comments
 (0)