🚧 WIP: copy command bar from existing PR

This commit is contained in:
Fred KISSIE
2026-06-11 23:46:11 +02:00
parent 3e977ba00d
commit 444d293a29
11 changed files with 986 additions and 39 deletions
+42
View File
@@ -0,0 +1,42 @@
import type { ReactNode } from "react";
import type {
SidebarNavItem,
SidebarNavSection
} from "@app/components/SidebarNav";
export type FlatNavItem = {
title: string;
href: string;
icon?: ReactNode;
sectionHeading: string;
};
function flattenItems(
items: SidebarNavItem[],
sectionHeading: string,
result: FlatNavItem[]
) {
for (const item of items) {
if (item.href) {
result.push({
title: item.title,
href: item.href,
icon: item.icon,
sectionHeading
});
}
if (item.items?.length) {
flattenItems(item.items, sectionHeading, result);
}
}
}
export function flattenNavSections(
sections: SidebarNavSection[]
): FlatNavItem[] {
const result: FlatNavItem[] = [];
for (const section of sections) {
flattenItems(section.items, section.heading, result);
}
return result;
}