Skip to content

Commit

Permalink
build: add check for new theming bundle (angular#22398)
Browse files Browse the repository at this point in the history
Sets up a build check to verify that the new theming API works.
  • Loading branch information
crisbeto committed Apr 6, 2021
1 parent 76a09d9 commit d93c85c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 16 deletions.
3 changes: 2 additions & 1 deletion src/material/_index.scss
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
12 changes: 10 additions & 2 deletions src/material/core/theming/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ 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,
src = "test-theming-bundle.scss",
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,
Expand Down
28 changes: 28 additions & 0 deletions src/material/core/theming/tests/test-legacy-theming-bundle.scss
Original file line number Diff line number Diff line change
@@ -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);
24 changes: 11 additions & 13 deletions src/material/core/theming/tests/test-theming-bundle.scss
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit d93c85c

Please sign in to comment.