Skip to content

Commit 0eb7ab1

Browse files
committed
build: add check for new theming bundle
Sets up a build check to verify that the new theming API works.
1 parent 4f8e87e commit 0eb7ab1

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

src/material/_index.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Theming APIs
22
@forward './core/theming/theming' show define-light-theme, define-dark-theme,
3-
define-palette, get-contrast-color-from-palette, get-color-from-palette;
3+
define-palette, get-contrast-color-from-palette, get-color-from-palette,
4+
$theme-ignore-duplication-warnings;
45
@forward './core/theming/palette' show $red-palette, $pink-palette, $indigo-palette,
56
$purple-palette, $deep-purple-palette, $blue-palette, $light-blue-palette, $cyan-palette,
67
$teal-palette, $green-palette, $light-green-palette, $lime-palette, $yellow-palette,

src/material/core/theming/tests/BUILD.bazel

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,23 @@ sass_binary(
2121
deps = ["//src/material/core:theming_scss_lib"],
2222
)
2323

24-
# Sass binary which is used to ensure that the theming bundle exposes the necessary
25-
# mixins and variables for creating themes.
24+
# Sass binary used to ensure that the theming bundle works as expected.
2625
sass_binary(
2726
name = "test-theming-bundle",
2827
testonly = True,
2928
src = "test-theming-bundle.scss",
3029
deps = ["//src/material:theming_bundle"],
3130
)
3231

32+
# Sass binary which is used to ensure that the legacy theming bundle exposes the necessary
33+
# mixins and variables for creating themes.
34+
sass_binary(
35+
name = "test-legacy-theming-bundle",
36+
testonly = True,
37+
src = "test-legacy-theming-bundle.scss",
38+
deps = ["//src/material:theming_bundle"],
39+
)
40+
3341
ts_library(
3442
name = "unit_test_lib",
3543
testonly = True,
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Imports the theming bundle. Needs to be an absolute bin-dir import path as on Windows,
2+
// runfiles are not symlinked, so the Sass compilation happens in the workspace directory
3+
// with the include paths being set to the `bazel-bin` directory.
4+
// stylelint-disable-next-line material/no-import
5+
@import 'src/material/theming';
6+
7+
// Disable theme style duplication warnings. This test intentionally generates
8+
// the same themes multiple times.
9+
$mat-theme-ignore-duplication-warnings: true;
10+
11+
@include mat-core();
12+
13+
$theme: mat-light-theme((
14+
color: (
15+
primary: $mat-red,
16+
accent: $mat-blue,
17+
),
18+
density: -2,
19+
));
20+
21+
// If one of these mixins is not available, the compilation will fail and the
22+
// test will be reported as failing.
23+
@include angular-material-theme($theme);
24+
@include angular-material-typography();
25+
@include angular-material-color($theme);
26+
@include angular-material-density($theme);
27+
@include mat-core-theme($theme);
28+
@include mat-button-theme($theme);
Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
// Imports the theming bundle. Needs to be an absolute bin-dir import path as on Windows,
22
// runfiles are not symlinked, so the Sass compilation happens in the workspace directory
33
// with the include paths being set to the `bazel-bin` directory.
4-
// stylelint-disable-next-line material/no-import
5-
@import 'src/material/theming';
4+
@use 'src/material' as mat;
65

76
// Disable theme style duplication warnings. This test intentionally generates
87
// the same themes multiple times.
9-
$mat-theme-ignore-duplication-warnings: true;
8+
mat.$theme-ignore-duplication-warnings: true;
109

11-
@include mat-core();
10+
@include mat.core();
1211

13-
$theme: mat-light-theme((
12+
$theme: mat.define-light-theme((
1413
color: (
15-
primary: $mat-red,
16-
accent: $mat-blue,
14+
primary: mat.$red-palette,
15+
accent: mat.$blue-palette,
1716
),
1817
density: -2,
1918
));
2019

2120
// If one of these mixins is not available, the compilation will fail and the
2221
// test will be reported as failing.
23-
@include angular-material-theme($theme);
24-
@include angular-material-typography();
25-
@include angular-material-color($theme);
26-
@include angular-material-density($theme);
27-
@include mat-core-theme($theme);
28-
@include mat-button-theme($theme);
22+
@include mat.all-component-themes($theme);
23+
@include mat.all-component-typographies();
24+
@include mat.all-component-colors($theme);
25+
@include mat.core-theme($theme);
26+
@include mat.button-theme($theme);

0 commit comments

Comments
 (0)