Skip to content

Commit 8a18a26

Browse files
authoredMar 5, 2024··
refactor(material-experimental/theming): move error colors into color palettes (#28666)
1 parent c62c578 commit 8a18a26

File tree

2 files changed

+45
-34
lines changed

2 files changed

+45
-34
lines changed
 

‎src/material-experimental/theming/_definition.scss

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ $theme-version: 1;
5151
tertiary: map.remove($tertiary, neutral, neutral-variant, secondary),
5252
neutral: map.get($primary, neutral),
5353
neutral-variant: map.get($primary, neutral-variant),
54-
error: m3-palettes.$private-error-palette,
54+
error: map.get($primary, error),
5555
),
5656
color-tokens: m3-tokens.generate-color-tokens(
57-
$type, $primary, $tertiary, m3-palettes.$private-error-palette)
57+
$type, $primary, $tertiary, map.get($primary, error))
5858
)
5959
);
6060
}

‎src/material-experimental/theming/_m3-palettes.scss

+43-32
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,39 @@
2727
@return $palette;
2828
}
2929

30+
/// Adds the error colors to the given palette.
31+
@function _patch-error-palette($palette) {
32+
@return map.merge(
33+
$palette,
34+
(
35+
error: (
36+
0: #000000,
37+
10: #410002,
38+
20: #690005,
39+
25: #7e0007,
40+
30: #93000a,
41+
35: #a80710,
42+
40: #ba1a1a,
43+
50: #de3730,
44+
60: #ff5449,
45+
70: #ff897d,
46+
80: #ffb4ab,
47+
90: #ffdad6,
48+
95: #ffedea,
49+
98: #fff8f7,
50+
99: #fffbff,
51+
100: #ffffff,
52+
),
53+
)
54+
);
55+
}
56+
57+
@function _apply-patches($palette) {
58+
@return _patch-missing-hues(_patch-error-palette($palette));
59+
}
60+
3061
/// Red color palette to be used as primary or tertiary palette.
31-
$red-palette: _patch-missing-hues((
62+
$red-palette: _apply-patches((
3263
0: #000000,
3364
10: #410000,
3465
20: #690100,
@@ -102,7 +133,7 @@ $red-palette: _patch-missing-hues((
102133
));
103134

104135
/// Green color palette to be used as primary or tertiary palette.
105-
$green-palette: _patch-missing-hues((
136+
$green-palette: _apply-patches((
106137
0: #000000,
107138
10: #002200,
108139
20: #013a00,
@@ -176,7 +207,7 @@ $green-palette: _patch-missing-hues((
176207
));
177208

178209
/// Blue color palette to be used as primary or tertiary palette.
179-
$blue-palette: _patch-missing-hues((
210+
$blue-palette: _apply-patches((
180211
0: #000000,
181212
10: #00006e,
182213
20: #0001ac,
@@ -250,7 +281,7 @@ $blue-palette: _patch-missing-hues((
250281
));
251282

252283
/// Yellow color palette to be used as primary or tertiary palette.
253-
$yellow-palette: _patch-missing-hues((
284+
$yellow-palette: _apply-patches((
254285
0: #000000,
255286
10: #1d1d00,
256287
20: #323200,
@@ -324,7 +355,7 @@ $yellow-palette: _patch-missing-hues((
324355
));
325356

326357
/// Cyan color palette to be used as primary or tertiary palette.
327-
$cyan-palette: _patch-missing-hues((
358+
$cyan-palette: _apply-patches((
328359
0: #000000,
329360
10: #002020,
330361
20: #003737,
@@ -398,7 +429,7 @@ $cyan-palette: _patch-missing-hues((
398429
));
399430

400431
/// Magenta color palette to be used as primary or tertiary palette.
401-
$magenta-palette: _patch-missing-hues((
432+
$magenta-palette: _apply-patches((
402433
0: #000000,
403434
10: #380038,
404435
20: #5b005b,
@@ -472,7 +503,7 @@ $magenta-palette: _patch-missing-hues((
472503
));
473504

474505
/// Orange color palette to be used as primary or tertiary palette.
475-
$orange-palette: _patch-missing-hues((
506+
$orange-palette: _apply-patches((
476507
0: #000000,
477508
10: #311300,
478509
20: #502400,
@@ -546,7 +577,7 @@ $orange-palette: _patch-missing-hues((
546577
));
547578

548579
/// Chartreuse color palette to be used as primary or tertiary palette.
549-
$chartreuse-palette: _patch-missing-hues((
580+
$chartreuse-palette: _apply-patches((
550581
0: #000000,
551582
10: #0b2000,
552583
20: #173800,
@@ -620,7 +651,7 @@ $chartreuse-palette: _patch-missing-hues((
620651
));
621652

622653
/// Spring Green color palette to be used as primary or tertiary palette.
623-
$spring-green-palette: _patch-missing-hues((
654+
$spring-green-palette: _apply-patches((
624655
0: #000000,
625656
10: #00210b,
626657
20: #003917,
@@ -694,7 +725,7 @@ $spring-green-palette: _patch-missing-hues((
694725
));
695726

696727
/// Azure color palette to be used as primary or tertiary palette.
697-
$azure-palette: _patch-missing-hues((
728+
$azure-palette: _apply-patches((
698729
0: #000000,
699730
10: #001b3f,
700731
20: #002f65,
@@ -768,7 +799,7 @@ $azure-palette: _patch-missing-hues((
768799
));
769800

770801
/// Violet color palette to be used as primary or tertiary palette.
771-
$violet-palette: _patch-missing-hues((
802+
$violet-palette: _apply-patches((
772803
0: #000000,
773804
10: #270057,
774805
20: #42008a,
@@ -842,7 +873,7 @@ $violet-palette: _patch-missing-hues((
842873
));
843874

844875
/// Rose color palette to be used as primary or tertiary palette.
845-
$rose-palette: _patch-missing-hues((
876+
$rose-palette: _apply-patches((
846877
0: #000000,
847878
10: #3f001b,
848879
20: #65002f,
@@ -914,23 +945,3 @@ $rose-palette: _patch-missing-hues((
914945
100: #ffffff,
915946
),
916947
));
917-
918-
/// Color palette to be used for error colors.
919-
$private-error-palette: (
920-
0: #000000,
921-
10: #410002,
922-
20: #690005,
923-
25: #7e0007,
924-
30: #93000a,
925-
35: #a80710,
926-
40: #ba1a1a,
927-
50: #de3730,
928-
60: #ff5449,
929-
70: #ff897d,
930-
80: #ffb4ab,
931-
90: #ffdad6,
932-
95: #ffedea,
933-
98: #fff8f7,
934-
99: #fffbff,
935-
100: #ffffff,
936-
);

0 commit comments

Comments
 (0)
Please sign in to comment.