Simplify CSS variable system, add css-data.json for IDE/LLM support#4291
Draft
amcclain wants to merge 8 commits into
Draft
Simplify CSS variable system, add css-data.json for IDE/LLM support#4291amcclain wants to merge 8 commits into
amcclain wants to merge 8 commits into
Conversation
…efix Remove the unprefixed CSS variable override hooks (e.g. --grid-bg, --pad, --font-size) from vars.scss. Applications now override the --xh- prefixed variables directly. This eliminates unnecessary indirection, enables IDE autocomplete for override targets, and aligns with modern CSS variable conventions. The previous system defined vars like `--xh-grid-bg: var(--grid-bg, var(--xh-bg))` where apps set the unprefixed `--grid-bg` to customize. After this change, `--xh-grid-bg: var(--xh-bg)` is the simplified form, and apps set `--xh-grid-bg` directly. Also includes the intent text-color copy-paste bug fix from the prior commit and adds CHANGELOG and v83 upgrade notes documenting the migration path (mechanical find-and-replace for most apps, with a mapping table for the small number of naming mismatches). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Remove all references to the two-tier unprefixed override pattern. Update examples to use --xh- prefixed variables directly, add scoped override and dark theme override guidance, and revise pitfall examples accordingly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Introduce bin/generate-css-data.mjs, which parses vars.scss to produce a VS Code Custom Data file (css-data.json) with descriptions for all ~425 --xh-* CSS custom properties. Descriptions are auto-generated from variable name structure and value relationships (derivations, aliases, intent system, palette colors), with support for explicit /// doc comments that take precedence. Added sample doc comments to key vars in vars.scss. The generated file is checked in and ships with the npm package. A pre-commit hook validates it stays in sync when SCSS files change, and prepack regenerates it before publish. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Member
Author
|
We have a further option to also remove the indirection we have with unit-less values, then we then multiply to make varying combinations (e.g. We should discuss if we want to make that change also, or if this is already pushed as far as we're comfortable. I do like that this cleans up something that's been muddy in my mind from the very beginning and would love to get it merged when we're ready. Feedback + thoughts appreciated! |
Catch up with develop (v83 -> v87-SNAPSHOT). Conflict resolutions: - styles/vars.scss: removed all two-tier override hooks (the PR's purpose), taking develop's newer underlying values and new vars (grid tooltip vars, --xh-bg-highlight-alt, --xh-loading-indicator-spinner-color, SegmentedControl, Spinner, dark button bg variants). Unwrapped var(--hook, INNER) -> INNER for every hook develop added in non-conflicting regions as well. - docs/upgrade-notes/v83-upgrade-notes.md: kept develop's real v83 release notes; relocated the PR's CSS-variable migration notes to a new v87-upgrade-notes.md. - CHANGELOG.md: PR entries now sit under 87.0.0-SNAPSHOT; fixed upgrade-notes link to v87, merged the duplicate Bug Fixes section, added difficulty description. - css-data.json: regenerated against merged vars.scss (441 properties).
The intent text-color copy-paste bug (introduced in v80 by #4194) was fixed independently in commit 428f3f6 and shipped in v83.0.0. It is already on develop, so referencing it as a v87 fix in the changelog and upgrade notes was misleading - removed both the changelog bullet and the upgrade-note section.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Removes the two-tier CSS custom property override system. Previously, Hoist defined framework variables like
--xh-grid-bg: var(--grid-bg, var(--xh-bg)), where the unprefixed--grid-bgserved as an app-level override hook. This added complexity, confused IDE autocomplete (apps were expected to set vars that didn't appear in any source), and was inconsistently applied across the codebase. Applications now override the--xh-prefixed variables directly - simpler, IDE-friendly, and consistent with modern CSS variable conventions.Adds
css-data.jsonfor IDE autocomplete and LLM/agent consumption. A VS Code Custom Data file generated fromvars.scssbybin/generate-css-data.mjs, providing autocomplete and hover documentation for all ~440--xh-*CSS custom properties. Descriptions are auto-generated from variable name structure and value relationships (derivations, aliases, intent system, palette colors), with support for explicit///doc comments that take precedence. A pre-commit hook validates the file stays in sync when SCSS files change;prepackregenerates before publish.Motivation
The unprefixed override hooks were an unnecessary layer of indirection. Analysis of sample apps found only ~39% of the 265 hooks were ever used, and apps that did use them got no IDE support - the unprefixed names existed only inside
var()fallback expressions invars.scss, invisible to autocomplete. Meanwhile, the--xh-prefixed names were the ones actually documented and referenced in component SCSS. Removing the two-tier pattern and standardizing on--xh-eliminates confusion and makes the system work better with modern tooling.The
css-data.jsonfile takes this further by giving VS Code users immediate autocomplete with descriptions, and - more importantly - giving coding agents and LLMs a machine-readable index of every available CSS variable with relationship and override guidance baked into the descriptions.Breaking change
This is a low-difficulty mechanical migration for apps. Most overrides simply need an
xh-prefix added. A small number of unprefixed names differed from their--xh-counterparts - the upgrade notes include a complete mapping table and grep commands for finding affected code.See
docs/upgrade-notes/v87-upgrade-notes.mdfor step-by-step instructions.Test plan
css-data.jsonprovides autocomplete in VS Code when configured viacss.customDatacss-data.jsonwhen SCSS is modifiednode bin/generate-css-data.mjs --checkpasses after regeneration