From d28e99802b5e3a3fb008c19df809ba0b82dee0df Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Mon, 5 Apr 2021 18:25:53 +0200 Subject: [PATCH] build: add check for new theming bundle Sets up a build check to verify that the new theming API works. --- src/material/_index.scss | 3 +- src/material/core/theming/tests/BUILD.bazel | 12 ++++++-- .../tests/test-legacy-theming-bundle.scss | 28 +++++++++++++++++++ .../theming/tests/test-theming-bundle.scss | 24 ++++++++-------- 4 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 src/material/core/theming/tests/test-legacy-theming-bundle.scss diff --git a/src/material/_index.scss b/src/material/_index.scss index 9488a0fa8c18..735f13398ec4 100644 --- a/src/material/_index.scss +++ b/src/material/_index.scss @@ -1,6 +1,7 @@ // Theming APIs @forward './core/theming/theming' show define-light-theme, define-dark-theme, - define-palette, get-contrast-color-from-palette, get-color-from-palette; + define-palette, get-contrast-color-from-palette, get-color-from-palette, + $theme-ignore-duplication-warnings; @forward './core/theming/palette' show $red-palette, $pink-palette, $indigo-palette, $purple-palette, $deep-purple-palette, $blue-palette, $light-blue-palette, $cyan-palette, $teal-palette, $green-palette, $light-green-palette, $lime-palette, $yellow-palette, diff --git a/src/material/core/theming/tests/BUILD.bazel b/src/material/core/theming/tests/BUILD.bazel index e7a4899e9c6a..4c2725df97f2 100644 --- a/src/material/core/theming/tests/BUILD.bazel +++ b/src/material/core/theming/tests/BUILD.bazel @@ -21,8 +21,7 @@ sass_binary( deps = ["//src/material/core:theming_scss_lib"], ) -# Sass binary which is used to ensure that the theming bundle exposes the necessary -# mixins and variables for creating themes. +# Sass binary used to ensure that the theming bundle works as expected. sass_binary( name = "test-theming-bundle", testonly = True, @@ -30,6 +29,15 @@ sass_binary( deps = ["//src/material:theming_bundle"], ) +# Sass binary which is used to ensure that the legacy theming bundle exposes the necessary +# mixins and variables for creating themes. +sass_binary( + name = "test-legacy-theming-bundle", + testonly = True, + src = "test-legacy-theming-bundle.scss", + deps = ["//src/material:theming_bundle"], +) + ts_library( name = "unit_test_lib", testonly = True, diff --git a/src/material/core/theming/tests/test-legacy-theming-bundle.scss b/src/material/core/theming/tests/test-legacy-theming-bundle.scss new file mode 100644 index 000000000000..eecb1bf33134 --- /dev/null +++ b/src/material/core/theming/tests/test-legacy-theming-bundle.scss @@ -0,0 +1,28 @@ +// Imports the theming bundle. Needs to be an absolute bin-dir import path as on Windows, +// runfiles are not symlinked, so the Sass compilation happens in the workspace directory +// with the include paths being set to the `bazel-bin` directory. +// stylelint-disable-next-line material/no-import +@import 'src/material/theming'; + +// Disable theme style duplication warnings. This test intentionally generates +// the same themes multiple times. +$mat-theme-ignore-duplication-warnings: true; + +@include mat-core(); + +$theme: mat-light-theme(( + color: ( + primary: $mat-red, + accent: $mat-blue, + ), + density: -2, +)); + +// If one of these mixins is not available, the compilation will fail and the +// test will be reported as failing. +@include angular-material-theme($theme); +@include angular-material-typography(); +@include angular-material-color($theme); +@include angular-material-density($theme); +@include mat-core-theme($theme); +@include mat-button-theme($theme); diff --git a/src/material/core/theming/tests/test-theming-bundle.scss b/src/material/core/theming/tests/test-theming-bundle.scss index eecb1bf33134..8a1788d99458 100644 --- a/src/material/core/theming/tests/test-theming-bundle.scss +++ b/src/material/core/theming/tests/test-theming-bundle.scss @@ -1,28 +1,26 @@ // Imports the theming bundle. Needs to be an absolute bin-dir import path as on Windows, // runfiles are not symlinked, so the Sass compilation happens in the workspace directory // with the include paths being set to the `bazel-bin` directory. -// stylelint-disable-next-line material/no-import -@import 'src/material/theming'; +@use 'src/material' as mat; // Disable theme style duplication warnings. This test intentionally generates // the same themes multiple times. -$mat-theme-ignore-duplication-warnings: true; +mat.$theme-ignore-duplication-warnings: true; -@include mat-core(); +@include mat.core(); -$theme: mat-light-theme(( +$theme: mat.define-light-theme(( color: ( - primary: $mat-red, - accent: $mat-blue, + primary: mat.$red-palette, + accent: mat.$blue-palette, ), density: -2, )); // If one of these mixins is not available, the compilation will fail and the // test will be reported as failing. -@include angular-material-theme($theme); -@include angular-material-typography(); -@include angular-material-color($theme); -@include angular-material-density($theme); -@include mat-core-theme($theme); -@include mat-button-theme($theme); +@include mat.all-component-themes($theme); +@include mat.all-component-typographies(); +@include mat.all-component-colors($theme); +@include mat.core-theme($theme); +@include mat.button-theme($theme);