import { type ActiveOptions, Link, type LinkProps } from '@tanstack/react-router' import type { ReactNode } from 'react' import { cn } from './cn.ts' import { ArrowLeftIcon, SettingsIcon, ShieldIcon } from './icons.tsx' import { sidebarRow } from './ui/sidebar.ts' import { Text } from './ui/Text.tsx' export interface Section { to: NonNullable label: string icon?: ReactNode /** Whether only the section's own path counts as it, not the pages under it. */ exact?: boolean } interface Props { sections: readonly Section[] /** When a section's link counts as the current page, by default its path and the pages under it. */ activeOptions?: ActiveOptions /** A quiet label over the links, for sections in groups. */ label?: string } /** * A list of links to a page's sections, marking the current one. Beside the section on a wide * screen, the open one is a grey tint. */ export function SectionNav(props: Props) { return (
{props.label && ( {props.label} )}
) } interface HeaderProps { title: string } /** The way back to the chats over the name of these sections, big beside them on a wide screen. */ export function NavHeader(props: HeaderProps) { return ( <>

{props.title}

) } const areas = [ { area: 'settings', to: '/settings', label: 'Settings', icon: }, { area: 'admin', to: '/admin', label: 'Admin', icon: }, ] as const /** A tab of `AreaTabs`, its icon a step smaller to suit its text. */ const areaTab = 'flex flex-1 items-center justify-center gap-1.5 rounded-sm py-1 font-medium text-small no-underline [&_svg]:size-3.75' interface TabsProps { /** The area open, which the tabs name in place of a title. */ open: (typeof areas)[number]['area'] } /** * For admins, the way back to the chats over tabs between their settings and the admin area, so the * other area is always in view at the top. The open one is a raised card on the tray rather than a * link, since it would only lead back to its first section, and marks the area rather than the page, * which the section's own link marks. */ export function AreaTabs(props: TabsProps) { return ( <>
{areas.map((area) => { if (area.area === props.open) return ( {area.icon} {area.label} ) return ( {area.icon} {area.label} ) })}
) } /** The way back to the chats, with room below before what names these sections. */ function BackToChats() { return ( Back to chats ) }