Skip to content

fix(atoms): Link's focus ring is dead, Button's is under 3:1 - #134

Merged
sydevs-bot merged 9 commits into
mainfrom
claude/fix-133-focus-ring
Oct 12, 2026
Merged

sydevs-bot merged 9 commits into
mainfrom
claude/fix-133-focus-ring

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Link's eight focus:ring-<color> classes never drew a ring — no width utility, so Tailwind emitted --tw-ring-color and no box-shadow. Confirmed by compiling the repo's own [email protected].
  • Every light-theme ring colour Button shipped sat under the 3:1 of WCAG 2.1 SC 1.4.11, and focus:outline-none suppressed the conformant UA outline behind it.
  • One focusRing(theme) now serves Link, Button and Image: teal-600 on light, white on 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) in baseStyles; the focus:ring-* entries leave four Button maps and both Link maps.
  • components/atoms/Button/Button.tsx — passes theme to the inner Link when href makes 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 a theme prop. It owns the inner Link and had no way to say what surface it sits on.
  • components/organisms/Header/Header.tsx — threads theme to the banner logo and action link, which render over the lead splash.
  • DESIGN_SYSTEM.md, docs/rules/design-system.md — the keyboard row taught focus:ring-2 focus:ring-teal-600, the pattern this branch removes.

Preview

Test results

  • Lean gate: ✓ pnpm lint (0 errors, warning count unchanged at 2121), tsc --noEmit, vitest run — 78 files, 795 tests
  • Targeted specs: 8 focus cases across Link.test.tsx and Button.test.tsx, plus 2 in Header.test.tsx covering the dark-surface callers
  • Build: N/A — no build/server/Wrangler change
  • comment-lint --base origin/main: no banned comment added
  • 12 files changed

Manual verification

Contrast is computed, not observed, so the pixels want one human pass:

  1. pnpm ladle → Link and Button stories. Tab through the Dark Theme section of each (they render on bg-gray-800). The indicator should match in width, colour and offset, and no white band should appear between a button and its ring.
  2. Click a Button with the mouse. The ring should not persist — that is the focus: → focus-visible: change.
  3. Tab through the header on a page with a dark lead splash. The logo and the action link should draw a white ring, not a teal one over a white band.
  4. Tab to a lightbox-enabled Image. It should look identical to before; only the class source changed.

Notes for reviewer

Three open questions from the ticket, decided here:

  • Which dark surfaces? Not one token. theme="dark" renders on teal-900, OrnateTextBox's #8a6f56→#473729 gradient, photographic splashes, and bg-gray-800 in Ladle. white is the only ring that clears 3:1 on all of them — 3.85 on the lightest (teal-600), 4.68 on #8a6f56, 12.21 on teal-900. A brand colour cannot.
  • focus: or focus-visible:? focus-visible:, matching Image.tsx. A browser without :focus-visible keeps its own outline rather than losing both.
  • Keep 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 against bg-teal-500 (2.70), bg-coral-500 (2.53) and neutral's bg-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.css as @utility focus-ring with an inheritable --focus-ring-color, not as a TS function. The evidence is good: the repo already has three @utility blocks, docs/rules/tailwind.md says a CSS concern in a .tsx file is wrong, and none of the eight deferred components has a theme prop — so the string-returning shape is why they had to be deferred. The review round below sharpened this: threading theme through Logo is 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

  • blocker, adopted (930197a) — making Link's ring live turned it on for variant="unstyled", and the header's banner logo and action link passed no theme. On a dark lead splash they drew ring-teal-600 over a ring-offset-white band against a photograph. Logo gains a theme prop; Header threads it. The sticky logo and map-pin take isSticky ? 'light' : theme, matching the nav items beside them — they sit on bg-white once visible and stay tabbable while transparent. Two Header specs pin it, and both fail if the threading is reverted.
  • should-fix, rebutted — dropping ring-offset from DARK was argued from the dark-theme text button fills only. iconOnlyDarkThemeStyles uses teal-500/coral-500, and both neutral entries are bg-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.
  • consider, adopted (bacb407) — dropped the unused focusRing barrel export.
Detail

Evidence for the two defects. Compiling [email protected] through its own compile() API:

