feat(ui): add css :target deeplinks to CodeTabs - #9144
Open
joebasrawi wants to merge 2 commits into
Open
Conversation
Replace Radix tabs in CodeTabs with a pure HTML/CSS implementation so URL fragments select a tab via :target without hash event listeners.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
5 tasks
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.
Implements deep linking for
CodeTabswith pure HTML/CSS, following @ovflowd’s direction on #9140. Radix Tabs are no longer used for this component; tab switching is fragment links and:target.Clicking a tab is an
<a href="#id">, so the URL updates natively. Loading/path#idselects that tab via CSS. Nohashchangelisteners.How
:targetworks<a id="…" href="#…">.:targetstyles the active trigger.:has(.trigger:nth-child(n):target).CodeTabsinstance does not contain the current fragment (no hash, unmatched hash, or another group’s tab),[data-default](first tab, ordefaultTab/defaultValue) is shown.ID scheme
groupId{slug(groupId)}-{slug(tabKey)}e.g.install-js-0groupId)codetabs-{useId}-{slug(tabKey)}e.g.codetabs-r1-js-0MDX already uses
tabKey={language}-{index}.useIdmakes multiple CodeTabs on one page unique. Authors can passgroupIdfor stable permalinks.Common/Tabsis unchanged and still uses Radix.Validation
@node-core/ui-componentsunit tests: initial#idselects the right tab, clicks updatelocation.hash, hash navigation between tabs, unmatched hash keeps the default, two CodeTabs on one page do not collide.pnpm --filter @node-core/ui-components test:unitpassing (60 tests).lint:js,lint:css, andlint:typespassing.Fixes #9140
Check List
pnpm formatto ensure the code follows the style guide.@node-core/ui-componentsunit tests).pnpm buildto check if the website builds without errors.