29 lines
1.3 KiB
TypeScript
29 lines
1.3 KiB
TypeScript
// Which routes are full-bleed inside the shell; every other route gets the
|
|
// same centred body. Kept apart from `Shell.tsx` so it is a plain function of
|
|
// a path, with no DOM or CSS behind it, and can be tested.
|
|
|
|
// `/agents/:name/terminal` (and a subagent's, under
|
|
// `/agents/:name/subagents/:subagent/`) is full-bleed: the terminal fills
|
|
// the whole viewport below the header bar, edge to edge (`shell-full` /
|
|
// `shell-body-full` in Shell.css). It's a parameterized path, so one literal
|
|
// string can't match every agent name.
|
|
const FULL_BLEED_ROUTE_PATTERN =
|
|
/^\/agents\/[^/]+(\/subagents\/[^/]+)?\/terminal$/;
|
|
|
|
// The start page (`/`) is full-bleed too: its rain backdrop fills the whole
|
|
// body below the header.
|
|
export function isFullBleedRoute(location: string): boolean {
|
|
return location === "/" || FULL_BLEED_ROUTE_PATTERN.test(location);
|
|
}
|
|
|
|
// Routes that only a developer needs. "hide developer details" takes their
|
|
// tabs out of the nav; the pages themselves still answer at their paths.
|
|
const DEVELOPER_ROUTES = ["/components"];
|
|
|
|
export function visibleNavItems<T extends { href: string }>(
|
|
items: readonly T[],
|
|
hideDeveloper: boolean,
|
|
): readonly T[] {
|
|
if (!hideDeveloper) return items;
|
|
return items.filter((item) => !DEVELOPER_ROUTES.includes(item.href));
|
|
}
|