MCPcopy
hub / github.com/yousifamanuel/terraink / normalizeHexColor

Function normalizeHexColor

src/shared/utils/color.ts:20–37  ·  view source on GitHub ↗
(color: string)

Source from the content-addressed store, hash-verified

18// ─── Normalize ───────────────────────────────────────────────────────────────
19
20export function normalizeHexColor(color: string): string {
21 if (typeof color !== "string") {
22 return "";
23 }
24
25 const trimmed = color.trim().toLowerCase();
26 if (SIX_DIGIT_HEX.test(trimmed)) {
27 return trimmed;
28 }
29
30 const shortMatch = THREE_DIGIT_HEX.exec(trimmed);
31 if (!shortMatch) {
32 return "";
33 }
34
35 const [, value] = shortMatch;
36 return `#${value[0]}${value[0]}${value[1]}${value[1]}${value[2]}${value[2]}`;
37}
38
39export function toUniqueHexColors(colors: string[] = []): string[] {
40 const unique: string[] = [];

Callers 12

normalizeThemeFunction · 0.90
buildDynamicColorChoicesFunction · 0.90
addSuggestedFunction · 0.90
addMoreFunction · 0.90
ColorPickerFunction · 0.90
handlePickerChangeFunction · 0.90
handleHexInputFunction · 0.90
handleResetThemeColorsFunction · 0.90
handleResetSingleColorFunction · 0.90
MapSettingsSectionFunction · 0.90
toUniqueHexColorsFunction · 0.85
parseHexColorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected