Skip to content

Commit 73fd32d

Browse files
committed
Color decision: usage and variant same path
1 parent 8ad610f commit 73fd32d

File tree

3 files changed

+28
-33
lines changed

3 files changed

+28
-33
lines changed

src/bin/css_to_ts/colorDecisions.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,20 @@ export function createParseColorDecisionName(params: {
135135
*
136136
* getThemePath(createParseColorDecisionName("--background-alt-raised-grey-hover"))
137137
* ->
138-
* ["background", "altRaised", "normal", "grey", "hover"]
138+
* ["background", "altRaised", "grey", "hover"]
139139
*
140140
* getThemePath(createParseColorDecisionName("--border-action-low-orange-terre-battue"))
141141
* ->
142-
* ["border", "action", "low", "orangeTerreBattue", "default"]
142+
* ["border", "actionLow", "orangeTerreBattue", "default"]
143143
*/
144144
export function getThemePath(parsedColorDecisionName: ParsedColorDecisionName) {
145145
return [
146146
parsedColorDecisionName.context,
147-
parsedColorDecisionName.usage,
148-
parsedColorDecisionName.variant ?? "normal",
147+
`${parsedColorDecisionName.usage}${
148+
parsedColorDecisionName.variant === undefined
149+
? ""
150+
: capitalize(parsedColorDecisionName.variant)
151+
}`,
149152
parsedColorDecisionName.colorName,
150153
parsedColorDecisionName.state ?? "default"
151154
];

src/test/bin/colorDecisions/generateGetColorDecisionsTsCode.test.ts

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ console.log(`Running test ${__filename}`);
66

77
const input: ColorDecision[] = [
88
{
9-
"themePath": ["background", "default", "normal", "grey", "hover"],
9+
"themePath": ["background", "default", "grey", "hover"],
1010
"optionThemePath": ["grey", "_1000_50", "hover"]
1111
},
1212
{
13-
"themePath": ["background", "default", "normal", "grey", "default"],
13+
"themePath": ["background", "default", "grey", "default"],
1414
"optionThemePath": ["grey", "_1000_50", "default"]
1515
},
1616
{
17-
"themePath": ["border", "action", "low", "orangeTerreBattue", "default"],
17+
"themePath": ["border", "actionLow", "orangeTerreBattue", "default"],
1818
"optionThemePath": ["orangeTerreBattue", "_850_200", "default"]
1919
},
2020
{
21-
"themePath": ["background", "altRaised", "normal", "grey", "hover"],
21+
"themePath": ["background", "altRaised", "grey", "hover"],
2222
"optionThemePath": ["grey", "_975_100", "hover"]
2323
},
2424
{
25-
"themePath": ["background", "contrastOverlap", "normal", "grey", "default"],
25+
"themePath": ["background", "contrastOverlap", "grey", "default"],
2626
"optionThemePath": ["grey", "_950_150", "default"]
2727
}
2828
];
@@ -39,34 +39,26 @@ export function getColorDecisions(
3939
return {
4040
"background": {
4141
"default": {
42-
"normal": {
43-
"grey": {
44-
"hover": colorOptions.grey._1000_50.hover,
45-
"default": colorOptions.grey._1000_50.default
46-
}
42+
"grey": {
43+
"hover": colorOptions.grey._1000_50.hover,
44+
"default": colorOptions.grey._1000_50.default
4745
}
4846
},
4947
"altRaised": {
50-
"normal": {
51-
"grey": {
52-
"hover": colorOptions.grey._975_100.hover
53-
}
48+
"grey": {
49+
"hover": colorOptions.grey._975_100.hover
5450
}
5551
},
5652
"contrastOverlap": {
57-
"normal": {
58-
"grey": {
59-
"default": colorOptions.grey._950_150.default
60-
}
53+
"grey": {
54+
"default": colorOptions.grey._950_150.default
6155
}
6256
}
6357
},
6458
"border": {
65-
"action": {
66-
"low": {
67-
"orangeTerreBattue": {
68-
"default": colorOptions.orangeTerreBattue._850_200.default
69-
}
59+
"actionLow": {
60+
"orangeTerreBattue": {
61+
"default": colorOptions.orangeTerreBattue._850_200.default
7062
}
7163
}
7264
}
@@ -75,6 +67,6 @@ export function getColorDecisions(
7567

7668
const got = generateGetColorDecisionsTsCode(input);
7769

78-
assert(got === expected);
70+
assert(got === expected, "xxxx::");
7971

8072
console.log("PASS");

src/test/bin/colorDecisions/parseColorDecision.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@ const got = parseColorDecision({
2828

2929
const expected: ColorDecision[] = [
3030
{
31-
"themePath": ["background", "default", "normal", "grey", "hover"],
31+
"themePath": ["background", "default", "grey", "hover"],
3232
"optionThemePath": ["grey", "_1000_50", "hover"]
3333
},
3434
{
35-
"themePath": ["background", "default", "normal", "grey", "default"],
35+
"themePath": ["background", "default", "grey", "default"],
3636
"optionThemePath": ["grey", "_1000_50", "default"]
3737
},
3838
{
39-
"themePath": ["border", "action", "low", "orangeTerreBattue", "default"],
39+
"themePath": ["border", "actionLow", "orangeTerreBattue", "default"],
4040
"optionThemePath": ["orangeTerreBattue", "_850_200", "default"]
4141
},
4242
{
43-
"themePath": ["background", "altRaised", "normal", "grey", "hover"],
43+
"themePath": ["background", "altRaised", "grey", "hover"],
4444
"optionThemePath": ["grey", "_975_100", "hover"]
4545
},
4646
{
47-
"themePath": ["background", "contrastOverlap", "normal", "grey", "default"],
47+
"themePath": ["background", "contrastOverlap", "grey", "default"],
4848
"optionThemePath": ["grey", "_950_150", "default"]
4949
}
5050
];

0 commit comments

Comments
 (0)