Skip to content

Commit 1d7ba38

Browse files
devversionandrewseguin
authored andcommitted
refactor: add mixin for generating all color styles
Adds a mixin (currently denoted as private) that can be used to generate color styles for all components. This is needed in the future for generating theme color styles while not accidentally re-generating density or typography styles.
1 parent f1409d4 commit 1d7ba38

File tree

5 files changed

+43
-6
lines changed

5 files changed

+43
-6
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
/src/material/core/* @jelbourn
4343
/src/material/core/testing/** @crisbeto
4444
/src/material/core/animation/** @jelbourn
45+
/src/material/core/color/** @jelbourn @devversion
4546
/src/material/core/common-behaviors/** @jelbourn @devversion
4647
/src/material/core/datetime/** @mmalerba
4748
/src/material/core/density/** @devversion

src/material/BUILD.bazel

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@ scss_bundle(
2626
name = "theming_bundle",
2727
outs = ["_theming.scss"],
2828
args = [
29-
"--entryFile=$(execpath //src/material/core:theming/_all-theme.scss)",
29+
"--entryFile=$(execpath :theming-bundle.scss)",
3030
"--outFile=$(execpath :_theming.scss)",
3131
],
3232
data = CDK_SCSS_LIBS + MATERIAL_SCSS_LIBS + [
33-
"//src/material/core:theming/_all-theme.scss",
33+
"theming-bundle.scss",
34+
"//src/material/core:theming_scss_lib",
3435
# Config file is required by "scss-bundle" and will be automatically
3536
# loaded by the CLI. It expects the config to be in the execroot.
3637
"//:scss-bundle.config.json",

src/material/core/BUILD.bazel

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,21 @@ ng_module(
4141
],
4242
)
4343

44+
ALL_THEMING_FILES = [
45+
# The `_core.scss` file needs to be added here too because it depends
46+
# on the `_all-typography` file.
47+
"_core.scss",
48+
"color/_all-color.scss",
49+
"density/_all-density.scss",
50+
"theming/_all-theme.scss",
51+
"typography/_all-typography.scss",
52+
]
53+
4454
sass_library(
4555
name = "core_scss_lib",
4656
srcs = glob(
4757
["**/_*.scss"],
48-
exclude = ["theming/_all-theme.scss"],
58+
exclude = ALL_THEMING_FILES,
4959
),
5060
deps = [
5161
"//src/cdk/a11y:a11y_scss_lib",
@@ -56,9 +66,7 @@ sass_library(
5666

5767
sass_library(
5868
name = "theming_scss_lib",
59-
srcs = [
60-
"theming/_all-theme.scss",
61-
],
69+
srcs = ALL_THEMING_FILES,
6270
deps = MATERIAL_SCSS_LIBS,
6371
)
6472

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@import '../theming/all-theme';
2+
3+
// Includes all of the color styles.
4+
@mixin angular-material-color($config) {
5+
// In case a theme object has been passed instead of a configuration for
6+
// the color system, extract the color config from the theme object.
7+
@if type_of($config) == 'map' {
8+
$config: map_get($config, color);
9+
}
10+
// If no actual color configuration has been specified, report an error.
11+
@if not $config {
12+
@error 'No color configuration specified.';
13+
}
14+
15+
@include angular-material-theme((
16+
color: $config,
17+
typography: null,
18+
density: null,
19+
));
20+
}

src/material/theming-bundle.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// File for which all imports are resolved and bundled. This is the entry-point for
2+
// the `@angular/material` theming Sass bundle. See `//src/material:theming_bundle`.
3+
4+
@import './core/color/all-color';
5+
@import './core/density/all-density';
6+
@import './core/theming/all-theme';
7+
@import './core/typography/all-typography';

0 commit comments

Comments
 (0)