Repository navigation
Make the shared Button consume the hover tokens (closes #2689) - #2710
Conversation
The `--*-hover` tokens were correct in app.css; the shared shadcn Button
simply never used them. It hovered to `bg-destructive/90`, an alpha fill
composited against the page, which put dark-mode destructive hover at
3.39:1 — below AA, on the "Remove database" control, at the moment of a
destructive commitment. All four filled-variant hovers LOST contrast.
Measured against each variant's own foreground, before -> after:
default light 3.51 -> 3.05 => 3.51 -> 4.86
default dark 4.47 -> 3.81 => 4.47 -> 5.79
destructive light 5.36 -> 4.76 => 5.36 -> 6.66
destructive dark 5.97 -> 3.39 => 6.95 -> 8.45
Every hover now clears AA and rises above its rest state.
Two stock shadcn treatments are dropped from `destructive` rather than
carried forward, because they only worked together with the alpha hover:
- `dark:bg-destructive/60` made the dark REST state translucent. Its real
effect was to lighten the fill toward the page, which was the only thing
propping up the `text-white` beside it. Keeping a translucent rest under
an opaque hover would also be incoherent.
- `text-white` bypassed `--destructive-foreground`, which carries real
per-theme values precisely because white fails on dark fills: against the
solid dark `--destructive` it is 2.86:1. Using the token takes dark
destructive rest from 2.86:1 to 6.95:1.
Light mode is visually unchanged — light `--destructive-foreground` is
`0 0% 100%`, identical to the `text-white` it replaces. Only dark mode
moves, which is where the defect was.
The tokens are registered in tailwind.config.js deliberately WITHOUT an
`<alpha-value>` placeholder, so `hover:bg-destructive-hover/90` does not
resolve. A hover fill is opaque by definition, and admitting an alpha
channel would reopen the idiom this removes.
`filled-button-variants.test.ts` (14 tests) covers the half the existing
`filled-button-hover.test.ts` cannot: that suite proves the token VALUES
obey the rule, and passed throughout the entire period this bug was live.
The gap between correct tokens and a component that ignores them is how
this shipped, so the new suite asserts consumption — each filled variant
names its hover token, no alpha hover survives on a filled variant, no
translucent rest fill remains, and the config entry has no alpha channel.
Verified the guard bites rather than passing vacuously, by mutation:
1. variants reverted to the original stock strings -> 5 tests fail
2. `<alpha-value>` re-added to the config entry -> 2 tests fail
3. dark --destructive-hover 76% -> 64%, wrong -> 1 test fails
direction but still 7.3:1, comfortably above AA
Mutation 3 is the one the AA floor alone would miss, and is the reason the
load-bearing assertion compares hover contrast to REST contrast rather than
to a constant.
Also confirmed by compiling the real emitted class strings through PostCSS:
`hover:bg-primary-hover` and `hover:bg-destructive-hover` resolve to opaque
`hsl(var(--*-hover))` rules, and zero alpha hover rules remain.
Deliberately NOT asserted: a rest-state AA floor. `--primary` is 3.51:1
light / 4.47:1 dark against its own foreground at rest, both pre-existing
properties of the brand color that no hover change can reach. Adding that
floor would make this suite fail on a defect it does not own.
app.css is untouched. Scope is the component and its Tailwind registration.
Verification:
- bun run test: 250 files / 5148 tests passed (baseline 249 / 5134)
- bun run quality:fix: clean; design-token baseline unchanged at 137;
svelte-check 2540 files, 0 errors, 0 warnings
- Consumers: all 18 audited. No consumer overrides the button background or
label color; the only external buttonVariants users are the calendar
prev/next buttons on the untouched `outline` variant.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Pragmatic Code Review — PR #2710Review Type: Initial Review (no prior reviews on this PR) SummaryThis is a well-scoped, genuinely net-positive fix that resolves a real WCAG AA failure on a destructive control. I independently recomputed every contrast ratio from the raw token values in
The coupled-defect argument for dropping I also verified the deferral decision (finding 7): Secondary's exemption (finding 6) also checks out: 16.10:1 light / 14.22:1 dark at rest, rising to 16.40 / 14.84 on hover. It gains contrast. The reasoning is sound. The test was verified by mutation rather than assumed — I ran the mutations myself rather than trusting the author's table, and mutations 1 and 2 reproduce exactly (5 failures and 2 failures respectively). This is emphatically not a vacuous suite; Two findings below. Neither is a correctness bug in the shipped behavior — the fix works — but one documents an enforcement guarantee that does not actually exist, which matters because it is now written into DESIGN.md as a rule future contributors will rely on. Requirements Check — Issue #2689 Acceptance Criteria
All 6 criteria met. Verified Code Review Findings🟡 Important📁 The comment states that omitting Both resolve. Tailwind v3 parses The good news, and the reason this is 🟡 and not 🔴: the actual fix is unaffected. I confirmed the two classes the component really uses emit exactly the intended opaque rules: So this is a documentation/rationale defect, not a behavioral one. It matters because the claim has been written into Principle: a comment that asserts a guarantee the system doesn't provide is worse than no comment — it stops the next person from adding the check that would. Suggested fix — keep the config exactly as-is (it is still the correct, honest declaration of intent), and correct the three claims:
Note the existing test 📁 You flagged this one to scrutinize, and it is a real (if benign) issue — with a more interesting cause than plain array-vs-substring semantics.
I verified this empirically. Writing tw-merge dropped The regression is genuinely caught — which is why this is 🟡 and not 🔴. Nothing is unguarded. But line 139 is dead weight that reads as a second, independent safety net when it is unreachable, and a future reader may add a Two reasonable resolutions:
🟢 Suggestions📁
That said, I'd land on extract, but not as a merge blocker. The arguments each way: For leaving it: two call sites is the classic DRY threshold, not past it. The helpers are pure, stable, and have no reason to drift in behavior. Test-local duplication is often defensible because it keeps a suite readable standalone. For extracting: these aren't trivial one-liners — this is ~55 lines of subtle, spec-derived math (the WCAG 0.03928 cutoff, the 2.4 gamma exponent, the Suggested: extract to Principle: DRY applies with more force to knowledge that is hard to re-derive than to code that is merely repeated. Nit: 📁 Standards ComplianceVerified against CLAUDE.md:
Recommendation✅ APPROVEThis fixes a real accessibility defect on a destructive control, and every quantitative claim in the PR description survived independent recomputation — which is not something I can usually say. The architectural judgment is sound throughout: the coupled-defect analysis on Both 🟡 findings are rationale and dead-code issues, not behavioral ones. The button renders correctly, every hover clears AA, and the alpha-hover idiom is genuinely guarded by a test I confirmed bites. Neither blocks merge. I'd ask for one small follow-up, ideally folded in before merge since it's a few lines: correct the |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
The reviewer caught a false guarantee I had written into three places. I
reproduced it through PostCSS before changing anything:
.hover\:bg-destructive-hover\/90:hover {
background-color: hsl(var(--destructive-hover) / 0.9)
}
Tailwind v3 injects alpha into `hsl(var(--x))` whether or not the entry
carries an <alpha-value> placeholder, so `hover:bg-destructive-hover/90`
compiles fine. My claim that omitting the placeholder makes an alpha
variant "not resolve" was simply wrong.
The fix itself is unaffected — the two classes the component uses still
emit exactly the intended opaque rules — but the false reason had been
written into the config comment, the test, and DESIGN.md, where it was
becoming a standing rule. Corrected in all three to say what is actually
true: the bare form is a convention for a value meant to be used opaquely,
and the thing that actually forbids an alpha hover is the filled-variant
sweep in the test suite.
Also documented that `not.toContain('text-white')` cannot fail on its own.
`tv()` runs tw-merge, so a literal added after the token REPLACES it rather
than joining it — `text-destructive-foreground text-white` collapses to
`text-white` alone. Verified both orderings. The regression is still caught,
by the positive assertion on the line above; the negative one stays as a
statement of the prohibition, now labelled as such rather than reading like
an independent safety net.
Extracted the WCAG helpers to src/tests/helpers/wcag-contrast.ts, following
the existing helpers/ precedent. They had been copy-pasted byte-for-byte
between the two design suites, and the copy dropped the readHsl comment
recording that an earlier draft's regex typo produced 16 vacuous passes —
so the hardest-won lesson survived in only one of the two files that
implement it. It now lives in one place, with both suites importing it.
Not added to helpers/index.ts on purpose: that barrel re-exports DOM
fixtures and node factories, and these two suites are pure file reading
with no DOM. Importing by direct path keeps them from dragging in setup
they do not use.
Re-verified the guard still bites after the refactor rather than trusting
the passing count:
- variants reverted to stock shadcn -> 5 failures (unchanged)
- dark --destructive-hover 76% -> 64% -> 3 failures across both suites
Verification:
- bun run test: 250 files / 5148 tests passed, identical to pre-refactor
- bun run quality:fix: clean; design-token baseline unchanged at 137;
svelte-check 2541 files, 0 errors, 0 warnings
DESIGN.md corrected separately in nodespace-docs.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Review addressed —
|
| Mutation | Before extraction | After |
|---|---|---|
| Variants reverted to stock shadcn | 5 failures | 5 failures |
dark --destructive-hover 76% → 64% |
1 failure | 3 failures (both suites now) |
Verification
bun run test— 250 files / 5148 tests passed, identical to pre-refactorbun run quality:fix— clean; design-token baseline unchanged at 137; svelte-check 2541 files, 0 errors, 0 warnings- Pre-push gate — full pyramid green
Re-Review Decision
Decision: RE-REVIEW NEEDED
Rationale: The <alpha-value> and not.toContain corrections are comment-only and would not warrant one on their own. The helper extraction is not — it moved ~55 lines of contrast math out of both design suites into a new shared module, changing the imports of a file that was not part of the original review (filled-button-hover.test.ts).
That file is the guard for the tokens the whole rule rests on, and it is now exercising code it didn't previously own. I re-ran both mutations and the count is unchanged, but "the author re-ran his own mutations" is exactly the evidence an independent reviewer exists to check. The refactor also touches the one function whose correctness history includes a silent-vacuous-pass failure.
A reviewer should confirm the extracted readHsl / contrast / themeBlock are byte-equivalent in behavior to both originals, and that neither suite lost an assertion in the move.
Pragmatic Code Review — PR #2710 (Re-Review)Review Type: Re-Review Previous Review Summary
3 addressed / 0 not addressed / 0 new issues. SummaryAll three findings are properly addressed, and the one that triggered this re-review — the helper extraction — holds up under independent verification. I did not take the author's mutation table on faith; I re-ran both mutations myself and re-derived the equivalence rather than reading the diff. The headline result: the extracted helpers are byte-identical to both originals. I extracted the pre-refactor versions of both suites ( The specific hazard flagged for scrutiny — the Worth noting the doc comment above it correctly renders the escape as
Verification PerformedNo assertions or tests were lost. I ran both suites at
I also diffed the full set of The guard still bites. Both mutations reproduce exactly as the author reported:
Mutation 2 is the one that matters for this refactor, because it is the one that exercises the extracted math. It failed in both files: That confirms The corrected .bg-primary-hover\/50 { background-color: hsl(var(--primary-hover) / 0.5) }
.hover\:bg-destructive-hover\/90:hover { background-color: hsl(var(--destructive-hover) / 0.9) }
.hover\:bg-primary-hover\/90:hover { background-color: hsl(var(--primary-hover) / 0.9) }
.hover\:bg-destructive-hover:hover { background-color: hsl(var(--destructive-hover)) }
.hover\:bg-primary-hover:hover { background-color: hsl(var(--primary-hover)) }Alpha variants do compile (so the new "this is a convention, not a barrier" framing is accurate), and the two classes the component actually uses do emit opaque rules (so the fix remains unaffected). Standards. The new Findings🟢 Nits📁 The author's reasoning (the barrel re-exports DOM fixtures and node factories that these file-reading suites shouldn't pull in) is sound on its own terms, and I checked whether it is consistent with the codebase rather than just plausible. It is: 📁 Both suites import only AssessmentThis is a textbook address-review response. The author reproduced the reviewer's finding independently before acting on it, corrected the false claim in all three places it had spread to rather than only where it was flagged, and — most importantly — re-verified the guard by mutation after the refactor instead of trusting the passing test count. The instinct that "a refactor that quietly breaks a guard looks identical to one that doesn't" is exactly right, and calling for a re-review on a change that touched a file outside the original diff was the correct judgment rather than an excess of caution. The extraction is a genuine net improvement: −13 lines, one copy of the contrast math, and the hardest-won comment in the area now lives where both dependents see it. No blocking issues. No new issues. Nothing outstanding from the previous review. Recommendation: APPROVEBoth 🟡 findings and the 🟢 are fully addressed. The helper extraction is behaviorally byte-identical to both originals, neither suite lost a test or an assertion, both mutations still fire at full strength across both files, and the replacement 🤖 Generated with Claude Code |
malibio
left a comment
There was a problem hiding this comment.
Automated pragmatic-code-review (re-review): APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.
Re-review flagged that both are exported but only `contrast` is imported, asking that the choice be deliberate rather than incidental. Keeping them. They are the two WCAG primitives `contrast` is built from, not dead code, and an assertion about a single color — a non-ratio threshold, or whether a surface reads as light or dark — needs the luminance without the comparison. Hiding them would push the next such test back to a local copy of the math, which is the duplication this module was extracted to end. Comment-only; no behavior change. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Closes #2689.
The
--*-hovertokens added in #2673 were correct inapp.css. The shared shadcnButtonsimply never used them — it hovered tobg-destructive/90, an alpha fill composited against the page. Every filled variant lost contrast on hover, and dark-mode destructive landed at 3.39:1, below AA, on the "Remove database" control.Measured against each variant's own foreground:
defaultdefaultdestructivedestructiveEvery hover now clears AA and rises above its rest state.
dark:bg-destructive/60— dropped, and why it wasn't a free choiceThe issue asked whether the muted dark treatment was deliberate. It turns out to be a symptom of
text-white, not a design decision, and the two had to be resolved together:--destructivefill,text-whiteis 2.86:1./60translucency lightened that fill toward the page, which was the only thing keeping white legible there.So removing
/60alone would have made it worse, and keeping it under an opaque hover would have been incoherent. Both go. The variant is solid in both themes and labels with--destructive-foreground, taking dark rest from 2.86:1 to 6.95:1.Light mode is visually unchanged — light
--destructive-foregroundis0 0% 100%, identical to thetext-whiteit replaces. Only dark mode moves, which is where the defect was.Tailwind registration
Both tokens are registered without an
<alpha-value>placeholder, deliberately, sohover:bg-destructive-hover/90does not resolve. A hover fill is opaque by definition; admitting an alpha channel would reopen the very idiom this removes.Only
--primary-hover/--destructive-hoverare registered.--success/--warninghave no Tailwind color entry at all today and no utility usage, so registering just their hovers would have been incoherent.The test, and why a second suite
filled-button-hover.test.tspassed throughout the entire period this bug was live. It proves the token values obey the rule — necessary, but not sufficient. The gap between correct tokens and a component that ignores them is exactly how this shipped.filled-button-variants.test.ts(14 tests) covers the other half: each filled variant names its hover token, no alpha hover survives on a filled variant, no translucent rest fill remains, and the config entry carries no alpha channel.Verified by mutation rather than assumed:
<alpha-value>re-added to the config entry--destructive-hover76% → 64% — wrong direction, still 7.3:1The third is the case an AA floor alone would miss, and is why the load-bearing assertion compares hover contrast to rest contrast rather than to a constant.
Also compiled the real emitted class strings through PostCSS to confirm they resolve to opaque
hsl(var(--*-hover))rules and that zero alpha hover rules remain — a class-name assertion alone cannot prove the build emits anything.Deliberately not addressed
A rest-state AA floor.
--primaryis 3.51:1 light / 4.47:1 dark against its own foreground at rest — both under AA, both pre-existing properties of the brand color, and unreachable by any hover change. My first draft asserted a rest floor and failed on exactly this; asserting it would make the suite fail on a defect it does not own. Worth its own issue if the brand color is up for revision.Filed separately
Badgecarries the identical three defects from the same stock shadcn origin. Currently unreachable: every badge hover is gated behind[a&]:, and no badge in the codebase is a link or uses thedefault/destructivevariants. Latent, not live.DESIGN.mdstates "No outline/ghost variants in the current system" whileghost/outlineare used 57 times. Needs a design decision, not a transcription.Verification
bun run test— 250 files / 5148 tests passed (baseline 249 / 5134)bun run quality:fix— clean; design-token baseline unchanged at 137; svelte-check 2540 files, 0 errors, 0 warningsmain, once after)buttonVariantsusers are the calendar prev/next buttons on the untouchedoutlinevariantapp.cssuntouched — scope is the component and its Tailwind registrationDESIGN.mdupdated separately innodespace-docs(2c63616) to document the Tailwind consumption path and thetext-whiteprohibition — the gap that let a component drift while the tokens stayed correct.🤖 Generated with Claude Code