Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

SettingsBreadcrumb.tsx

35 lines1.1 KB

1import {
2 WorkspaceBreadcrumb,
3 WorkspaceBreadcrumbItem,
4 WorkspaceBreadcrumbSeparator,
5} from "../WorkspaceBreadcrumb";
6import { SETTINGS_SECTION_LABELS } from "./settingsSearch";
7​
8const SETTINGS_BREADCRUMB_LABELS: Readonly<Record<string, string>> = {
9 ...SETTINGS_SECTION_LABELS,
10 "/settings/diagnostics": "Diagnostics",
11 "/settings/open-source-licenses": "Open source licenses",
12};
13​
14function settingsBreadcrumbLabel(pathname: string): string | null {
15 const normalizedPathname = pathname.replace(/\/+$/, "") || "/";
16 return SETTINGS_BREADCRUMB_LABELS[normalizedPathname] ?? null;
18​
19export function SettingsBreadcrumb({ pathname }: { pathname: string }) {
20 const sectionLabel = settingsBreadcrumbLabel(pathname);
21​
22 return (
23 <WorkspaceBreadcrumb ariaLabel="Settings breadcrumb">
24 {sectionLabel ? (
25 <>
26 <WorkspaceBreadcrumbItem>Settings</WorkspaceBreadcrumbItem>
27 <WorkspaceBreadcrumbSeparator />
28 </>
29 ) : null}
30 <WorkspaceBreadcrumbItem current className="truncate">
31 {sectionLabel ?? "Settings"}
32 </WorkspaceBreadcrumbItem>
33 </WorkspaceBreadcrumb>
34 );