Skip to content

feat(ui): switcher row fields and renderNetworkLabel - #857

Merged
bntvllnt merged 8 commits into
mainfrom
feat/shell-switcher-rows
Dec 3, 2026
Merged

bntvllnt merged 8 commits into
mainfrom
feat/shell-switcher-rows

Conversation

@bntvllnt

@bntvllnt bntvllnt commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Part of #770

PR3 of the 0.5.0 shell API v2 plan (rows a1, a3 and b). Switcher rows can now carry more information, and an app can draw its own lockup in each row. The library still has no locale or status vocabulary.

What changes

  • New row fields: NetworkSwitcherItem gains description?, status?, mark? and hrefLang?. All are display strings the app writes in the page's language.
  • New header prop: SiteHeader and SiteHeaderStatic take renderNetworkLabel?: (item: NetworkSwitcherItem) => ReactNode.
    • The lockup it draws is decorative: it is wrapped in aria-hidden="true".
    • The link is named by a visually hidden (sr-only) copy of label, then the mark when one is set (Acme Blog EN). So the name is the app's string, with the visible label first (WCAG 2.5.3); the app keeps the lockup's visible text equal to label.
    • The anchor has no aria-label. See "Why not aria-label" below.
  • Row layout: compact only, inside the existing w-72 panel; no layout="wide" and no lead.
    • Line 1: the label (or lockup), then the mark (muted text-xs), then the status chip (muted text in a hairline pill).
    • Line 2: the description (muted text-xs).
    • The whole row stays one anchor, so the hit area is the row.
    • The description and status sit inside the anchor with aria-hidden, and the anchor names them with aria-describedby. The ids are site-network-<group>-<index>-d and -s. No hook is needed, so the static header still renders on the server.
  • Unchanged:
    • hrefLang goes on the row anchor.
    • The current row still links homeHref with aria-current="true".
    • A row with only current, href and label renders exactly as before. The 0.4.0 markup snapshots from feat(ui): data attributes and slots on shell links #844 (both headers, with and without a network) pass unchanged.
  • Exports, additive only:
    • New root type export: RenderNetworkLabel.
    • HomeLinkProps gains optional aria-describedby and hrefLang.
    • Nothing is removed or renamed.
  • Added linkMark(mark?) and MUTED_TEXT to lib/shell-link.ts. They use plain createElement, because lib/ has no .tsx. PR4 (feat(ui): link options on nav, footer and CTA #855) can reuse linkMark for nav and footer marks.
  • Refactor: NetworkSwitcher's inline onBlur moved into useDisclosure as handleBlur, with no change in behaviour.
  • Story: Layout/SiteHeader/RichRows shows rows with a description, a status, a mark and a lockup through renderNetworkLabel. Its play step opens the switcher, so axe and Visual Diff see the rows.
  • Docs: site-header.mdx (API row, Network section, example) and site-header-static.mdx. The CHANGELOG entry is in Unreleased → Added.

Owner defaults kept: flat panel with no shadow, compact only, no lead slot. Only existing tokens are used (text-muted-foreground, border-border); no new token, dependency or Radix.

Why not aria-label (changed from the v2 spec)

The first version put aria-label={item.label} on the anchor. CI's Storybook axe run then failed label-content-name-mismatch on every RichRows row. axe counts all text inside the anchor as visible, including the aria-hidden description and status and the mark, and that text was not in the aria-label.

With a visually hidden label and no aria-label, the rule doesn't apply. The name is still label (then mark), and the description and status are still read through aria-describedby. The v2 notes (row a1 and the PR3 acceptance cell) were updated to match.

Design references (Mobbin)

The Mobbin MCP is authenticated. These references show the same row pattern: a name, then a small inline status chip, then a muted line below.

The chip follows the label rather than sitting at the row's right edge, as in Vercel and Jasper. That costs fewer classes and wraps cleanly at 390 px.

Tests (written first)

Cases in site-header.test.tsx and site-header-static.test.tsx (the spec's PR3 row):

  1. The description and status render and are named by aria-describedby.
  2. mark and hrefLang land on the anchor.
  3. The current row still links homeHref with aria-current.
  4. A row with only current, href and label holds its bare label.
  5. Under renderNetworkLabel, the link's accessible name is the label, then the mark (App EN), with no lockup text. The lockup is inside aria-hidden="true", and the anchor has no aria-label.

The 0.4.0 markup snapshots cover the call with no new prop.

Red before green:

  • Cases 1, 2, 3 and 5 ran against the old source: 8 failed / 113 passed. Case 4 and the snapshots passed, as they should.
  • The new case 5 failed on f41771d (the aria-label version) in both files: 2 failed, because the marked row was named "App". With the fix it passes.

Gates (local, at this head, after merging origin/main e60b561 with #843 and #856)

Gate Result
pnpm --filter @vllnt/ui lint pass
tsc --noEmit -p tsconfig.build.json pass
test:once (full @vllnt/ui suite) pass (exit 0)
check:circular, check:atomic, check:use-client pass
build, check:dist-imports pass
size pass with the raise below
@vllnt/ui-registry registry:sync-shims, test:once, registry:integrity, registry:check pass
axe on RichRows with the panel open (local Storybook, the runner's tags wcag2a/2aa/21a/21aa/22aa, page-level rules off) 0 violations at 390 and 1280 px × light and dark × glass and solid
Real browser check (local Storybook, Playwright Chromium) 390 / 1280 px × light / dark: 0 console errors. The panel is 288 px (w-72) at x 20 / 96, with no horizontal scroll. Link names are Acme Docs, Acme App, Acme Blog EN and Acme Cloud. Row labels compute to oklch(0 0 0) in light and oklch(1 0 0) in dark.
test:visual on the header stories No test to run: no *.visual.tsx exists for either header (0 tests). Visual Diff in CI screenshots every story, RichRows included.

Size budget

Measured with pnpm -F @vllnt/ui build && node scripts/check-size.mjs (minified), both builds on the same machine:

* (every export, up front)
origin/main e60b5619 (budget 1,950,170 B, set by #843) 1,950,168 B
this PR 1,951,246 B
delta +1,078 B

The budget entry is raised by the delta, rounded up to 10 B: 1,950,170 → 1,951,250 B (+1,080 B).

Where the bytes come from:

  • The first build of the feature was +1,068 B. The row markup was then trimmed to +999 B:

    • one helper draws both hint spans
    • boolean aria-hidden
    • one shared muted-text class
    • hrefLang set in one place
  • The lockup fix adds about 80 B: the aria-hidden wrapper and the sr-only label.

  • The rest is the feature itself: two ARIA attribute names, the ids, the chip and row class strings, and the prop threaded through both headers.

  • By file, minified with esbuild against main before the lockup fix:

    File Delta
    network-list ~+685 B
    lib/shell-link +199 B
    site-header-static +77 B
    network-switcher +38 B
    site-header +35 B

Notes

@bntvllnt
bntvllnt marked this pull request as ready for review December 3, 2026 20:25
@bntvllnt
bntvllnt merged commit c614cb0 into main Dec 3, 2026
31 of 32 checks passed
@bntvllnt
bntvllnt deleted the feat/shell-switcher-rows branch December 3, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant