Repository navigation
fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill - #12296
josephfarina wants to merge 3 commits into
Conversation
Solid Buttons scope --color-text-primary to their fill content role and --color-neutral to a new --color-neutral-on-<fill> tint, so a neutral Badge in a primary Button reads white on a darkened tint (5.85:1 light, 5.16:1 dark) instead of dark text on a light tint (3.21:1, 2.82:1). Theme generation derives the tint for any theme that does not set it.
|
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.
This pull request needs an engineering owner's spec decision before it can be approved, and one fix is required either way.
- The five new core tokens were not regenerated into the committed Swift theme files, so
packages/native/src/theme/swiftIOSTheme.test.tsfails with "Tokens.swift is stale"; runpnpm -F @astryxdesign/native generate:swift-iosand commitTokens.swiftand the eight generated theme files.
Approval also waits on an engineering owner deciding the new --color-neutral-on-<fill> direction: the sixth name shape in architecture:theme-tokens INV10, its derivation in architecture:theme-compilation INV17 (including the transparent fallback that drops the Badge pill), and the scoping sentence in component:Button FR2. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. The contrast fix itself checks out: in the stock theme the count moves from 3.21:1 to 5.86:1 in light mode and from 2.82:1 to 5.17:1 in dark mode.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim (changeset): a neutral Badge in a primary or destructive Button meets 4.5:1 in light and dark mode. Verified: stock 5.86:1 and 5.51:1 light, 5.17:1 and 5.75:1 dark; Chocolate and Matcha 4.57:1 or more; the other five themes keep their own Badge colours at 5.49:1 or more.
- Claim (changeset): solid Buttons scope the text and neutral roles to their own fill. Verified:
Button.tsx:329-330and:343-344,Button.test.tsx:259-300. - Claim (changeset): the new tint tokens cover the accent and each status. Verified:
tokens.stylex.ts:80-84. - Claim (changeset): themes that do not set the tokens get a derived value. Verified:
statusRoleDerivation.ts:295-318; all seven builttheme.cssfiles carry them, and a theme that sets none of the inputs gets Core's default, which equals the derivation (tokens.test.ts:392-399). - Claim: the count read 3.21:1 in light and 2.82:1 in dark before the change. Verified.
- Claim: it reads 5.85:1 and 5.16:1 after. Verified within rounding (5.86:1 and 5.17:1).
- Claim: every first-party theme passes 4.5:1. Verified: the contrast check passes for all seven themes, also when merged with the current base branch.
- Claim: recolouring the text alone leaves dark mode at 3.67:1, and the muted accent and overlay roles miss 4.5:1 in dark mode. Verified: 3.67:1, 4.44:1, 4.36:1 and 4.03:1.
- Claim: a theme's own tint is kept, and a pair no tint can fix gets a transparent tint. Verified:
statusRoleDerivation.ts:305and:377,tokens.test.ts:426-447. - Claim: the tooltip keeps the page roles, and secondary and ghost Buttons are unchanged. Verified: the tooltip renders beside the button (
Button.tsx:1236),Button.test.tsx:281-300, and those pills render identically before and after. - Claim: no existing theme needs an edit. Verified: no theme source changes and every theme check passes.
- Claim: setting the dark accent tint back to the page neutral fails the new check at 3.67:1. Verified by calculation.
- Claim: browser results at 390, 375 and 1280 px in two builds. Consistent with this review's Chromium capture; those widths and builds were not re-run.
- File
.changeset/neutral-badge-on-solid-button.md: clear. - File
docs/architecture/theme-compilation.md: the INV17 tint clause waits on the owner decision. - File
docs/architecture/theme-tokens.md: the INV10 sixth shape and the verification rows wait on the owner decision. - File
docs/specs/components/Button/Button.spec.md: the FR2 scoping sentence waits on the owner decision. - File
packages/cli/assets/docs/tree/tokens-color.doc.mjs: clear; matches its generator. - File
packages/cli/assets/docs/tree/tokens.doc.mjs: clear. - File
packages/core/src/Button/Button.test.tsx: clear. - File
packages/core/src/Button/Button.tsx: clear. - File
packages/core/src/theme/generateThemeRules.ts: clear. - File
packages/core/src/theme/statusRoleDerivation.ts: clear. - File
packages/core/src/theme/tokens.stylex.ts: the new tokens are missing from the committed Swift files (blocking finding above). - File
packages/core/src/theme/tokens.test.ts: clear. - File
scripts/check-status-text-contrast.test.mjs: clear.
…o new tokens A solid Button publishes its fill pair to its content, and a neutral Badge there paints the pair inverted, which keeps the pair's contrast. The new neutral-on-fill tokens and their derivation come out.
|
Owner decision (engineering owner, covering this pull request): inside a solid Button (primary or destructive), a neutral Badge paints the Button's own color pair inverted, the on-fill color as the pill and the fill color as the text, so a count on the Button reads at the same contrast as the Button's label in every official theme and mode. The Button passes that pair to the Badge through private custom properties; no public token is added and the theme token records do not change. The Badge and Button specs each state this in one sentence, and the specs' owner approves the record lines on this pull request. |
|
/approve-spec e7f9c55 |
There was a problem hiding this comment.
Changes requested. The contrast fix works: in the stock theme the count now reads 5.39:1 in light mode and 4.70:1 in dark mode, the same as the Button's label, and at least 4.57:1 in every official theme. Two things need fixing first:
packages/core/src/theme/derivedVarRegistry.test.tsfails because--_button-filland--_button-on-fillare not registered; add both toPRIVATE_SYSTEM_VARSwith a one-line comment naming Badge FR5 and Button FR2, as the other cross-component private properties are.- Badge FR5 ("inside a solid Button") and Button FR2 ("A solid variant (
primary,destructive)") use "solid" for two variants, while Button AR7 and the code also countsecondaryas solid, so nameprimaryanddestructivedirectly in both records and in theBadge.tsxcomment.
The red test-node legs come from a suite-budget check that main fails the same way, not from this change.
Claims and files checked
Review mode: full; reason: spec-record
- Claim (changeset): a neutral Badge in a primary or destructive Button meets 4.5:1 in light and dark mode. Verified: the contrast test passes all 32 theme, variant and mode cases; stock primary 5.39:1 and 4.70:1, destructive 4.70:1 and 4.99:1.
- Claim (changeset): it paints the Button's pair inverted. Verified:
Badge.tsx:97-98,Button.tsx:328-329and:342-343. - Claim: before, the count read 3.21:1 light and 2.82:1 dark, and the destructive Button had the same problem. Verified: 3.21:1 and 2.82:1; destructive 3.42:1 and 2.51:1.
- Claim: after, 5.39:1 light and 4.70:1 dark, equal to the label. Verified.
- Claim: at least 4.5:1 in every official theme and mode. Verified: lowest 4.57:1.
- Claim: the Badge's page colours keep their page values inside a primary Button. Verified in the base source and in Chromium's computed colours.
- Claim: white text on the neutral tint fixes light mode (5.85:1) but not dark (3.67:1). Verified.
- Claim: no existing subtle tint keeps the white label readable in both modes. Verified for the neutral, muted-accent and overlay tints (3.67:1 to 4.44:1 in dark mode).
- Claim: the Button passes its pair through two private custom properties and the Badge falls back elsewhere. Verified:
Button.tsx:322-345,Badge.tsx:92-99. - Claim: Badge FR5 and Button FR2 each gain one sentence. Verified.
- Claim: no theme token, theme contract or public prop changes. Verified: the API report shows no added, changed or removed row.
- Claim: the shell-top-nav template reproduces it. Verified:
shell-top-nav/page.tsx:214-218. - Claim: secondary and ghost Buttons publish no pair, and a neutral Badge elsewhere keeps its page colours. Verified:
Button.test.tsx:285-296and identical computed colours before and after. - Claim: the contrast test covers Core and every official theme in both modes and uses a theme's own paint where it repaints. Verified:
check-status-text-contrast.test.mjs:158-204. - Claim: with the old pair the check fails for Core, chocolate and matcha. Verified: 1.00:1 to 3.42:1 there; the other themes repaint the Badge.
- Claim: the listed test run passes. Verified (11 files, 447 tests); it leaves out
derivedVarRegistry.test.ts, which fails (finding above). - Claim: Chromium results at 390, 375 and 1280 px. Consistent: Chromium at 1280 px gives the same computed colours, and the badge colours have no width-dependent rule.
- Claim: one defect restored, scoped to Button and Badge, with no hidden public API. Verified.
- File
.changeset/neutral-badge-on-solid-button.md: clear. - File
docs/specs/components/Badge/Badge.spec.md: "solid Button" conflicts with Button AR7 (finding above). - File
docs/specs/components/Button/Button.spec.md: "A solid variant (primary,destructive)" conflicts with AR7 (finding above). - File
packages/core/src/Badge/Badge.tsx: works; its comment repeats "solid Button" (finding above). - File
packages/core/src/Button/Button.test.tsx: clear; the secondary and ghost test title says more than it checks (non-blocking). - File
packages/core/src/Button/Button.tsx: the two new private properties are unregistered (finding above). - File
scripts/check-status-text-contrast.test.mjs: clear.
| ); | ||
|
|
||
| it.each(['secondary', 'ghost'] as const)( | ||
| 'leaves a neutral Badge in a %s Button on its page colours', |
There was a problem hiding this comment.
Non-blocking: this case renders no Badge, so it checks only that the pair is unset. A title such as "publishes no fill pair from a %s Button" says what it proves.
…structive in the records
|
/approve-spec a23257b |
There was a problem hiding this comment.
Changes requested: both earlier blockers are fixed (the private-property registry test passes, and Badge FR5, Button FR2 and the source comments now name primary and destructive), and one title edit is left. The contrast fix works: in the stock theme the count reads 5.39:1 in light mode and 4.70:1 in dark mode, the same as the Button's label, and at least 4.57:1 in every official theme.
- Miss: the title says a neutral Badge "in a solid Button" meets 4.5:1, but Button AR7 also counts
secondaryas solid and a neutral Badge there is unchanged at 4.47:1 on the stock dark surface, so retitle it "fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill" (no code change needed).
CI at this head stopped on a capacity check before any test ran, so it needs a re-run. Optional: the secondary/ghost test at Button.test.tsx:285 renders no Badge, so a title such as "publishes no fill pair from a %s Button" says what it checks, and Badge's FR5 verification row could name the two tests that now cover the new clause.
Claims and files checked
Review mode: full; reason: spec-record
- Claim (changeset): a neutral Badge in a primary or destructive Button meets 4.5:1 in light and dark mode. Verified: the contrast test passes all 32 theme, variant and mode cases (lowest 4.57:1), and Chromium's computed colours agree.
- Claim (changeset): it paints the Button's pair inverted. Verified:
Badge.tsx:97-99,Button.tsx:328-329and:342-343. - Claim: before, the count read 3.21:1 light and 2.82:1 dark, and a destructive Button had the same problem. Verified: destructive 3.42:1 and 2.51:1.
- Claim: after, 5.39:1 light and 4.70:1 dark, equal to the label, and at least 4.5:1 in every official theme and mode. Verified.
- Claim: the Badge's page colours keep their page values inside a primary Button. Verified in the base source and in Chromium.
- Claim: white text on the neutral tint fixes light mode (5.85:1) but not dark (3.67:1). Verified.
- Claim: no existing subtle tint keeps the white label readable in both modes. Partly checked: the neutral tint gives 3.67:1 in dark mode; other tints were not measured.
- Claim: the Button passes its pair through two private custom properties, and the Badge falls back elsewhere. Verified:
Button.tsx:328-343,Badge.tsx:97-99. - Claim: Badge FR5 and Button FR2 each gain one sentence, and no theme token, theme contract or public prop changes. Verified: the API report over both builds lists no row.
- Claim: the shell-top-nav template reproduces the problem. Verified:
shell-top-nav/page.tsx:214-218. - Claim: secondary and ghost Buttons publish no pair, and a neutral Badge elsewhere keeps its page colours. Verified:
Button.test.tsx:285-293and identical computed colours before and after. - Claim: the contrast test covers Core and every official theme in both modes and uses a theme's own paint where it repaints. Verified:
check-status-text-contrast.test.mjs:227-273. - Claim: with the old pair the check fails for Core, Chocolate and Matcha. Verified for the pair (1.00:1 to 3.42:1); the test builds the pair from token names, so it also passes unchanged on the base, and
Button.test.tsxis the check that fails there. - Claim: the listed test run passes. Verified: 442 tests across those files and the registry test.
- Claim: Chromium results at 390, 375 and 1280 px. Consistent: Chromium at 1280 px gives the same computed colours, and the badge colours have no width-dependent rule.
- Claim: one defect is restored, scoped to Button and Badge, with no hidden public API. Verified.
- Claim (title): a neutral Badge in a solid Button meets 4.5:1. False for
secondary, a solid variant under Button AR7 (finding above). - File
.changeset/neutral-badge-on-solid-button.md: clear. - File
docs/specs/components/Badge/Badge.spec.md: clear; the FR5 verification row is not updated (optional). - File
docs/specs/components/Button/Button.spec.md: clear. - File
packages/core/src/Badge/Badge.tsx: clear. - File
packages/core/src/Button/Button.test.tsx: clear; one test title says more than it checks (optional). - File
packages/core/src/Button/Button.tsx: clear. - File
packages/core/src/theme/derivedVarRegistry.test.ts: clear. - File
scripts/check-status-text-contrast.test.mjs: clear; its describe title also says "solid Button".
|
Re the last review item (title): the PR is now titled "fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill", so it no longer says "solid". Secondary keeps its existing paint and is out of scope here. The head is unchanged at a23257b, and I made no push for the optional items. |
|
I'll run a full review to re-check this with your note. |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The retitle fixes the last blocker, so the title now matches the change: a neutral Badge in a primary or destructive Button reads at the Button label's own contrast (5.39:1 light and 4.70:1 dark in the stock theme) and at least 4.57:1 in every official theme and mode.
The CI workflow at this head stopped on its capacity check before any test ran, so it needs a re-run. Optional and non-blocking: the contrast test's describe title and the description's fit bullet still say "solid Button" (Button AR7 also counts secondary), the secondary/ghost test at Button.test.tsx:285 renders no Badge, and Badge's FR5 verification row could name the two tests that now cover the new clause.
Claims and files checked
Review mode: same-head; reason: none
- Claim (title): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill. Verified: the contrast test passes all 32 theme, variant and mode cases (lowest 4.57:1), and Chromium's computed colours agree.
- Claim (changeset): a neutral Badge in a primary or destructive Button meets 4.5:1 in light and dark mode. Verified, as above.
- Claim (changeset): it paints the Button's colour pair inverted. Verified:
Badge.tsx:97-99,Button.tsx:328-329and:342-343. - Claim: before the change the count read 3.21:1 light and 2.82:1 dark, and a destructive Button had the same problem. Verified: destructive 3.42:1 and 2.51:1.
- Claim: after the change 5.39:1 light and 4.70:1 dark, equal to the label, and at least 4.5:1 in every official theme and mode. Verified.
- Claim: the Badge's page colours keep their page values inside a primary Button. Verified in the base source and in Chromium.
- Claim: white text on the neutral tint fixes light mode (5.85:1) but not dark (3.67:1). Verified.
- Claim: no existing subtle tint keeps the white label readable in both modes. Verified for tints that lighten the fill, the alternative the bullet describes: each existing translucent colour that lightens the dark accent fill drops the white label under 4.5:1; darker pills keep it, an option the description does not discuss.
- Claim: the badge then has the Button's own label contrast in any theme. Verified where the inversion applies (stock, Chocolate, Matcha); the five themes that repaint the Button also repaint the neutral Badge, whose own paint keeps 5.49:1 or more.
- Claim: the Button passes its pair through two private custom properties, and the Badge falls back elsewhere. Verified:
Button.tsx:328-343,Badge.tsx:97-99. - Claim: Badge FR5 and Button FR2 each gain one sentence, and no theme token, theme contract or public prop changes. Verified: the API report over both builds lists no row.
- Claim: the shell-top-nav template reproduces the problem. Verified:
shell-top-nav/page.tsx:214-218. - Claim: secondary and ghost Buttons publish no pair, and a neutral Badge elsewhere keeps its page colours. Verified:
Button.test.tsx:285-293and identical computed colours before and after. - Claim: the contrast test covers the stock theme and every official theme in both modes and uses a theme's own paint where it repaints. Verified:
check-status-text-contrast.test.mjs:227-273. - Claim: with the old pair the check fails for the stock theme, Chocolate and Matcha. Verified for the pair (1.00:1 to 3.42:1); the test builds the pair from token names, so it also passes unchanged on the base, and
Button.test.tsxis the check that fails there. - Claim: the listed test run passes. Verified: 442 tests across those files and the registry test.
- Claim: Chromium results at 390, 375 and 1280 px. Consistent: Chromium at 1280 px gives the same computed colours, and the badge colours have no width-dependent rule.
- Claim: one defect is restored, scoped to Button and Badge, with no hidden public API. Verified.
- Claim: the writing rubric reports no narration, research, status or open questions added to the records. Verified: the two added sentences are present-tense contract text.
- Claim: public text and artifacts carry no internal context. Verified: no match in the added lines, each commit's patch, the title, the body or the branch name.
- File
.changeset/neutral-badge-on-solid-button.md: clear. - File
docs/specs/components/Badge/Badge.spec.md: clear; the FR5 verification row is not updated (optional). - File
docs/specs/components/Button/Button.spec.md: clear. - File
packages/core/src/Badge/Badge.tsx: clear. - File
packages/core/src/Button/Button.test.tsx: clear; one test title says more than it checks (optional). - File
packages/core/src/Button/Button.tsx: clear. - File
packages/core/src/theme/derivedVarRegistry.test.ts: clear. - File
scripts/check-status-text-contrast.test.mjs: clear; its describe title says "solid Button" (optional).
| }); | ||
| }); | ||
|
|
||
| describe('a neutral Badge in a solid Button keeps 4.5:1', () => { |
There was a problem hiding this comment.
Non-blocking: Button AR7 counts secondary as a solid variant, and this block covers only primary and destructive. A title such as "a neutral Badge in a primary or destructive Button keeps 4.5:1" says what it proves.
…utton meets 4.5:1 on its fill
- #12680 perf(cli): a template's component line resolves its names in one pass, not one full lookup per name Author: Joey <[email protected]> - #12180 fix(core): Calendar weekday names widen their column instead of overlapping Author: Joey <[email protected]> - #12159 feat(cli): make an icon set inside your own app Author: Joey Farina <[email protected]> - #12383 fix(Grid): a responsive column shrinks to a container narrower than minWidth Author: Joey Farina <[email protected]> - #12374 [fix] Icon: a glyph given as name renders and warns, instead of crashing Author: Joey Farina <[email protected]> - #12453 fix(charts): line, area and band default to straight segments Author: josephfarina <[email protected]> - #12296 fix(core): a neutral Badge in a primary or destructive Button meets 4.5:1 on its fill Author: Joey Farina <[email protected]> - #12395 fix(CodeBlock): without a code string, CodeBlock names the prop and the fix in development Author: Joey Farina <[email protected]> - #12260 fix(cli): `astryx component Flex` names Stack first Author: Joey Farina <[email protected]> - #12391 fix(core): a two-lane Toolbar wraps instead of squeezing its start lane Author: Joey Farina <[email protected]> - #12427 fix(core): checkbox and radio marks keep their share of the box a theme sizes Author: josephfarina <[email protected]> - #12725 [experimental] cli: with no icon set, experimental icon names the discover search where it lists packs Author: Joey Farina <[email protected]>
|
Landed in #12738. |
User impact
A neutral Badge inside a primary Button (for example a cart count on a "Checkout" button) painted dark text on a light tint over the blue fill. The count read at 3.21:1 in light mode and 2.82:1 in dark mode, below the 4.5:1 that 12px text needs. The same happened in a destructive Button. After this change the count reads at 5.39:1 (light) and 4.70:1 (dark) on the stock theme, the same contrast as the Button's own label, and it reaches at least 4.5:1 in every official theme and mode.
Problem and solution fit
--color-text-primaryon--color-neutral. Those colours are meant for the page, not for a strong fill. Inside a primary Button they still resolve to the page values.Expected behavior and authority
Smallest restoration
Button.tsx:primaryanddestructiveset--_button-filland--_button-on-fillfrom their existing tokens.Badge.tsx:neutralreads them, with its existing colours as the fallback.Evidence
endContent={<Badge label={3} />}). Badge text 3.21:1 light, 2.82:1 dark at 390, 375 and 1280 px wide.check-status-text-contrast.test.mjsresolves the badge pair inside primary and destructive Buttons for Core and every official theme, in light and dark. Where a theme repaints the neutral Badge or the Button, the test uses the theme's paint. With the old pair (primary text on the neutral tint) the check fails for Core, chocolate and matcha.Scope
Components: Button, Badge
Testing
vitest run packages/core/src/Button packages/core/src/Badge scripts/check-status-text-contrast.test.mjs scripts/check-badge-contrast.test.mjsButton.test.tsx: primary and destructive publish their pair, and a neutral Badge reads it; secondary and ghost publish none.Writing rubric results
R1 narration: none; the Badge FR5 and Button FR2 sentences describe the system in the present tense.
R2 research: none in the records.
R3 evidence: no evidence cell changed.
R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none added.
R7 project status: none.