Repository navigation
feat(ui): switcher row fields and renderNetworkLabel - #857
Merged
Merged
Conversation
# Conflicts: # packages/ui/CHANGELOG.md # packages/ui/scripts/size-budget.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
NetworkSwitcherItemgainsdescription?,status?,mark?andhrefLang?. All are display strings the app writes in the page's language.SiteHeaderandSiteHeaderStatictakerenderNetworkLabel?: (item: NetworkSwitcherItem) => ReactNode.aria-hidden="true".sr-only) copy oflabel, then themarkwhen 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 tolabel.aria-label. See "Why notaria-label" below.w-72panel; nolayout="wide"and nolead.text-xs), then the status chip (muted text in a hairline pill).text-xs).aria-hidden, and the anchor names them witharia-describedby. The ids aresite-network-<group>-<index>-dand-s. No hook is needed, so the static header still renders on the server.hrefLanggoes on the row anchor.homeHrefwitharia-current="true".current,hrefandlabelrenders 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.RenderNetworkLabel.HomeLinkPropsgains optionalaria-describedbyandhrefLang.linkMark(mark?)andMUTED_TEXTtolib/shell-link.ts. They use plaincreateElement, becauselib/has no.tsx. PR4 (feat(ui): link options on nav, footer and CTA #855) can reuselinkMarkfor nav and footer marks.NetworkSwitcher's inlineonBlurmoved intouseDisclosureashandleBlur, with no change in behaviour.Layout/SiteHeader/RichRowsshows rows with a description, a status, a mark and a lockup throughrenderNetworkLabel. Itsplaystep opens the switcher, so axe and Visual Diff see the rows.site-header.mdx(API row, Network section, example) andsite-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 failedlabel-content-name-mismatchon everyRichRowsrow. axe counts all text inside the anchor as visible, including thearia-hiddendescription and status and the mark, and that text was not in thearia-label.With a visually hidden label and no
aria-label, the rule doesn't apply. The name is stilllabel(thenmark), and the description and status are still read througharia-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.tsxandsite-header-static.test.tsx(the spec's PR3 row):aria-describedby.markandhrefLangland on the anchor.homeHrefwitharia-current.current,hrefandlabelholds its bare label.renderNetworkLabel, the link's accessible name is the label, then the mark (App EN), with no lockup text. The lockup is insidearia-hidden="true", and the anchor has noaria-label.The 0.4.0 markup snapshots cover the call with no new prop.
Red before green:
aria-labelversion) 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/maine60b561 with #843 and #856)pnpm --filter @vllnt/ui linttsc --noEmit -p tsconfig.build.jsontest:once(full@vllnt/uisuite)check:circular,check:atomic,check:use-clientbuild,check:dist-importssize@vllnt/ui-registry registry:sync-shims,test:once,registry:integrity,registry:checkRichRowswith the panel open (local Storybook, the runner's tagswcag2a/2aa/21a/21aa/22aa, page-level rules off)w-72) at x 20 / 96, with no horizontal scroll. Link names areAcme Docs,Acme App,Acme Blog ENandAcme Cloud. Row labels compute tooklch(0 0 0)in light andoklch(1 0 0)in dark.test:visualon the header stories*.visual.tsxexists for either header (0 tests). Visual Diff in CI screenshots every story,RichRowsincluded.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)e60b5619(budget 1,950,170 B, set by #843)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:
aria-hiddenhrefLangset in one placeThe lockup fix adds about 80 B: the
aria-hiddenwrapper and thesr-onlylabel.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:
network-listlib/shell-linksite-header-staticnetwork-switchersite-headerNotes
size-budget.jsonandCHANGELOG.md.