Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | 291x 889x 7x 76x 113x 5x 46x | import type { LucideIcon } from "lucide-react";
import { ChevronLeft, ChevronRight, CornerDownRight } from "lucide-react";
import React from "react";
// Shared section navigation for pages that split into top-level tabs
// (Inference, Knowledge, Governance). Generic over the section key so each
// page keeps its own string-union typing.
//
// A tab is the whole of the navigation wherever one list is one tab. Where a
// resource genuinely owns others — a skillset is the only way an agent gets a
// skill, a toolkit the only way it gets a tool — the owner is the tab and
// `SubsectionLinks` reaches the things inside it, with `SubsectionBackLink`
// coming back out. That keeps the nesting visible without a second, permanent
// level of chrome under the tab bar.
export interface SectionTabConfig<K extends string> {
key: K;
label: string;
Icon: LucideIcon;
/** Omit for a tab with nothing to count yet — one marked `badge`. */
count?: number;
/** A word in place of the count, e.g. "Soon" on a feature not yet
* available. */
badge?: string;
}
export interface SubpageConfig<K extends string> {
key: K;
label: string;
hint?: string;
Icon: LucideIcon;
/** Omit for a subpage that is a tool rather than a collection (Compare),
* where a count badge would have nothing to count. */
count?: number;
depth: number;
}
// ─── Tab bar ──────────────────────────────────────────────────────────────────
export function SectionTabBar<K extends string>({
tabs,
active,
onChange,
}: {
tabs: SectionTabConfig<K>[];
active: K;
onChange: (t: K) => void;
}) {
return (
// Tabs scroll rather than wrap: a page with six of them would otherwise
// break onto a second row on a narrow viewport and stop reading as one
// bar. `shrink-0` keeps each tab at its natural width inside the scroller.
<div
role="tablist"
className="flex items-center gap-1 border-b border-gray-200 dark:border-gray-700 mb-6 overflow-x-auto"
>
{tabs.map(({ key, label, Icon, count, badge }) => (
<button
key={key}
role="tab"
aria-selected={active === key}
onClick={() => onChange(key)}
className={`flex items-center gap-2 px-4 py-2.5 text-sm font-medium border-b-2 transition-colors -mb-px shrink-0 whitespace-nowrap ${
active === key
? "border-gray-900 dark:border-white text-gray-900 dark:text-white"
: "border-transparent text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200"
}`}
>
<Icon className="size-4" />
{label}
{count !== undefined && (
<span
className={`text-xs px-1.5 py-0.5 rounded-full font-mono tabular-nums ${
active === key
? "bg-gray-900 dark:bg-white text-white dark:text-gray-900"
: "bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400"
}`}
>
{count}
</span>
)}
{badge && (
<span className="text-[10px] uppercase tracking-wide px-1.5 py-0.5 rounded-full font-medium bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400">
{badge}
</span>
)}
</button>
))}
</div>
);
}
// ─── Subpage sidebar ──────────────────────────────────────────────────────────
export function SubpageSidebar<K extends string>({
items,
active,
onChange,
}: {
items: SubpageConfig<K>[];
active: K;
onChange: (s: K) => void;
}) {
return (
<nav className="w-full sm:w-56 shrink-0 flex flex-col gap-0.5">
{items.map(({ key, label, hint, Icon, count, depth }) => (
<button
key={key}
onClick={() => onChange(key)}
style={{ marginLeft: depth * 16 }}
className={`flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium text-left transition-colors ${
active === key
? "bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-white"
: "text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-800/50"
}`}
>
{depth > 0 && (
<CornerDownRight className="size-3.5 shrink-0 text-gray-400 dark:text-gray-500 -ml-1" />
)}
<Icon className="size-4 shrink-0" />
<span className="flex-1 min-w-0">
<span className="block truncate">{label}</span>
{hint && (
<span className="block text-xs font-normal text-gray-400 dark:text-gray-500 truncate">
{hint}
</span>
)}
</span>
{count !== undefined && (
<span
className={`text-xs px-1.5 py-0.5 rounded-full font-mono tabular-nums ${
active === key
? "bg-gray-900 dark:bg-white text-white dark:text-gray-900"
: "bg-gray-100 dark:bg-gray-800 text-gray-500 dark:text-gray-400"
}`}
>
{count}
</span>
)}
</button>
))}
</nav>
);
}
// ─── Subsection links ─────────────────────────────────────────────────────────
export interface SubsectionLinkConfig<K extends string> {
key: K;
label: string;
hint?: string;
Icon: LucideIcon;
count?: number;
}
/**
* The resources that live *inside* a tab, offered from that tab's own page.
*
* Skills and workers belong to skillsets, tools and MCP servers to toolkits —
* real containment, not a filing convenience. Listing them in a permanent
* sidebar made them read as peers of the thing that owns them and cost every
* page a column; listing them here says the same thing in the one place it is
* true, and only while the reader is there.
*/
export function SubsectionLinks<K extends string>({
items,
onSelect,
}: {
items: SubsectionLinkConfig<K>[];
onSelect: (key: K) => void;
}) {
return (
<div className="grid gap-2 sm:grid-cols-2 mb-6">
{items.map(({ key, label, hint, Icon, count }) => (
<button
key={key}
onClick={() => onSelect(key)}
className="group flex items-center gap-3 px-3.5 py-3 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 text-left hover:border-gray-300 dark:hover:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors"
>
<span className="flex items-center justify-center size-8 rounded-lg bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-300 shrink-0">
<Icon className="size-4" />
</span>
<span className="flex-1 min-w-0">
<span className="block text-sm font-medium text-gray-900 dark:text-gray-100 truncate">
{label}
</span>
{hint && (
<span className="block text-xs text-gray-400 dark:text-gray-500 truncate">
{hint}
</span>
)}
</span>
{count !== undefined && (
<span className="text-xs px-1.5 py-0.5 rounded-full font-mono tabular-nums bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 shrink-0">
{count}
</span>
)}
<ChevronRight className="size-4 text-gray-300 dark:text-gray-600 group-hover:text-gray-500 dark:group-hover:text-gray-400 shrink-0 transition-colors" />
</button>
))}
</div>
);
}
/** The way back out of a subsection, to the tab that owns it. */
export function SubsectionBackLink({
label,
onClick,
}: {
label: string;
onClick: () => void;
}) {
return (
<button
onClick={onClick}
className="inline-flex items-center gap-1 mb-4 text-xs font-medium text-gray-400 dark:text-gray-500 hover:text-gray-700 dark:hover:text-gray-300 transition-colors"
>
<ChevronLeft className="size-3.5" />
{label}
</button>
);
}
|