Repository navigation
fix(Button): filled buttons keep their label at 4.5:1 on hover and press - #12415
josephfarina wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
6e625ba to
def08bc
Compare
There was a problem hiding this comment.
This needs an owner decision before it can be approved, and it has three fixes to make either way.
Filled Buttons painting their own label colour on hover and press is new behavior that no current spec decides: the Button spec names the shared overlays, and the press-feedback architecture names the system pressed tint. An engineering owner records the decision by commenting /approve-spec <full head SHA> and naming the record that will carry it; the author may do so as an engineering owner.
Blocking findings:
- The label tint lowers label contrast below 4.5:1 while hovered or pressed: Core's default primary falls to 3.80:1 pressed in light mode (5.87:1 on main) and destructive to 3.51:1 pressed in dark mode, so pick a paint that keeps 4.5:1 and have the guard assert it.
- Desktop behavior change needs an owner decision: hover and mouse press paint change for every filled Button (
Button.tsxvariant styles), so gate it to touch input or cite the owner decision that covers it. - The new guard skips every filled row when it cannot read the two constants, so on main only its constant check fails and its visibility check passes, contrary to the description; read each variant's declarations (or computed style), fail unresolved rows, and correct the description.
Non-blocking: the new comment block now separates the older variant JSDoc from variants; merge or move it.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: default buttons now visibly change on hover and press. Verified in Chromium frames (Core primary fill moves from #0064E0 to #1E76E3 on hover).
- Claim: primary, secondary and destructive paint a tint of their label colour, so dark fills lighten and light fills darken. Verified (variant styles; neutral light and dark frames).
- Claim: a theme's own button rule for the overlay tokens still wins. Verified (theme component rules sit in a later cascade layer).
- Claim: ghost buttons keep the page overlay. Verified (ghost style unchanged).
- Claim: the primary Button looked the same on hover in every theme and with none. Verified (fill moves 0 to 20 steps on main).
- Claim: destructive hover was faint in five themes, secondary in matcha dark and y2k. Verified with the repository's contrast helpers.
- Claim: an open menu trigger now takes its button's own tint. Verified (the open style reads the pressed token on the Button element).
- Claim: no change to fills, labels, borders, layout, token defaults or theme files. Verified for files; every theme's filled-button hover and press still change.
- Claim: the regression test fails on main for the primary Button in every theme. False: on main only its constant check fails; the visibility check passes.
- Claim: the guard reads Core's paint from Button.tsx and honours a theme's button rule. Partly true: it reads two constant names, not the variant styles.
- Claim: the look check passes for six themes and matcha's remaining finding is its own. Not verifiable here.
- File
packages/core/src/Button/Button.tsx: label contrast and desktop-decision findings; comment placement note. - File
scripts/check-interactive-state-change.test.mjs: guard finding. - File
.changeset/core-button-hover-press-visible.md: clear.
def08bc to
554bc47
Compare
3f3d363 to
4698116
Compare
There was a problem hiding this comment.
Changes are needed: five fixes below, and an owner decision on the filled-state paint.
No current spec decides which tint replaces the shared overlay where it drops a filled Button's label under 4.5:1, the press-feedback change that lets Button own that tint, or theme generation deriving those paints for every theme, so the new Button FR15 sentence and the press-feedback edits stay proposals until an engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
Blocking findings:
- A theme whose fill or label is written as
hsl(),oklch()orcolor-mix()gets no paint for that variant, so its Button falls back to Core's built-in hover and press values instead of the theme's own overlay (paintsForinfilledStatePaint.tsskips the variant andentriesFromlists only the variants measured in light mode), so emit every variant, hold the shared overlay where a colour cannot be measured, and add a test. packages/core/src/theme/filledStatePaint.stylex.tsis a new internal shared module, imported bypackages/core/src/Button/Button.tsx, that no current record names, so it needs that owner decision, or move it intoButton/so only Button imports it.- Neutral's pale destructive Button in dark mode now paints hover and press with a black tint instead of the portable overlay that
packages/themes/neutral/neutral.spec.md(DEC-6 and its mapping paragraph) still says it uses, so amend those lines in this pull request or change neutral's dark destructive colours so the shared overlay keeps 4.5:1. - Desktop behavior change needs an owner decision: neutral's dark destructive hover already read 5.12:1 on the shared overlay but now darkens for every pointer, because
filledStatePaint.tsreplaces both states when only the press fails, so replace each state only where the shared overlay fails, or cite the decision that covers this hover and reword the changeset, which says only the failing state changes. - The INV1 verification row of
docs/architecture/press-feedback.mdstill rejects any new tint variable outside the press recipe modules, which contradicts the exception INV1 and the Builder impact row now make, so add the same exception to that row.
The Builder impact row is now consistent, and two non-blocking notes cover the readability-wins fallback that FR15 does not state and two over-long comments in filledStatePaint.ts.
Claims and files checked
Review mode: full; reason: spec-record
- Claim: Core's dark primary, chocolate's and matcha's light destructive, and neutral's dark destructive dropped under 4.5:1 on hover or press, and keep 4.5:1 with a visible change now: verified (contrast probe, guard and browser frames); neutral's dark hover already passed.
- Claim: every other filled Button paints hover and press exactly as before: verified for Core and the official themes; false for a theme with unmeasurable colours (first finding).
- Claim: Core's dark primary reads 4.70, 5.37 and 6.08 to 1 and its fill moves 27 and 51: verified.
- Claim: a state that keeps the page overlay holds that mode's overlay colour: verified in Core's values and the generated theme CSS.
- Claim: theme generation measures a theme's own button rule and its generated status labels: verified by the unit tests.
- Claim: a theme's own button rule for the overlay tokens still wins: verified by layer order.
- Claim: an open DropdownMenu trigger follows the new paint on the four fills: verified (it paints the pressed token on the trigger).
- Claim: on media surfaces a filled Button keeps the root's paint, the shared overlay on every official theme's primary, and an overlay a container sets no longer reaches it: verified from the generated CSS and the on-media defaults.
- Claim: where no tint both shows and reads, the state takes a strong tint away from the label, and no official theme reaches that case: verified; the fill can stay unmoved there (non-blocking note).
- Claim: the guard fails on low contrast, invisible replaced paints, unresolved rows and missing variant paints, and cannot pass on the base: verified (the base builds no derivation module).
- Claim: no change to fills, labels, borders, layout, overlay defaults or theme files: verified from the diff.
- Claim: the testing commands pass: verified for the guard, the Button and theme suites, and the knowledge check.
- Changeset: "paints that state" is false for neutral's dark hover (fourth finding); the rest is verified for the official themes.
.changeset/core-button-hover-press-visible.md: fourth finding.docs/architecture/press-feedback.md: fifth finding; the amendment awaits the owner decision.docs/specs/components/Button/Button.spec.md: the FR15 sentence and row await the owner decision; the removed gap line is fixed by the code; non-blocking fallback note.packages/core/src/Button/Button.tsx: second finding.packages/core/src/theme/filledStatePaint.stylex.ts: second finding.packages/core/src/theme/filledStatePaint.test.ts: clear.packages/core/src/theme/filledStatePaint.ts: first and fourth findings; two non-blocking notes.packages/core/src/theme/generateThemeRules.ts: clear.scripts/check-interactive-state-change.test.mjs: clear.scripts/lib/theme-contrast.mjs: clear.
| import {touchHitAreaStyles} from '../internal/touchHitArea.stylex'; | ||
| import {useLinkComponent} from '../Link/useLinkComponent'; | ||
| import type {LinkComponentType} from '../Link/types'; | ||
| import {filledStatePaintVars} from '../theme/filledStatePaint.stylex'; |
There was a problem hiding this comment.
theme/filledStatePaint.stylex.ts is a new internal module imported from outside theme/, and no current record names it, so it needs an owner decision (the FR15 edit counts once an engineering owner approves it), or move the defineVars into Button/ so only Button imports it.
c34f3f3 to
a8abf29
Compare
…ess [skip ci] Where the shared hover or pressed overlay drops a filled Button's label under 4.5:1 on its fill in a mode (AST-020 FR1, WCAG 1.4.3), that state takes the variant's own tint: away from the label where that shows, else toward it, and readability wins where no tint does both. Every other state keeps the shared overlay. theme/filledStatePaint derives the paints for Core and for every theme, its adaptations and media surfaces; Button reads them. Button FR15, press-feedback, and neutral's record state the exception; a guard checks every filled variant in Core and every official theme.
0013975 to
79d4484
Compare
There was a problem hiding this comment.
Changes are needed: two fixes below, and an owner decision on the filled-state paint.
No current spec decides which tint replaces the shared overlay on a filled Button, the press-feedback change that lets Button own that tint, neutral's dark destructive press exception, or theme generation deriving those paints for every theme, so the new Button FR15 sentences and the press-feedback and neutral edits stay proposals until an engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
Blocking findings:
packages/core/src/theme/filledStatePaint.stylex.tsis a new internal shared module, imported bypackages/core/src/Button/Button.tsx, that no current record names, so it needs that owner decision (the FR15 edit names it once approved), or move it intoButton/so only Button imports it.- Miss: a filled label that already reads under 4.5:1 also loses the shared overlay whenever the overlay lowers it (
filledStatePaint.tstakesmin(4.5, rest)as the floor), so a custom theme with a#8a8a8aprimary under white text gets a black hover and press instead of its own overlay, while the changeset says every other filled Button keeps the page's overlay and the FR15 sentence covers only overlays that drop a label under 4.5:1; state that rule in both, or replace only overlays that drop a label from 4.5:1 or more.
The earlier fallback for unmeasurable colours and the missing readability-wins wording in FR15 are fixed, and non-blocking notes cover the Review checks row missing from the description's press-feedback list and two comments over the source-comment sentence length.
Claims and files checked
Review mode: full; reason: rebase
- Claim: Core's dark primary, chocolate's and matcha's light destructive, and neutral's dark destructive press dropped under 4.5:1 with the shared overlay and keep 4.5:1 with a visible change now: verified (Chromium frames and the guard).
- Claim: each state is checked on its own and every other state keeps the page overlay: verified for Core and the seven official themes (neutral's dark destructive hover is unchanged); false for a custom label already under 4.5:1 (second finding).
- Claim: Core's dark primary reads 4.70, 5.37 and 6.08 to 1 and its fill moves 27 and 51: verified (5.38 and 6.10 in Chromium).
- Claim: a colour that cannot be measured keeps the page overlay: verified (code and unit test).
- Claim: a state that keeps the page overlay holds that mode's overlay colour: verified in Core's values and the generated theme CSS.
- Claim: theme generation measures a theme's own button rule and generated status labels, and measures adaptations and media surfaces again: verified (unit tests and generated CSS).
- Claim: a theme's own button rule for the overlay tokens still wins: verified by layer order.
- Claim: an open DropdownMenu trigger follows the new paint on the four fills: verified (the open trigger paints the pressed token on the trigger).
- Claim: an overlay a container sets outside the theme no longer reaches filled Buttons: consistent with the mechanism.
- Claim: where no tint both shows and reads, a strong tint away from the label applies, and no official theme reaches that case: verified for every painted state; media surfaces generate such values only in the half they never show.
- Claim: the guard fails on low contrast, invisible replaced paints, unresolved rows and missing variant paints, and cannot pass on main: verified (main builds no derivation module).
- Claim: no change to fills, labels, borders, layout, overlay defaults or theme files: verified from the diff.
- Claim: the testing commands pass: verified (guard and contrast tests, Button and theme suites, knowledge check).
- Changeset: the "every other filled Button keeps the page's overlay" sentence is false for a label already under 4.5:1 (second finding); the rest is verified.
.changeset/core-button-hover-press-visible.md: second finding.docs/architecture/press-feedback.md: awaits the owner decision.docs/specs/components/Button/Button.spec.md: FR15 awaits the owner decision; second finding; the removed gap line is fixed by the code.packages/core/src/Button/Button.tsx: first finding; comment-length note.packages/core/src/theme/filledStatePaint.stylex.ts: first finding.packages/core/src/theme/filledStatePaint.test.ts: clear.packages/core/src/theme/filledStatePaint.ts: second finding; comment-length note.packages/core/src/theme/generateThemeRules.ts: clear.packages/themes/neutral/neutral.spec.md: awaits the owner decision.scripts/check-interactive-state-change.test.mjs: clear.scripts/lib/theme-contrast.mjs: clear.
| label: RGBA, | ||
| hoverFill: RGBA, | ||
| ): Record<'hover' | 'pressed', boolean> { | ||
| const floor = Math.min(TEXT_RATIO, contrastRatio(label, fill)); |
There was a problem hiding this comment.
Miss (blocking): with min(4.5, rest) as the floor, a label that already reads under 4.5:1 loses the shared overlay whenever the overlay lowers it at all. A #8a8a8a primary under white text (3.45:1) with a white 15% hover now paints black 7% (3.94:1). The changeset says every other filled Button keeps the page's overlay, and the FR15 sentence covers only an overlay that drops a label under 4.5:1. Please state this rule in both, or replace only overlays that drop a label from 4.5:1 or more.
| * Each filled variant paints hover and press with the paint filledStatePaint.ts | ||
| * derives: the shared overlay where it keeps the label at 4.5:1, else a tint | ||
| * that does. A theme's own button rule for these tokens wins. |
There was a problem hiding this comment.
Non-blocking: this sentence has 27 words, over the 25-word limit for a description in source comments. For example: "Filled variants paint hover and press with their derived paint. A theme's button rule for these tokens wins."
| * The variables as `light-dark()` values. A state that keeps the shared | ||
| * overlay in a mode holds that mode's overlay value, so the Button that sets | ||
| * its overlay to the variable paints what the page paints. |
There was a problem hiding this comment.
Non-blocking: this sentence has 29 words, over the 25-word limit for a description in source comments. For example: "A state that keeps the shared overlay holds that mode's overlay value. The Button then paints what the page paints."
|
Please use a darker existing palette step for the resting fill so dark-mode hover and press can keep getting lighter. Neutral blue 45 (#0067ce) kept the white label above 4.5:1 in all three states in the Core dark primary example with the existing overlays. Keep overlay colors palette-based and verify the other affected themes. |
rubyycheung
left a comment
There was a problem hiding this comment.
Please use a darker existing palette step for the resting fill so dark-mode hover and press can keep getting lighter. Neutral blue 45 (#0067ce) kept the white label above 4.5:1 in all three states in the Core dark primary example with the existing overlays. Keep overlay colors palette-based and verify the other affected themes.
User impact
On some filled Buttons, hovering or pressing dropped the label under 4.5:1 contrast, so the text got harder to read at the very moment someone used it. That happened with no theme on Core's dark-mode primary Button, on the light-mode destructive Button in chocolate and matcha, and on neutral's dark-mode destructive Button.
With this change, those Buttons keep their label at 4.5:1 or more at rest, hovered and pressed, and their hover and press still visibly change the fill. Every other filled Button paints hover and press exactly as before.
Problem and solution fit
--color-overlay-hoverand--color-overlay-pressedover the variant's fill. That overlay tints one way only (darker in light mode, lighter in dark mode). On a fill whose label only just clears 4.5:1, a tint toward the label's own lightness pushes it under. Under white text in dark mode, the lightening overlay does exactly that.spec:AST-020FR1).The fix measures each filled variant's fill and label in each mode. Each state (hover, press) is checked on its own. Where the page overlay keeps the label at 4.5:1, that state is unchanged. Where it doesn't, that state takes the variant's own tint instead: away from the label (darker under light text, lighter under dark text) where that visibly moves the fill, else toward the label in the smallest amount that shows and keeps 4.5:1. A colour that can't be measured keeps the page overlay.
theme/filledStatePaint.tsderives the paints.theme/filledStatePaint.stylex.tsholds Core's own values, and a unit test holds them to the derivation. These are new internal modules: Button reads the six private paint variables, and theme generation writes a theme's own.tokens.stylex.tsholds public tokens a theme sets, andinteractionOverlay.stylex.tspaints one overlay for every part, so neither can hold a paint derived per variant, fill and mode. The values sit in the theme layer because they are per-modelight-dark()pairs. A state that keeps the page overlay holds that mode's overlay colour, so the Button paints what the page paints. Button FR15 names both modules.generateThemeRulesemits a theme's own paints when the theme sets a colour they read, measured on the fill and label the theme's own button rule paints where it sets one, and on the status labels the theme generates (a theme that sets only its error fill is measured on the label generated for it).Expected behavior and authority
spec:AST-020FR1 makes WCAG 2.2 AA the baseline, and its SC 1.4.3 row assigns text contrast to the component and the theme.component:ButtonFR15 now states the scope: where the shared overlay would drop a filled variant's label under 4.5:1 on its fill in a mode, that variant paints that state with its own tint instead, so the label keeps 4.5:1 and the change shows, and readability wins where no tint does both; every other state keeps the shared overlay. The record's gap line on the dark accent's hover and pressed contrast goes, since the paint now keeps 4.5:1.architecture:press-feedbackrecipe 1, INV1, its Builder impact row and its INV1 verification row name the system pressed tint for the Button family and allow no tint of a component's own, so all four now allow the readable filled-Button tint of Button FR15 where the system tint drops the label under 4.5:1. Both record edits are design-owner decisions and wait on the owner's review.Smallest restoration
packages/core/src/theme/filledStatePaint.ts,filledStatePaint.stylex.ts: the paint derivation and Core's values.packages/core/src/theme/generateThemeRules.ts: a theme's own paints.packages/core/src/Button/Button.tsx: the filled variants read their paint.docs/specs/components/Button/Button.spec.md: the FR15 sentence, the verification row,verified_by.docs/architecture/press-feedback.md: recipe 1, INV1, its Builder impact row and its INV1 verification row allow the readable filled-Button tint.packages/themes/neutral/neutral.spec.md: the mapping paragraph and DEC-6 name the pale destructive Button's dark press, which takes Button FR15's tint.Evidence
scripts/check-interactive-state-change.test.mjsmeasures every filled variant in Core alone and in every official theme, in both modes, at rest, hovered, pressed, and pressed with the mouse (over the theme's own hover fill). It fails when a label reads under 4.5:1, when a replaced paint does not move the fill visibly (more than 24 on hover, 48 on press), when a row cannot be resolved, or when a filled variant in Button.tsx does not paint hover and press with its own derived paint. On main it cannot pass: main's Button.tsx paints no derived paint, and main's Core has no derivation to measure.Scope
Components: Button, filledStatePaint (internal theme module), generateThemeRules
Testing
CI=1 pnpm vitest run --project node scripts/check-interactive-state-change.test.mjs scripts/check-text-contrast-by-role.test.mjsCI=1 pnpm vitest run packages/core/src/Button packages/core/src/themenode scripts/check-knowledge.mjsWriting rubric results
component:Button(FR15 sentence, verification row, removed gap line):R1 narration: none; the FR15 sentence states what the Button paints in the present tense.
R2 research: none in the record; the measurements stay in this description.
R3 evidence: the new verification row names
filledStatePaint.test.tsandcheck-interactive-state-change.test.mjs, not a change.R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none.
R7 project status: none added; one gap line removed because the paint now meets it.
architecture:press-feedback(recipe 1, INV1, Builder impact, INV1 verification row):R1 narration: none; the edits state what the Button family paints in the present tense.
R2 research: none.
R3 evidence: the INV1 verification row names the Button FR15 exception, not a change.
R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none.
R7 project status: none.
theme:neutral(the mapping paragraph and DEC-6):R1 narration: none; the line states what the Button paints in the present tense.
R2 research: none.
R3 evidence: no evidence cell changed.
R4 rejected alternatives: none recorded.
R5 change references: none.
R6 open questions: none.
R7 project status: none.