ai-subnav.tsx44 lines · main
| 1 | 'use client'; |
| 2 | |
| 3 | import Link from 'next/link'; |
| 4 | import { usePathname } from 'next/navigation'; |
| 5 | |
| 6 | const AI_TABS = [ |
| 7 | { suffix: '/ai-schema', label: 'schema' }, |
| 8 | { suffix: '/ai-function', label: 'function' }, |
| 9 | { suffix: '/ai-explain', label: 'explain' }, |
| 10 | ] as const; |
| 11 | |
| 12 | /** |
| 13 | * Sub-nav for the three AI features under one `ai` project tab. |
| 14 | * Renders inline above each ai-* page; the parent tab nav stays |
| 15 | * collapsed to a single `ai` entry so we don't pollute it. |
| 16 | */ |
| 17 | export function AiSubnav({ projectId }: { projectId: string }) { |
| 18 | const pathname = usePathname(); |
| 19 | const base = `/dashboard/projects/${projectId}`; |
| 20 | return ( |
| 21 | <nav |
| 22 | aria-label="ai sections" |
| 23 | className="flex gap-1 border-b border-[var(--color-border-subtle)] pb-2 font-mono text-xs" |
| 24 | > |
| 25 | {AI_TABS.map((tab) => { |
| 26 | const href = `${base}${tab.suffix}`; |
| 27 | const active = pathname.startsWith(href); |
| 28 | return ( |
| 29 | <Link |
| 30 | key={tab.suffix} |
| 31 | href={href} |
| 32 | className={`rounded-md px-3 py-1.5 transition ${ |
| 33 | active |
| 34 | ? 'bg-[var(--color-surface-raised)] text-[var(--color-text)]' |
| 35 | : 'text-[var(--color-text-muted)] hover:text-[var(--color-text)]' |
| 36 | }`} |
| 37 | > |
| 38 | {tab.label} |
| 39 | </Link> |
| 40 | ); |
| 41 | })} |
| 42 | </nav> |
| 43 | ); |
| 44 | } |