mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 14:24:27 +01:00
feat(breadcrumb): prefer workspace icon class
This commit is contained in:
parent
e2fac8ab05
commit
6d4e52c928
@ -14,7 +14,7 @@ import ActionButton from "../react/ActionButton";
|
|||||||
import { Badge } from "../react/Badge";
|
import { Badge } from "../react/Badge";
|
||||||
import Dropdown from "../react/Dropdown";
|
import Dropdown from "../react/Dropdown";
|
||||||
import { FormListItem } from "../react/FormList";
|
import { FormListItem } from "../react/FormList";
|
||||||
import { useChildNotes, useNote, useNoteLabel, useNoteLabelBoolean, useNoteProperty } from "../react/hooks";
|
import { useChildNotes, useNote, useNoteIcon, useNoteLabel, useNoteLabelBoolean, useNoteProperty } from "../react/hooks";
|
||||||
import Icon from "../react/Icon";
|
import Icon from "../react/Icon";
|
||||||
import NoteLink from "../react/NoteLink";
|
import NoteLink from "../react/NoteLink";
|
||||||
|
|
||||||
@ -84,14 +84,16 @@ function BreadcrumbRoot({ noteContext }: { noteContext: NoteContext | undefined
|
|||||||
|
|
||||||
function BreadcrumbHoistedNoteRoot({ noteId }: { noteId: string }) {
|
function BreadcrumbHoistedNoteRoot({ noteId }: { noteId: string }) {
|
||||||
const note = useNote(noteId);
|
const note = useNote(noteId);
|
||||||
|
const noteIcon = useNoteIcon(note);
|
||||||
const [ workspace ] = useNoteLabelBoolean(note, "workspace");
|
const [ workspace ] = useNoteLabelBoolean(note, "workspace");
|
||||||
|
const [ workspaceIconClass ] = useNoteLabel(note, "workspaceIconClass");
|
||||||
|
|
||||||
// Hoisted workspace shows both text and icon and a way to exit easily out of the hoisting.
|
// Hoisted workspace shows both text and icon and a way to exit easily out of the hoisting.
|
||||||
return (note &&
|
return (note &&
|
||||||
<>
|
<>
|
||||||
<Badge
|
<Badge
|
||||||
className="badge-hoisted"
|
className="badge-hoisted"
|
||||||
icon={workspace ? "bx bx-folder-open" : "bx bxs-chevrons-up"}
|
icon={workspace ? (workspaceIconClass || noteIcon) : "bx bxs-chevrons-up"}
|
||||||
text={workspace ? t("breadcrumb.workspace_badge") : t("breadcrumb.hoisted_badge")}
|
text={workspace ? t("breadcrumb.workspace_badge") : t("breadcrumb.hoisted_badge")}
|
||||||
tooltip={t("breadcrumb.hoisted_badge_title")}
|
tooltip={t("breadcrumb.hoisted_badge_title")}
|
||||||
onClick={() => hoisted_note.unhoist()}
|
onClick={() => hoisted_note.unhoist()}
|
||||||
|
|||||||
@ -1039,3 +1039,13 @@ export function useNote(noteId: string | null | undefined, silentNotFoundError =
|
|||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useNoteIcon(note: FNote | null | undefined) {
|
||||||
|
const [ icon, setIcon ] = useState(note?.getIcon());
|
||||||
|
const iconClass = useNoteLabel(note, "iconClass");
|
||||||
|
useEffect(() => {
|
||||||
|
setIcon(note?.getIcon());
|
||||||
|
}, [ note, iconClass ]);
|
||||||
|
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user