diff --git a/apps/client/src/widgets/Breadcrumb.css b/apps/client/src/widgets/Breadcrumb.css
index 810d54797..7a78982b2 100644
--- a/apps/client/src/widgets/Breadcrumb.css
+++ b/apps/client/src/widgets/Breadcrumb.css
@@ -50,5 +50,6 @@
white-space: nowrap;
overflow: hidden;
display: block;
+ max-width: 300px;
}
}
diff --git a/apps/client/src/widgets/Breadcrumb.tsx b/apps/client/src/widgets/Breadcrumb.tsx
index 1c4f6a4dc..940f62405 100644
--- a/apps/client/src/widgets/Breadcrumb.tsx
+++ b/apps/client/src/widgets/Breadcrumb.tsx
@@ -10,22 +10,47 @@ import ActionButton from "./react/ActionButton";
import { useMemo } from "preact/hooks";
import froca from "../services/froca";
+const COLLAPSE_THRESHOLD = 5;
+const INITIAL_ITEMS = 2;
+const FINAL_ITEMS = 2;
+
export default function Breadcrumb() {
const { note, noteContext } = useNoteContext();
const notePath = buildNotePaths(noteContext?.notePathArray);
return (
- {notePath.map((item, index) => (
+ {notePath.length > COLLAPSE_THRESHOLD ? (
+ <>
+ {notePath.slice(0, INITIAL_ITEMS).map((item, index) => (
{index === 0 && notePath.length > 1
- ?
- :
+ ?
+ :
}
- {(index < notePath.length - 1 || note?.hasChildren()) &&
- }
+
- ))}
+ ))}
+
+ {notePath.slice(-FINAL_ITEMS).map((item, index) => (
+
+
+
+
+ ))}
+ >
+ ) : (
+ notePath.map((item, index) => (
+
+ {index === 0 && notePath.length > 1
+ ?
+ :
+ }
+ {(index < notePath.length - 1 || note?.hasChildren()) &&
+ }
+
+ ))
+ )}
)
}
@@ -95,6 +120,36 @@ function BreadcrumbSeparatorDropdownContent({ notePath, noteContext, activeNoteP
)
}
+function BreadcrumbCollapsed({ items, noteContext }: { items: string[], noteContext: NoteContext | undefined }) {
+ return (
+ }
+ noSelectButtonStyle
+ buttonClassName="icon-action"
+ hideToggleArrow
+ dropdownOptions={{ popperConfig: { strategy: "fixed" } }}
+ >
+
+ {items.map((notePath) => {
+ const notePathComponents = notePath.split("/");
+ const noteId = notePathComponents[notePathComponents.length - 1];
+ const note = froca.getNoteFromCache(noteId);
+ if (!note) return null;
+
+ return -
+ noteContext?.setNote(notePath)}
+ >
+ {note.title}
+
+
+ })}
+
+
+ )
+}
+
function buildNotePaths(notePathArray: string[] | undefined) {
if (!notePathArray) return [];