feat(website): let homepage sections switch between video and code - #831
Merged
Conversation
Wire MediumSwitcher into the homepage Stream and Approve FeatureBlocks, building panes server-side via buildPanes() so HighlightedCode (an async Server Component) can be highlighted before being passed as a client prop. Also registers the 'home_medium_switcher' analytics surface and the sectionId_key cta_id pattern MediumSwitcher already emits — this was required for the production type-check to pass.
Every other loose CtaId member is prefix-anchored (copy_${string},
nav_${string}, footer_${string}, final_cta_${string}, home_demo_${string}),
which keeps the union a controlled vocabulary filterable by surface prefix.
The suffix-anchored ${string}_video/_code/_live members added for
MediumSwitcher broke that pattern and matched any string with the right
suffix regardless of surface. Prefix the emitted id with medium_ instead
and collapse the union to a single medium_${string} member.
MediumPane.key ('video'|'code'|'live') was doing double duty as both the
DOM/React identity and the analytics medium tag. SectionMedia.code is
readonly SolutionCode[], so a section with two code blocks would produce
two panes both keyed 'code', colliding on React key, tabId, and panelId
and breaking aria-controls/aria-labelledby. Add a separate MediumPane.id
for identity and keep .key for analytics only; page.tsx now indexes code
panes as code-0, code-1, ... and uses the block's own label when there is
more than one.
Also: correct the LANGGRAPH_CLIP comment, which claimed DemoShowcase
imports it (it doesn't — still hardcodes its own URLs), and give each
MediumSwitcher instance a section-specific tablist aria-label so a
screen-reader user can tell the Stream and Approve switchers apart.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
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.
Phase 1 of the medium switcher spec, executed from the plan.
A reader can now view the Stream and Approve sections as a video or as code. Different readers want different evidence — a video proves it's real, code proves it's small — and the homepage previously showed no code at all despite being a developer framework.
The constraint that shaped it
Only the active pane is mounted. Inactive panes are absent from the DOM, not hidden with CSS — otherwise the homepage would fetch every video on load. The built output confirms it: 2 tablists, 2
<video>elements, one per section.This is pinned by a test that was itself verified to fail: rendering every pane makes
mounts only the active panefail. Without that check, a later "cleanup" to CSS-toggling would pass the suite while quietly regressing the page.HighlightedCodeis an async Server Component, so a client component can't render one as a child. Code panes are highlighted inpage.tsxon the server and passed in as props — that's what makes the code tab possible at all.Three defects caught in review
Arrow keys changed selection without moving focus. The classic ARIA tabs trap:
aria-selectedmoved, DOM focus didn't, and because the newly-inactive tab keepstabIndex={-1}, the next Tab press skipped the entire tablist. The arrow-key test only assertedaria-selected, which is exactly how it got through — it now assertsdocument.activeElement, and that assertion was confirmed to fail before the fix.Duplicate pane ids.
SectionMedia.codeisreadonly SolutionCode[], so two code blocks were always possible — and both would have been keyed'code', colliding on the React key and producing duplicate DOM ids that breakaria-controls/aria-labelledby.MediumPanenow carries aniddistinct from its mediumkey; the built page shows four unique tab ids. Regression test included.A suffix-anchored analytics type. The first fix widened
CtaIdwith`${string}_video`, which accepts any string ending in_videofrom any surface. Every other loose member in that union is prefix-anchored (nav_${string},home_demo_${string}), so the id is nowmedium_<section>_<medium>and the union member is`medium_${string}`.Home/End key support was added alongside the focus fix.
Also here
LANGGRAPH_CLIPmoves intodemo-media.tsrather than being re-declared. Its comment states plainly thatDemoShowcasestill hardcodes its own copies — an earlier draft claimed the constant prevented drift, which was false while only one consumer used it.Known follow-ups (not in this PR)
DemoShowcasehas an incomplete ARIA tabs pattern —role="tablist"/role="tab"/aria-selectedwith noaria-controls, no roving tabindex, and no keyboard handling. That's worse than plain buttons: it promises assistive tech a widget it doesn't deliver. Tracked separately; it's a live homepage section and deserves its own change.<video>block now exists acrosspage.tsx,DemoShowcase.tsx, andSolutionDemoBlock.tsx. Worth extracting a shared player overDemoClip.public/screenshots/cockpit-docs.webpis now unreferenced (it was the old Stream visual). Verified withgrep -rn "cockpit-docs" apps/website/src→ no matches. Left in place for an asset-pruning pass.Verification
npx vitest run --config vite.config.mtsfromapps/website: 334 passed, 5 failed — the same pre-existing failures inthanks/page.spec.tsx,PostCard.spec.tsx,Differentiator.spec.tsx, untouched here (321 at branch point; 13 added tests account for the delta)nx lint website: 0 errors, 29 warnings (unchanged)nx build website --configuration=production: succeeds🤖 Generated with Claude Code