Something went wrong. Try again.
ATProto-based AI Assistant Chat interface.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147import { 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<LinkProps['to']> 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 ( <div> {props.label && ( <Text as="p" size="xs" color="muted" weight="semibold" className="mt-3 mb-1 px-row-inset tracking-label" > {props.label} </Text> )} <ul className="flex flex-col gap-0.5"> {props.sections.map((section) => ( <li key={section.to}> <Link to={section.to} activeOptions={ section.exact ? { ...props.activeOptions, exact: true } : props.activeOptions } className={cn( sidebarRow, 'wide:hover:bg-surface/55 wide:aria-[current=page]:bg-surface', )} > {section.icon} {section.label} </Link> </li> ))} </ul> </div> )}
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 ( <> <BackToChats /> <p className="mb-1.5 wide:mb-3 px-row-inset font-semibold text-body text-ink wide:text-title tracking-heading wide:tracking-title"> {props.title} </p> </> )}
const areas = [ { area: 'settings', to: '/settings', label: 'Settings', icon: <SettingsIcon /> }, { area: 'admin', to: '/admin', label: 'Admin', icon: <ShieldIcon /> },] 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 ( <> <BackToChats /> <div className="mb-2 flex gap-0.5 rounded-md bg-row-active p-1"> {areas.map((area) => { if (area.area === props.open) return ( <span key={area.area} aria-current="true" className={cn(areaTab, 'ring-(length:--hairline) bg-raised text-ink ring-line')} > {area.icon} {area.label} </span> ) return ( <Link key={area.area} to={area.to} className={cn( areaTab, 'text-muted transition-colors duration-(--dur-feedback) hover:text-ink', )} > {area.icon} {area.label} </Link> ) })} </div> </> )}
/** The way back to the chats, with room below before what names these sections. */function BackToChats() { return ( <Link to="/" activeOptions={{ exact: true }} className={cn(sidebarRow, 'mb-2.5 wide:mb-1 text-muted text-small hover:text-ink')} > <ArrowLeftIcon /> Back to chats </Link> )}