MCPcopy Create free account
hub / github.com/Railly/tinte / parseCSSVariables

Function parseCSSVariables

apps/web/src/lib/theme-operations/import.ts:9–23  ·  view source on GitHub ↗

* Parse CSS variables from a CSS string

(css: string)

Source from the content-addressed store, hash-verified

7 * Parse CSS variables from a CSS string
8 */
9function parseCSSVariables(css: string): Record<string, string> {
10 const variables: Record<string, string> = {};
11
12 // Match CSS variable declarations like --variable-name: value;
13 const variableRegex = /--([a-zA-Z0-9-]+):\s*([^;]+);/g;
14
15 let match = variableRegex.exec(css);
16 while (match !== null) {
17 const [, name, value] = match;
18 variables[name] = value.trim();
19 match = variableRegex.exec(css);
20 }
21
22 return variables;
23}
24
25/**
26 * Normalize color value to hex using culori

Callers 1

importShadcnThemeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected