Repository navigation
feat(link): polymorphic link support with XDSLinkProvider - #337
Conversation
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsBreadcrumbs · View in Storybook
Link · View in Storybook
SideNav · View in Storybook
TabList · View in Storybook
TopNav · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 2 accessibility violation(s) found — 1 serious, 1 moderate. XDSSideNav - 1 issue(s)
XDSTabList - 1 issue(s)
Component PreviewsIncludes interactive hover previews as animated GIFs. XDSBreadcrumbsDefaultScreenshot: Interaction Preview: (view video) View in Storybook · Supporting Variant with IconsScreenshot: View in Storybook · XDSLinkXDSSideNavDefaultScreenshot: Interaction Preview: (view video) View in Storybook · XDSTabListDefaultScreenshot: Interaction Preview: (view video) View in Storybook · Menu With Selected ChildScreenshot: View in Storybook · Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
…-component as prop Adds a provider-based default + per-component `as` prop override so all linkable XDS components can render as custom link components (Next.js Link, React Router Link, etc.). New exports: - XDSLinkProvider — app-wide default link component - useXDSLinkComponent — hook for resolution (as > provider > 'a') - XDSLinkComponentType — type alias Modified components: - XDSLink, XDSSideNavItem, XDSTopNavItem, XDSTab, XDSBreadcrumbItem Closes #333 Co-authored-by: Navi <[email protected]>
6d562cf to
528dd1a
Compare
Summary
Adds polymorphic link rendering so all linkable XDS components can use framework-specific link components (Next.js
<Link>, React Router<Link>, TanStack Router, etc.) instead of hardcoded<a>elements.Two-layer resolution:
asprop (per-component) →XDSLinkProvidercontext → default<a>.New API
App-wide provider
Per-component override
Affected Components
XDSLink<a>→LinkComponent(always)XDSSideNavItem<a>→LinkComponent(href branch only, button unchanged)XDSTopNavItem<a>→LinkComponent(always)XDSTab<a>→LinkComponent(href branch only, button unchanged)XDSBreadcrumbItem<a>→LinkComponent(non-current only, span unchanged)New Exports
XDSLinkProvider— context provideruseXDSLinkComponent(as?)— resolution hookXDSLinkComponentType— type alias (ElementType)Test Plan
asoverride, provider, nested providersasprop, provider integration, fallback behavior (button/span preserved)yarn build✅ |yarn test✅ (1027 tests) |yarn lint✅Demo
Sandbox demo page at
/pages/polymorphic-linkshows provider, per-component override, and default behavior.Closes #333
Crafted with care by Navi