Skip to content

Commit c2343a4

Browse files
committed
fix(material-experimental/theming): Make color API back-cmpat styles available
1 parent 127597f commit c2343a4

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

src/dev-app/BUILD.bazel

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web")
2-
load("//tools:defaults.bzl", "devmode_esbuild", "esbuild_config", "http_server", "ng_module", "sass_binary", "sass_library")
2+
load("//tools:defaults.bzl", "devmode_esbuild", "esbuild_config", "http_server", "ng_module", "sass_binary")
33
load("//src/components-examples:config.bzl", "ALL_EXAMPLES")
44
load("//tools/angular:index.bzl", "LINKER_PROCESSED_FW_PACKAGES")
55

@@ -105,21 +105,12 @@ devmode_esbuild(
105105
],
106106
)
107107

108-
sass_library(
109-
name = "color-api-back-compat",
110-
srcs = glob(["**/_*.scss"]),
111-
deps = [
112-
"//src/material:sass_lib",
113-
],
114-
)
115-
116108
sass_binary(
117109
name = "theme",
118110
src = "theme.scss",
119111
deps = [
120112
"//src/material:sass_lib",
121113
"//src/material-experimental:sass_lib",
122-
"//src/material/core:theming_scss_lib",
123114
],
124115
)
125116

@@ -130,7 +121,6 @@ sass_binary(
130121
":color-api-back-compat",
131122
"//src/material:sass_lib",
132123
"//src/material-experimental:sass_lib",
133-
"//src/material/core:theming_scss_lib",
134124
],
135125
)
136126

src/dev-app/theme-m3.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
@use '@angular/material' as mat;
22
@use '@angular/material-experimental' as matx;
3-
@use './color-api-back-compat';
43

54
// Plus imports for other components in your app.
65

@@ -80,10 +79,10 @@ $density-scales: (-1, -2, -3, -4, minimum, maximum);
8079

8180
// Enable back-compat CSS for color="..." API.
8281
.demo-color-api-back-compat {
83-
@include color-api-back-compat.color-variants-back-compat($light-theme);
82+
@include matx.color-variants-back-compat($light-theme);
8483

8584
&.demo-unicorn-dark-theme {
86-
@include color-api-back-compat.color-variants-back-compat($dark-theme);
85+
@include matx.color-variants-back-compat($dark-theme);
8786
}
8887
}
8988

src/material-experimental/_index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
@forward './theming/m3-palettes' as m3-* show $m3-red-palette, $m3-green-palette, $m3-blue-palette,
1010
$m3-yellow-palette, $m3-cyan-palette, $m3-magenta-palette, $m3-orange-palette,
1111
$m3-chartreuse-palette, $m3-azure-palette, $m3-violet-palette, $m3-rose-palette;
12+
@forward './theming/color-api-back-compat' show color-variants-back-compat;
1213

1314
// Additional public APIs for individual components

src/dev-app/_color-api-back-compat.scss renamed to src/material-experimental/theming/_color-api-back-compat.scss

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
@use '@angular/material' as mat;
22

33
@mixin color-variant-styles($theme, $color-variant) {
4-
@include mat.option-color($theme, $color-variant: $color-variant);
4+
// Some components use the secondary color rather than primary color for `.mat-primary`.
5+
// Those components should use the $secondary-color-variant.
6+
$secondary-color-variant: if($color-variant == primary, secondary, $color-variant);
7+
8+
@include mat.option-color($theme, $color-variant: $secondary-color-variant);
59
@include mat.progress-spinner-color($theme, $color-variant: $color-variant);
610
@include mat.pseudo-checkbox-color($theme, $color-variant: $color-variant);
711
@include mat.stepper-color($theme, $color-variant: $color-variant);
@@ -52,7 +56,7 @@
5256
}
5357

5458
&.mat-mdc-standard-chip {
55-
@include mat.chips-color($theme, $color-variant: $color-variant);
59+
@include mat.chips-color($theme, $color-variant: $secondary-color-variant);
5660
}
5761

5862
.mdc-list-item__start,
@@ -70,8 +74,6 @@
7074
}
7175
}
7276

73-
// TODO(mmalerba): Consider adding this as a back-compat API for users who want it, rather than just
74-
// a demo thing.
7577
@mixin color-variants-back-compat($theme) {
7678
.mat-primary {
7779
@include color-variant-styles($theme, primary);

0 commit comments

Comments
 (0)