Repository navigation
test(ci): theme var guard accepts an inherited seam like --link-hover-color - #12611
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested: the guard fix looks right, but the description is missing one required line.
- Add a
CI impact:line to the description, as AST-030 FR19 and CONTRIBUTING.md require for any change to a CI script: give the runner class ofpr-a11y (audit and guards), job-minutes and runner-pool usage before and after, and time to green (all unchanged here).
Two optional hardening ideas are in the inline comments: the stylesheet read check matches longer var names by prefix, and the declaration check cannot see values written through a style prop. A maintainer can add ci:run-a11y to run the guard at this head before merge.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: the guard has failed on main since the Link doc listed the var. Verified from the code: no story or theme sets it, so the base probe prints the quoted line (
theme-var-reachability.js:159-165,:279-282). - Claim: the earlier change documents
--link-hover-coloras a public Link var. Verified (Link.doc.mjs:20-29). - Claim: the Link spec's FR11 and DEC-1 are current and say Link reads the var with a fallback and never sets it. Verified (
Link.spec.md:123,:223-233). - Claim: the guard treats the topmost element with a value as the declaring element. Verified (
:159-165). - Claim: a default on the Link root would contradict DEC-1 and the hover-color spec's container case. Verified (DEC-1;
Link.hoverColor.a11y.chromium.spec.ts:116). - Claim: the fallback requires the page CSS to read the var. Verified (
:194). - Claim: the fallback rejects a var that any rule declares. Verified for stylesheet rules (
:195); inline writes are not covered (inline comment). - Claim: the theme rule must reach a rendered target, or the guard fails as before. Verified (
:196-200,:234,:279-291). - Claim: the fallback applies only after every story is undeclared, and declared vars keep the old path. Verified (
:223,:232-234;themeSetsmatches the old probe). - Claim: a Storybook run fails before and passes after, across 12 public vars. Not reproduced here; the component docs list 12 public vars, and Link's is the only one no source declares.
- Claim: the title. It matches the change.
- File
.github/scripts/theme-var-reachability.js: the description lacks the CI impact line (blocking), plus two non-blocking notes; consistent with the workflow step and its comment (ci.yml:3463-3472).
| // A cross-origin sheet hides its rules; Core's CSS is same-origin. | ||
| } | ||
| } | ||
| if (!rules.some(text => text.includes(`var(${name}`))) return null; |
There was a problem hiding this comment.
Non-blocking: this also matches a longer var name (var(--link-hover-color-strong for --link-hover-color), so a documented var that nothing reads could pass. Matching var(${name}) or var(${name}, closes that. No current var name is a prefix of another.
| } | ||
| } | ||
| if (!rules.some(text => text.includes(`var(${name}`))) return null; | ||
| if (rules.some(text => text.includes(`${name}:`))) return null; |
There was a problem hiding this comment.
Non-blocking: this sees stylesheet rules only. A var that a component writes through a style prop, in a state no story renders, would pass here and skip the #4530 inline-write check. No public var is written that way today.
validation: ran
pnpm storybook:buildthennode .github/scripts/theme-var-reachability.js --storybook-dir apps/storybook/dist: on the unchanged code it failed 2 of 2 runs with onlyLink --link-hover-color: nothing declares it; with this change it passed 2 of 2 runs, all 12 public component vars settable from a theme (Link --link-hover-color — .astryx-link sets it ( → 9987px)), and the other 11 vars resolve exactly as before.CI impact:
pr-a11y (audit and guards)keeps its runner class before and after: standard GitHub-hostedubuntu-24.04-armfor pull requests and bot-triggered release checks, and the existing non-standard2-core-ubuntu-armfor human-triggered release checks. Job-minutes per pull-request update before → after: expected unchanged (0 added job-minutes); runner-pool usage before → after: expected unchanged (0 added runner-minutes/day and 0 added average concurrent jobs); time to green before → after: expected unchanged (0 added minutes). This CI script change is not measured; workflow routing, runners, job count and scheduling are unchanged.What failed
The release-check
a11y guardsjob's theme var reachability guard failed on main from 3b4c199 (#12081):Cause
#12081 documents
--link-hover-coloras a public Link var. Per the Link spec (component:LinkFR11 and DEC-1, authoritycurrent), an accent link's hover readsvar(--link-hover-color, <default mix>)and Link never sets the var, so a value set on an ancestor container reaches the link. That is by design: the var is unset by default.The guard finds the "declaring" element as the topmost element whose computed style has a value for the var. A var that is read with a fallback and never declared has no value on any element until a container or a theme sets one, so the guard reported it as unread (#5012), although the compiled CSS reads it and a theme rule on
.astryx-linkdoes reach the link.Declaring a default on the Link root instead would mask an ancestor's value and contradict DEC-1 (and the container case in
Link.hoverColor.a11y.chromium.spec.ts), so the fix is in the guard.Fix
.github/scripts/theme-var-reachability.jsnow recognises an inherited seam. When no story declares the var, it falls back to this check:var(<name>(still catches a var nothing reads, Theme docs teach--button-press-scale, a CSS variable no component defines #5012);<name>:(a var the component sets in some state still needs a story that renders it, so the feat(core): make TreeList per-level indent a themeable CSS variable #4530 cascade check on the declaring element is not skipped);@layer astryx-themerule on the component's documented target class must arrive on a rendered target element, or the guard fails as before.The fallback is used only after every story came back undeclared, so vars that some story declares follow the existing path unchanged.
Unsure
Another option was a new doc field that marks a var as an inherited seam explicitly, rather than detecting it from the page's CSS. That would change the doc schema, so I kept the change inside the guard. A maintainer may prefer the explicit marker.