Skip to content

Commit 13f5125

Browse files
committed
More detail in color picker raw data
1 parent c6530cd commit 13f5125

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

src/scripts/build/cssToTs/colorDecisions.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ export function getThemePath(parsedColorDecisionName: ParsedColorDecisionName) {
161161

162162
export type ColorDecision = {
163163
colorDecisionName: `--${string}`;
164+
parsedColorDecisionName: ParsedColorDecisionName;
164165
themePath: readonly string[];
165166
optionThemePath: readonly string[];
166167
};
@@ -204,9 +205,12 @@ export const parseColorDecision = memoize((rawCssCode: string): ColorDecision[]
204205

205206
assert(is<`--${string}`>(property));
206207

208+
const parsedColorDecisionName = parseColorDecisionName(property);
209+
207210
return {
208211
"colorDecisionName": property,
209-
"themePath": getThemePath(parseColorDecisionName(property)),
212+
"themePath": getThemePath(parsedColorDecisionName),
213+
parsedColorDecisionName,
210214
"optionThemePath": getColorOptionThemePath(parseColorOptionName(colorOptionName))
211215
};
212216
})

src/scripts/build/cssToTs/colorOptions.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ export type ColorOption = {
327327
light: `#${string}`;
328328
dark: `#${string}`;
329329
};
330+
parsedColorOptionName: ParsedColorOptionName;
330331
};
331332

332333
export const parseColorOptions = memoize((rawCssCode: string): ColorOption[] => {
@@ -341,7 +342,7 @@ export const parseColorOptions = memoize((rawCssCode: string): ColorOption[] =>
341342

342343
assert(node !== undefined);
343344

344-
const { declarations } = node as any;
345+
const { declarations } = node as { declarations: any[] };
345346

346347
return { declarations };
347348
})();
@@ -359,21 +360,22 @@ export const parseColorOptions = memoize((rawCssCode: string): ColorOption[] =>
359360
assert(typeof colorDark === "string");
360361
assert(cssColorRegexp.test(colorDark), `${colorDark} doesn't seem to be a color`);
361362

362-
const parsedName = parseColorOptionName(property);
363+
const parsedColorOptionName = parseColorOptionName(property);
363364

364-
if (parsedName.brightness.isInvariant) {
365+
if (parsedColorOptionName.brightness.isInvariant) {
365366
assert(colorLight === colorDark);
366367
}
367368

368369
return {
369370
"colorOptionName": property,
370-
"themePath": getThemePath(parsedName),
371-
"color": parsedName.brightness.isInvariant
372-
? colorLight
371+
"themePath": getThemePath(parsedColorOptionName),
372+
"color": parsedColorOptionName.brightness.isInvariant
373+
? (colorLight as `#${string}`)
373374
: {
374-
"light": colorLight,
375-
"dark": colorDark
376-
}
375+
"light": colorLight as `#${string}`,
376+
"dark": colorDark as `#${string}`
377+
},
378+
parsedColorOptionName
377379
};
378380
})
379381
.filter(exclude(undefined));

0 commit comments

Comments
 (0)