MCPcopy Create free account
hub / github.com/webstudio-is/webstudio / parseCssVar

Function parseCssVar

packages/css-data/src/parse-css-value.ts:525–542  ·  view source on GitHub ↗
(node: FunctionNode)

Source from the content-addressed store, hash-verified

523};
524
525export const parseCssVar = (node: FunctionNode): undefined | VarValue => {
526 const [name, _comma, ...fallback] = node.children;
527 const fallbackString = generate({
528 type: "Value",
529 loc: null,
530 children: new List<CssNode>().fromArray(fallback),
531 }).trim();
532 if (name.type === "Identifier") {
533 const value: VarValue = {
534 type: "var",
535 value: name.name.slice("--".length),
536 };
537 if (fallback.length > 0) {
538 value.fallback = { type: "unparsed", value: fallbackString };
539 }
540 return value;
541 }
542};
543
544const parseLiteral = (
545 node: undefined | null | CssNode,

Callers 4

enterFunction · 0.90
enterFunction · 0.90
parseColorWithVarAlphaFunction · 0.85
parseLiteralFunction · 0.85

Calls 1

generateFunction · 0.85

Tested by

no test coverage detected