// DocShell composition — sidebar + main grid for documentation. // Sidebar nav is data-driven (group → entry tree); apps pass their // own structure. Sticky sidebar, scrollable main, responsive collapse // to single-column under 800px. // // `LinkComponent` lets the app inject a client-side router (e.g. // `Link` from `@voltro/web`) so sidebar nav doesn't trigger full // page reloads. Default is plain `` so the kit stays // router-agnostic and works in any host. import type { ComponentType, ReactNode } from 'react' import { cn } from '../cn' export interface DocNavEntry { readonly label: string readonly href: string } export interface DocNavGroup { readonly section: string readonly entries: ReadonlyArray } // Minimal Link prop surface — matches @voltro/web's Link with `to`, // and degrades cleanly to a plain when not provided. export interface ShellLinkProps { readonly to: string readonly className?: string readonly children: ReactNode /** Pre-warm the destination on hover/focus. */ readonly prefetch?: boolean } interface DocShellProps { readonly brand: ReactNode readonly nav: ReadonlyArray readonly children: ReactNode readonly currentPath?: string readonly className?: string /** Search form GET action. When set, renders a search input that * POSTs ?q=… to this URL. */ readonly searchAction?: string /** Placeholder for the search input. Default `'Search docs…'`. */ readonly searchPlaceholder?: string /** `aria-label` for the search input. Default `'Search docs'`. */ readonly searchLabel?: string /** Optional client-router Link. Passing `Link` from `@voltro/web` * upgrades every sidebar entry to client-side navigation with * loader prefetch. */ readonly LinkComponent?: ComponentType } const PlainLink = ({ to, className, children }: ShellLinkProps): ReactNode => ( {children} ) export const DocShell = ({ brand, nav, children, currentPath, className, searchAction, searchPlaceholder = 'Search docs…', searchLabel = 'Search docs', LinkComponent = PlainLink, }: DocShellProps): ReactNode => { const Link = LinkComponent return (
{children}
) }