.focus\:ring-teal-500:focus   { --tw-ring-color: var(--color-teal-500); }
.focus-visible\:ring-2:focus-visible {
  --tw-ring-shadow: … 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
  box-shadow: …;
}

Only the width utility writes box-shadow. The same compile confirms --tw-ring-offset-color initialises to #fff, which is the unintended band.

Contrast, recomputed from layouts/tailwind.css rather than taken from the ticket — the numbers matched: teal-500 2.70, coral-500 2.53, gray-400 1.71, gray-500 2.33, teal-600 3.85, all on #ffffff.

Why Button passes theme down. With href, Button renders <Link variant="unstyled" className={commonClassNames}>. Link resolved its own base ring on the default light theme while commonClassNames carried the dark one, and two rules raced for --tw-ring-color. Passing theme makes 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, but unstyled has eight consumers besides Button — 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 unstyled callers actually needed theme. Only the header's banner pair. ContentCard, Column and AtlasContent set gray or teal text on light surfaces; HeaderDropdown's links sit in the dropdown panel; ContentCard's white-text Logo has no href, so it renders a div and draws no ring.

Rejected: Button.test.tsx re-pinning literals Link.test.tsx already 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-pr is not installed in this environment, so that step did not run — flagged rather than substituted. /security-review skipped: no path matches securityReview.triggerPattern.

Closes #133

🤖 Written by the sydevs autonomous loop — see what this is

🤖 Generated with Claude Code

https://claude.ai/code/session_01UjkKjdDophEatu4Ew6Am2o

`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
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Deploying wemeditate-design with  Cloudflare Pages  Cloudflare Pages

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

View logs

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 23, 2026
@sydevs-bot

sydevs-bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 19:27Z resolve-conflicts · attempt 1 · session · done
  • 19:27Z resolve-conflicts · attempt 1 · session
  • 21:38Z address-review · attempt 1 · session · done
  • 21:38Z address-review · attempt 1 · session
  • 21:32Z adversarial-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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-900 pins 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, and LayoutChrome.tsx:122 above them.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread components/atoms/Link/Link.tsx Resolved
Comment thread components/atoms/focusRing.ts Resolved
Comment thread components/atoms/index.ts Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Sep 23, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Pushed 190fc6d. Two adopted, one rebutted.

Adopted — the blocker: Logo gains a theme prop and Header threads it to the banner logo and action link, which render over the lead splash. They drew ring-teal-600 over a white band on a photograph. Two Header specs pin it. (930197a)

Adopted — the barrel export: dropped, nothing imported it. (bacb407)

Rebutted — dropping the dark offset band: the case for it reads textButtonDarkThemeStyles only. iconOnlyDarkThemeStyles uses teal-500/coral-500 and both neutral entries are bg-white, so a flush white ring measures 2.70, 2.53 and 1.00 on its inner edge. Left open.

Gate green: 0 lint errors, tsc clean, 795 tests.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Sep 23, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review September 23, 2026 21:50
@sydevs-bot
sydevs-bot requested a review from Ardnived September 23, 2026 21:50
@sydevs-bot sydevs-bot moved this from Revising to Approved in SYDevelopers Technical Roadmap Sep 23, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 11, 2026
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
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Merged main in. One conflict, in components/atoms/README.md: both sides rewrote the last sentence of the Styling paragraph. Kept both — main's layouts/tailwind.css path correction (#175) and this branch's focusRing(theme) instruction. No code conflicted.

Lean gate green on the merge commit: lint 0 errors, tsc --noEmit, 832 tests across 84 files, including main's new jsx-literals and design-tokens guards.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot added awaiting and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 11, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Oct 12, 2026
Merged via the queue into main with commit 7cb4a02 Oct 12, 2026
25 checks passed
@sydevs-bot
sydevs-bot deleted the claude/fix-133-focus-ring branch October 12, 2026 17:07
@sydevs-bot sydevs-bot moved this from Approved to Done in SYDevelopers Technical Roadmap Oct 12, 2026
sydevs-bot pushed a commit that referenced this pull request Oct 12, 2026
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
Ardnived added a commit that referenced this pull request Oct 13, 2026
)

* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

fix(atoms): Link's focus ring is dead, Button's is under 3:1

3 participants