diff --git a/src/dev-app/BUILD.bazel b/src/dev-app/BUILD.bazel index 049f6f0fc5c1..5c8cbb90881b 100644 --- a/src/dev-app/BUILD.bazel +++ b/src/dev-app/BUILD.bazel @@ -1,5 +1,5 @@ load("@build_bazel_rules_nodejs//:index.bzl", "pkg_web") -load("//tools:defaults.bzl", "devmode_esbuild", "esbuild_config", "http_server", "ng_module", "sass_binary") +load("//tools:defaults.bzl", "devmode_esbuild", "esbuild_config", "http_server", "ng_module", "sass_binary", "sass_library") load("//src/components-examples:config.bzl", "ALL_EXAMPLES") load("//tools/angular:index.bzl", "LINKER_PROCESSED_FW_PACKAGES") @@ -105,6 +105,14 @@ devmode_esbuild( ], ) +sass_library( + name = "color-api-back-compat", + srcs = glob(["**/_*.scss"]), + deps = [ + "//src/material:sass_lib", + ], +) + sass_binary( name = "theme", src = "theme.scss", @@ -119,6 +127,7 @@ sass_binary( name = "theme_m3", src = "theme-m3.scss", deps = [ + ":color-api-back-compat", "//src/material:sass_lib", "//src/material-experimental:sass_lib", "//src/material/core:theming_scss_lib", diff --git a/src/dev-app/_color-api-back-compat.scss b/src/dev-app/_color-api-back-compat.scss new file mode 100644 index 000000000000..ec2486cc6798 --- /dev/null +++ b/src/dev-app/_color-api-back-compat.scss @@ -0,0 +1,96 @@ +@use '@angular/material' as mat; + +@mixin color-variant-styles($theme, $color-variant) { + @include mat.option-color($theme, $color-variant: $color-variant); + @include mat.progress-spinner-color($theme, $color-variant: $color-variant); + @include mat.pseudo-checkbox-color($theme, $color-variant: $color-variant); + @include mat.stepper-color($theme, $color-variant: $color-variant); + + &.mat-icon { + @include mat.icon-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-checkbox { + @include mat.checkbox-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-slider { + @include mat.slider-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-tab-group, + &.mat-mdc-tab-nav-bar { + @include mat.tabs-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-slide-toggle { + @include mat.slide-toggle-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-form-field { + @include mat.select-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-radio-button { + @include mat.radio-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-progress-bar { + @include mat.progress-bar-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-form-field { + @include mat.form-field-color($theme, $color-variant: $color-variant); + } + + &.mat-datepicker-content { + @include mat.datepicker-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-button-base { + @include mat.button-color($theme, $color-variant: $color-variant); + } + + &.mat-mdc-standard-chip { + @include mat.chips-color($theme, $color-variant: $color-variant); + } + + .mdc-list-item__start, + .mdc-list-item__end { + @include mat.checkbox-color($theme, $color-variant: $color-variant); + @include mat.radio-color($theme, $color-variant: $color-variant); + } + + // M3 dropped support for warn/error color FABs. + @if $color-variant != error { + &.mat-mdc-fab, + &.mat-mdc-mini-fab { + @include mat.fab-color($theme, $color-variant: $color-variant); + } + } +} + +// TODO(mmalerba): Consider adding this as a back-compat API for users who want it, rather than just +// a demo thing. +@mixin color-variants-back-compat($theme) { + .mat-primary { + @include color-variant-styles($theme, primary); + } + .mat-badge { + @include mat.badge-color($theme, $color-variant: primary); + } + + .mat-accent { + @include color-variant-styles($theme, tertiary); + } + .mat-badge-accent { + @include mat.badge-color($theme, $color-variant: tertiary); + } + + .mat-warn { + @include color-variant-styles($theme, error); + } + .mat-badge-warn { + @include mat.badge-color($theme, $color-variant: error); + } +} diff --git a/src/dev-app/dev-app/dev-app-layout.html b/src/dev-app/dev-app/dev-app-layout.html index 62bbfa434256..17688a632475 100644 --- a/src/dev-app/dev-app/dev-app-layout.html +++ b/src/dev-app/dev-app/dev-app-layout.html @@ -45,6 +45,14 @@