diff --git a/apps/client/src/widgets/Breadcrumb.css b/apps/client/src/widgets/Breadcrumb.css index 1993e57ca..12ee1c759 100644 --- a/apps/client/src/widgets/Breadcrumb.css +++ b/apps/client/src/widgets/Breadcrumb.css @@ -10,4 +10,11 @@ color: inherit; text-decoration: none; } + + ul { + flex-direction: column; + list-style-type: none; + margin: 0; + padding: 0; + } } diff --git a/apps/client/src/widgets/Breadcrumb.tsx b/apps/client/src/widgets/Breadcrumb.tsx index eacf79ed7..3adf46b0a 100644 --- a/apps/client/src/widgets/Breadcrumb.tsx +++ b/apps/client/src/widgets/Breadcrumb.tsx @@ -1,10 +1,11 @@ import { Fragment } from "preact/jsx-runtime"; import "./Breadcrumb.css"; -import ActionButton from "./react/ActionButton"; -import { useNoteContext } from "./react/hooks"; +import { useChildNotes, useNoteContext } from "./react/hooks"; import NoteLink from "./react/NoteLink"; import Dropdown from "./react/Dropdown"; import Icon from "./react/Icon"; +import { FormListItem } from "./react/FormList"; +import NoteContext from "../components/note_context"; export default function Breadcrumb() { const { noteContext } = useNoteContext(); @@ -15,7 +16,7 @@ export default function Breadcrumb() { {notePath.map(item => ( - + ))} @@ -31,7 +32,7 @@ function BreadcrumbItem({ notePath }: { notePath: string }) { ) } -function BreadcrumbSeparator({ notePath }: { notePath: string}) { +function BreadcrumbSeparator({ notePath, noteContext }: { notePath: string, noteContext: NoteContext | undefined }) { return ( } @@ -39,11 +40,31 @@ function BreadcrumbSeparator({ notePath }: { notePath: string}) { buttonClassName="icon-action" hideToggleArrow > - Content goes here. + ) } +function BreadcrumbSeparatorDropdownContent({ notePath, noteContext }: { notePath: string, noteContext: NoteContext | undefined }) { + const notePathComponents = notePath.split("/"); + const parentNoteId = notePathComponents.pop(); + const childNotes = useChildNotes(parentNoteId); + const notePathPrefix = notePathComponents.join("/"); // last item was removed already. + + return ( + + ) +} + function buildNotePaths(notePathArray: string[] | undefined) { if (!notePathArray) return []; diff --git a/apps/client/src/widgets/react/hooks.tsx b/apps/client/src/widgets/react/hooks.tsx index 24a7948dc..0c9883df2 100644 --- a/apps/client/src/widgets/react/hooks.tsx +++ b/apps/client/src/widgets/react/hooks.tsx @@ -886,12 +886,15 @@ async function isNoteReadOnly(note: FNote, noteContext: NoteContext) { return true; } -export function useChildNotes(parentNoteId: string) { +export function useChildNotes(parentNoteId: string | undefined) { const [ childNotes, setChildNotes ] = useState([]); useEffect(() => { (async function() { - const parentNote = await froca.getNote(parentNoteId); - const childNotes = await parentNote?.getChildNotes(); + let childNotes: FNote[] | undefined; + if (parentNoteId) { + const parentNote = await froca.getNote(parentNoteId); + childNotes = await parentNote?.getChildNotes(); + } setChildNotes(childNotes ?? []); })(); }, [ parentNoteId ]);