@@ -18,11 +18,11 @@ $_system-level-prefix: sys;
18
18
/// config map. The config map can have values color, typography, and/or density.
19
19
///
20
20
/// If the config map's color value is an Angular Material color palette, it will be used as the
21
- /// primary and tertiary colors with a light theme type. Otherwise if the color value is a map,
22
- /// it must have a `primary` value containing an Angular Material color palette, and optionally
23
- /// a different `tertiary` palette (defaults to primary palette) and `theme-type` that is either
24
- /// `light` or `dark` (defaults to light ). Color variable definitions will not be emitted if there
25
- /// are no color values in the config.
21
+ /// primary and tertiary colors with a `color-scheme` theme type. Otherwise if the color value is a
22
+ /// map, it must have a `primary` value containing an Angular Material color palette, and
23
+ /// optionally a different `tertiary` palette (defaults to primary palette) and `theme-type` that
24
+ /// is either `light`, `dark`, or 'color-scheme` (defaults to `color-scheme` ). Color variable
25
+ /// definitions will not be emitted if there are no color values in the config.
26
26
///
27
27
/// If the config map's typography value is a font family string, it will be used as the
28
28
/// plain and brand font family with default bold, medium, and regular weights of 700, 500, and 400,
@@ -44,9 +44,14 @@ $_system-level-prefix: sys;
44
44
$color : map .get ($config , color );
45
45
$color-config : null;
46
46
@if ($color ) {
47
+ // Default to "color-scheme" theme type if the config's color does not provide one.
48
+ @if (meta .type-of ($color ) == ' map' and not map .has-key ($color , theme-type )) {
49
+ $color : map .set ($color , theme-type , color-scheme );
50
+ }
51
+
47
52
$color-config : if (meta .type-of ($color ) == ' map' ,
48
53
definition .define-colors ($color ),
49
- definition .define-colors ((primary: $color )));
54
+ definition .define-colors ((primary: $color , theme - type: color-scheme )));
50
55
@include system-level-colors ($color-config , $overrides , $_system-fallback-prefix );
51
56
@include system-level-elevation ($color-config , $overrides , $_system-fallback-prefix );
52
57
}
@@ -126,9 +131,7 @@ $_system-level-prefix: sys;
126
131
md- ref- palette: m3-tokens .generate-ref-palette-tokens ($primary , $tertiary , $error )
127
132
);
128
133
129
- $sys-colors : if ($type == dark ,
130
- definitions .md-sys-color-values-dark ($ref ),
131
- definitions .md-sys-color-values-light ($ref ));
134
+ $sys-colors : _generate-sys-colors ($ref , $type );
132
135
133
136
// Manually insert a subset of palette values that are used directly by components
134
137
// instead of system variables.
@@ -144,6 +147,30 @@ $_system-level-prefix: sys;
144
147
}
145
148
}
146
149
150
+ @function _generate-sys-colors ($ref , $type ) {
151
+ $light-sys-colors : definitions .md-sys-color-values-light ($ref );
152
+ @if ($type == light ) {
153
+ @return $light-sys-colors ;
154
+ }
155
+
156
+ $dark-sys-colors : definitions .md-sys-color-values-dark ($ref );
157
+ @if ($type == dark ) {
158
+ @return $dark-sys-colors ;
159
+ }
160
+
161
+ @if ($type == color-scheme ) {
162
+ $light-dark-sys-colors : ();
163
+ @each $name , $light-value in $light-sys-colors {
164
+ $dark-value : map .get ($dark-sys-colors , $name );
165
+ $light-dark-sys-colors :
166
+ map .set ($light-dark-sys-colors , $name , light-dark ($light-value , $dark-value ));
167
+ }
168
+ @return $light-dark-sys-colors ;
169
+ }
170
+
171
+ @error ' Unknown theme-type provided: #{$type } ' ;
172
+ }
173
+
147
174
@mixin system-level-typography ($theme , $overrides : (), $prefix : null) {
148
175
$font-definition : map .get ($theme , _mat-theming-internals-do-not-access , font-definition );
149
176
$brand : map .get ($font-definition , brand );
0 commit comments