Skip to content

feat: add var() resolution and mode-* descriptors#7

Merged
artmsilva merged 1 commit into
mainfrom
feat/var-resolution-and-modes
Mar 19, 2026
Merged

feat: add var() resolution and mode-* descriptors#7
artmsilva merged 1 commit into
mainfrom
feat/var-resolution-and-modes

Conversation

@artmsilva

Copy link
Copy Markdown
Owner

Summary

  • Resolve var(--X) references in initial-value by chasing through the token graph until a literal is found. Handles chains (A→B→C) and circular references (kept as-is).
  • Add mode-* extended descriptors (e.g., mode-dark, mode-high-contrast) to express color mode overrides directly in @property blocks. Mode values also get var() resolution.

Authoring

@property --color-action-primary {
  syntax: "<color>";
  inherits: true;
  initial-value: var(--color-blue-450);
  mode-dark: var(--color-blue-300);
}

Output

JSON (cssmark build): resolved literals

{
  "name": "--color-action-primary",
  "initialValue": "#2C49EF",
  "modes": { "dark": "#94B4FF" }
}

CSS (cssmark css): preserves var() references + generates mode blocks

:root {
  --color-action-primary: var(--color-blue-450);
}

:root[data-color-mode='dark'] {
  --color-action-primary: var(--color-blue-300);
}

- Resolve var(--X) references in initial-value by chasing through the
  token graph until a literal is found. Handles chains (A→B→C) and
  circular references (kept as-is). Original unresolved value preserved
  in RawInitialValue for CSS output.

- Add mode-* extended descriptors (e.g., mode-dark, mode-high-contrast)
  to express color mode overrides directly in @Property blocks. Mode
  values also get var() resolution with originals in RawModes.

- JSON output: initialValue and modes contain resolved literals.
- CSS output: :root preserves var() references, mode blocks generated
  as :root[data-color-mode='<mode>'] selectors.
@artmsilva artmsilva merged commit bbe9e24 into main Mar 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant