Repository navigation
fix(atoms): Link's focus ring is dead, Button's is under 3:1 - #134
Conversation
`Link` carried eight `focus:ring-<color>` classes and no width utility. Compiled against the repo's `[email protected]`, `focus:ring-teal-500` emits `--tw-ring-color` and nothing else; only `ring-2` writes the `box-shadow`. All eight were inert, so the link kept the UA outline. `Button` did draw a ring, but every light-theme colour it reached for sat under the 3:1 of WCAG 2.1 SC 1.4.11 against white — `teal-500` 2.70, `coral-500` 2.53, `gray-400` 1.71, `gray-500` 2.33 — and `focus:outline-none` suppressed the conformant UA outline behind it. So copying `Button`'s treatment into `Link`, the obvious fix, would have traded a working indicator for a failing one. `focusRing(theme)` is now the single treatment, in both atoms' `baseStyles`, and the `focus:ring-*` entries leave all four `Button` maps and both `Link` maps. Three decisions the ticket left open: - **Colour.** `teal-600` on light (3.85 on white) and `white` on dark. Dark surfaces are not one token — `teal-900`, OrnateTextBox's `#8a6f56`–`#473729` gradient, a photographic splash — so a brand colour cannot clear 3:1 on all of them. `white` measures 4.68 on the lightest of them and 12.21 on `teal-900`. - **Offset.** Kept, with the colour pinned per theme. `--tw-ring-offset-color` defaults to `#fff`, so a `theme="dark"` button drew a white band between itself and its ring. The band also gives the ring 3:1 on its inner edge, which it would not have against a `bg-teal-500` fill. - **Pseudo-class.** `focus-visible:`, matching `Image.tsx:356`. A mouse click no longer leaves the ring behind, and a browser without `:focus-visible` keeps its own outline rather than losing both. `Button` now passes `theme` down when `href` makes it render a `Link`. Without it the inner `Link` resolved its base ring light while `commonClassNames` carried the dark one, and two rules raced for `--tw-ring-color`. Scope stays on the two atoms. `EmbedButton`, `SocialIcon`, `Radio`, `Checkbox`, `Alert`, `Input`, `Textarea` and `Select` carry the same sub-3:1 colours and are the ticket's named follow-up. Closes #133 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qtr2xQwkgrtGthZJknbKAF
`docs/rules/design-system.md` carried no focus guidance, which is how two atoms disagreed about it. The new section under `## Common component patterns` names `focusRing(theme)` as the only treatment, gives the colour, width, offset and pseudo-class, and states the three traps behind them: a ring colour is inert without a width, the colour is per theme and never per variant, and `--tw-ring-offset-color` defaults to `#fff`. `components/atoms/README.md` points at it from the styling guideline, which said only "include a visible focus state". Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qtr2xQwkgrtGthZJknbKAF
Three findings from the review pass. `Image.tsx:356` already carried the helper's light branch character for character, so the branch was adding a third copy rather than removing one. It now calls `focusRing()`. Its `focus:outline-none` becomes `focus-visible:outline-none` with it, and the `#fff` it was relying on by default is now pinned as `ring-offset-white` — same pixels, said out loud. `focusRing` returns one of two module-level constants instead of building a 135-byte string per call. Measured at 110ns per call against 7ns for the constant, on a render React already charges ~2240ns for, so this is tidiness rather than a speed-up. It costs nothing and the signature is unchanged. `Link.test.tsx` asserted the same two classes twice, once on `default` and once on `unstyled`. One case over both variants says it, and the `unstyled` half is the one that proves the ring sits in `baseStyles` rather than in a variant entry. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qtr2xQwkgrtGthZJknbKAF
`DESIGN_SYSTEM.md`'s keyboard row prescribed `focus:ring-2 focus:ring-teal-600` — `focus:` rather than `focus-visible:`, and no offset colour. `docs/rules/design-system.md` names that file as the holder of the WCAG 2.1 AA rules, so the branch would have shipped the removed pattern still being taught at the root. The rule's own section stops claiming `focusRing` is the only treatment drawn. Eight components still carry their own, and none of them has a `theme` prop to hand it, which is why converting them is the follow-up rather than a rename. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Qtr2xQwkgrtGthZJknbKAF
Deploying wemeditate-design with
|
| Latest commit: |
599ad9c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1d3efff9.wm-design.pages.dev |
| Branch Preview URL: | https://claude-fix-133-focus-ring.wm-design.pages.dev |
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff is the size of the ticket and no larger, and both defects are fixed with evidence I could re-derive. One behaviour the ticket did not ask for matters most: making Link's ring live turns it on for variant="unstyled", and a header that renders over a dark splash passes no theme. That path gets a light ring and the white band #133 set out to remove.
Deferring the @utility focus-ring move is right. The blocker is the argument for it: an inheritable --focus-ring-color would fix that header without a theme prop on Logo.
Findings
- blocker — three dark-surface call sites pass no
theme(Link.tsx:79). - should-fix —
ring-offset-teal-900pins one dark surface (focusRing.ts:5). - consider — the barrel export has no consumer (
atoms/index.ts:51).
What was checked
- #133 against the diff: every acceptance criterion maps to a change.
- Read whole:
focusRing.ts,Link.tsx,Button.tsx, the new rule, both tests. - All 8
variant="unstyled"sites, andLayoutChrome.tsx:122above them.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
Making Link's ring live turned it on for variant="unstyled", and the two call sites in the header's top banner passed no theme. LayoutChrome renders that banner over the lead splash, so on a dark one they drew ring-teal-600 over a ring-offset-white band against a photograph — the white band #133 exists to remove, traded for the dead ring it also removes. Logo gains a theme prop because it owns the inner Link and had no way to say what it sits on. The sticky logo and map-pin follow the nav items beside them: light once the nav paints itself white, theme until then, since both stay tabbable while transparent. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjkKjdDophEatu4Ew6Am2o
Nothing imported it from there. All three callers reach for ../focusRing, and the atoms README already describes it as not a component, so the export only invited a fourth spelling. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjkKjdDophEatu4Ew6Am2o
The ring is only correct if the component knows what it sits on, and the header proved the default is silent when a caller forgets. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjkKjdDophEatu4Ew6Am2o
|
Pushed Adopted — the blocker: Adopted — the barrel export: dropped, nothing imported it. ( Rebutted — dropping the dark offset band: the case for it reads Gate green: 0 lint errors, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
wemeditate-web | 599ad9c | Commit Preview URL Branch Preview URL |
Oct 11 2026, 07:32 PM |
Both sides rewrote the same sentence in components/atoms/README.md. main (#175) corrected the token file from tailwind.config.ts to layouts/tailwind.css; this branch replaced the generic focus-state sentence with focusRing(theme). Kept both. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01N4nAVHRfbJbEtn2qhP1oB6
|
Merged Lean gate green on the merge commit: lint 0 errors, 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Both sides appended a describe block to Button.test.tsx: the touch-target cases here, the focus-indicator cases from #134. Kept both. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KwMoPa3aMVpKMsNSuWuH65
) * refactor(atoms): colour the focus ring from the surface, not a theme prop `focusRing(theme)` returned a class string per theme, so every component that sat on a dark surface had to be told so, and `Logo` grew a `theme` prop it used for nothing else. The ring now lives in `layouts/tailwind.css` as `@utility focus-ring`, reading two inherited custom properties. `:root` is light, and a container that paints a dark surface sets `surface-dark` once. - `Link` and `Button` claim a surface only when given a `theme`, so an unthemed atom inherits its container's instead of overriding it. - `Header`, `Splash`, `OrnateTextBox` and Ladle's dark `StorySection` set their surface. `Logo` loses its `theme` prop, and `Button` no longer threads `theme` into its inner `Link`. - `SocialIcon` and the `Splash` call to action adopt `focus-ring`. `SocialIcon`'s `teal-500` ring measured 2.70:1. - `layouts/tailwind.test.ts` compiles the real stylesheet and fails if a ring drops under 3:1 against its offset band. Follows #134. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(atoms): colour every surface-dependent atom from surface tokens The focus ring was the first colour to move into the surface. This moves the rest. `surface-light` and `surface-dark` now set thirteen tokens, and `@theme inline` exposes them as colours (`text-fg`, `text-fg-muted`, `text-primary`, `text-secondary`, `border-line`, `bg-tint`, ...), so a component resolves them against whatever surface it sits on. - `Link`, `Button`, `Icon`, `Spinner`, `Breadcrumbs`, `Countdown`, `Header` and `HeaderNavDropdown` lose their `theme` prop, and their paired light/dark colour maps become one map. - `Splash`, `ContentOverlay` and Ladle's `StorySection` keep a prop, renamed `surface`: only SahajCloud's `textColor` knows whether their image is dark. `lib/content-blocks.ts` inverts it once (`textColorToSurface`), and `LayoutChrome` sets the lead splash's surface on the header wrapper. - Two drifts resolved: neutral is white on every dark surface (`Link` was `gray-300`), and secondary is `coral-600` on light (`Icon` and `Spinner` were `coral-500`, 2.53:1). Dark text buttons no longer swap their primary/secondary hover fill. - `Button`'s spinner takes `border-current`, replacing two helpers that guessed a spinner colour per variant and theme. - `layouts/tailwind.test.ts` now also fails if a token resolves at `:root` (dropping `inline`) or if one surface omits a token. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Link's eightfocus:ring-<color>classes never drew a ring — no width utility, so Tailwind emitted--tw-ring-colorand nobox-shadow. Confirmed by compiling the repo's own[email protected].Buttonshipped sat under the 3:1 of WCAG 2.1 SC 1.4.11, andfocus:outline-nonesuppressed the conformant UA outline behind it.focusRing(theme)now servesLink,ButtonandImage:teal-600on light,whiteon dark,focus-visible:, offset colour pinned per theme.Changes
components/atoms/focusRing.ts— new. Two module-level constants behind a theme switch. Not exported from the atoms barrel: all three callers reach for../focusRing.components/atoms/{Link,Button}—focusRing(theme)inbaseStyles; thefocus:ring-*entries leave fourButtonmaps and bothLinkmaps.components/atoms/Button/Button.tsx— passesthemeto the innerLinkwhenhrefmakes it render one.components/atoms/Image/Image.tsx— was a third hand-rolled copy of the same classes; now calls the helper.components/atoms/graphics/Logo/Logo.tsx— gains athemeprop. It owns the innerLinkand had no way to say what surface it sits on.components/organisms/Header/Header.tsx— threadsthemeto the banner logo and action link, which render over the lead splash.DESIGN_SYSTEM.md,docs/rules/design-system.md— the keyboard row taughtfocus:ring-2 focus:ring-teal-600, the pattern this branch removes.Preview
LinkandButtonstories each have a Dark Theme section.Test results
pnpm lint(0 errors, warning count unchanged at 2121),tsc --noEmit,vitest run— 78 files, 795 testsLink.test.tsxandButton.test.tsx, plus 2 inHeader.test.tsxcovering the dark-surface callerscomment-lint --base origin/main: no banned comment addedManual verification
Contrast is computed, not observed, so the pixels want one human pass:
pnpm ladle→LinkandButtonstories. Tab through the Dark Theme section of each (they render onbg-gray-800). The indicator should match in width, colour and offset, and no white band should appear between a button and its ring.Buttonwith the mouse. The ring should not persist — that is thefocus:→focus-visible:change.Image. It should look identical to before; only the class source changed.Notes for reviewer
Three open questions from the ticket, decided here:
theme="dark"renders onteal-900,OrnateTextBox's#8a6f56→#473729gradient, photographic splashes, andbg-gray-800in Ladle.whiteis the only ring that clears 3:1 on all of them — 3.85 on the lightest (teal-600), 4.68 on#8a6f56, 12.21 onteal-900. A brand colour cannot.focus:orfocus-visible:?focus-visible:, matchingImage.tsx. A browser without:focus-visiblekeeps its own outline rather than losing both.ring-offset? Kept, colour pinned per theme. The band is what gives the ring 3:1 on its inner edge. Without it the white dark-theme ring sits flush againstbg-teal-500(2.70),bg-coral-500(2.53) andneutral'sbg-white(1.00).One finding I did not act on, and it is the reviewer's call. The altitude pass argued the indicator belongs in
layouts/tailwind.cssas@utility focus-ringwith an inheritable--focus-ring-color, not as a TS function. The evidence is good: the repo already has three@utilityblocks,docs/rules/tailwind.mdsays a CSS concern in a.tsxfile is wrong, and none of the eight deferred components has athemeprop — so the string-returning shape is why they had to be deferred. The review round below sharpened this: threadingthemethroughLogois the cost the custom property would avoid. I left it because adopting it properly means setting the property on every dark container (Splash,OrnateTextBox,ContentOverlay,StorySection, …), which widens this PR well past the ticket. Worth its own ticket.Review round 1
930197a) — makingLink's ring live turned it on forvariant="unstyled", and the header's banner logo and action link passed notheme. On a dark lead splash they drewring-teal-600over aring-offset-whiteband against a photograph.Logogains athemeprop;Headerthreads it. The sticky logo and map-pin takeisSticky ? 'light' : theme, matching the nav items beside them — they sit onbg-whiteonce visible and stay tabbable while transparent. TwoHeaderspecs pin it, and both fail if the threading is reverted.ring-offsetfromDARKwas argued from the dark-theme text button fills only.iconOnlyDarkThemeStylesusesteal-500/coral-500, and bothneutralentries arebg-white, so a flush white ring would measure 2.70, 2.53 and 1.00 on its inner edge. The teal band on the brown gradient is a real blemish, but it sits inside the indicator and the white outer edge still clears 4.68. Left open for the reviewer.bacb407) — dropped the unusedfocusRingbarrel export.Detail
Evidence for the two defects. Compiling
[email protected]through its owncompile()API:Only the width utility writes
box-shadow. The same compile confirms--tw-ring-offset-colorinitialises to#fff, which is the unintended band.Contrast, recomputed from
layouts/tailwind.cssrather than taken from the ticket — the numbers matched:teal-5002.70,coral-5002.53,gray-4001.71,gray-5002.33,teal-6003.85, all on#ffffff.Why
Buttonpassesthemedown. Withhref,Buttonrenders<Link variant="unstyled" className={commonClassNames}>.Linkresolved its own base ring on the default light theme whilecommonClassNamescarried the dark one, and two rules raced for--tw-ring-color. Passingthememakes the duplicates identical instead. The five repeated classes cost 136 bytes per button-link raw and ~5 bytes after brotli, against 16<Button href>sites in the repo.Rejected: drop the ring from
variant="unstyled". That would remove the duplication at the source, butunstyledhas eight consumers besidesButton—Logo,ContentCard,Column,Header(×2),HeaderDropdown,AtlasContent(×2) — and several supply no ring of their own. They would ship with no focus indicator at all.Which
unstyledcallers actually neededtheme. Only the header's banner pair.ContentCard,ColumnandAtlasContentset gray or teal text on light surfaces;HeaderDropdown's links sit in the dropdown panel;ContentCard's white-textLogohas nohref, so it renders a div and draws no ring.Rejected:
Button.test.tsxre-pinning literalsLink.test.tsxalready pins. The ticket asks for a spec in each file. Kept deliberately.Reviews run.
/simplify's four lenses (reuse, simplification, efficiency, altitude)./pr-review-toolkit:review-pris not installed in this environment, so that step did not run — flagged rather than substituted./security-reviewskipped: no path matchessecurityReview.triggerPattern.Closes #133
🤖 Written by the sydevs autonomous loop — see what this is
🤖 Generated with Claude Code
https://claude.ai/code/session_01UjkKjdDophEatu4Ew6Am2o