Skip to content

Build your personal knowledge base with Trilium Notes

client/content manager/space usage: show the note icons on the treemap

Adorian Doran80f9432fad39
diff --git a/apps/client/src/widgets/react/charts/Treemap.css b/apps/client/src/widgets/react/charts/Treemap.css
index ac933c13b4..621d99b5e1 100644
--- a/apps/client/src/widgets/react/charts/Treemap.css
+++ b/apps/client/src/widgets/react/charts/Treemap.css
@@ -4,13 +4,25 @@
height: 100%;
overflow: hidden;
+ /* The icon's tint is composed in HSL from the cell's own hue, so it reads as belonging to the
+ cell rather than sitting on it. Kept as separate knobs a theme can retune — how saturated and
+ how light the tint is, and how much of it survives the mix into the theme's text color — so
+ the contrast can be adjusted without restating the derivation below. */
+ --treemap-icon-saturation: 70%;
+ --treemap-icon-lightness: 30%;
+ --treemap-icon-tint: 40%;
+
/* Painted through a variable, not a competing rule: consumers set `--treemap-cell-background`
and never race this stylesheet's cascade position. */
/* The corner rounding is per cell — a cell rounds only the corners its block owns — so it is
computed with the geometry rather than set here. */
.treemap-cell {
+ display: flex;
position: absolute;
+ align-items: center;
+ justify-content: center;
background: var(--treemap-cell-background, var(--accented-background-color));
+ overflow: hidden;
cursor: pointer;
}
@@ -24,6 +36,24 @@
);
}
+ /* Sized inline from the cell's geometry; the pointer belongs to the cell, so the glyph never
+ intercepts a hover, a click or a right-click meant for it. */
+ .treemap-cell-icon {
+ color: var(--treemap-cell-icon-color, var(--muted-text-color));
+ line-height: 1;
+ pointer-events: none;
+ }
+
+ /* Same hue as the cell it sits in, pushed away from it in saturation and lightness, then mixed
+ into the theme's text color so it stays legible under light and dark themes alike. */
+ .treemap-cell.treemap-colored > .treemap-cell-icon {
+ --treemap-cell-icon-color: color-mix(
+ in srgb,
+ hsl(var(--treemap-hue) var(--treemap-icon-saturation) var(--treemap-icon-lightness)) var(--treemap-icon-tint),
+ var(--main-text-color)
+ );
+ }
+
.treemap-cell:hover {
outline: 2px solid var(--main-text-color);
outline-offset: -1px;
diff --git a/apps/client/src/widgets/react/charts/Treemap.spec.tsx b/apps/client/src/widgets/react/charts/Treemap.spec.tsx
index 68af2cb8ca..f336a1b65f 100644
--- a/apps/client/src/widgets/react/charts/Treemap.spec.tsx
+++ b/apps/client/src/widgets/react/charts/Treemap.spec.tsx
@@ -43,10 +43,11 @@ const ROOT: TreemapItem<string> = {
id: "big",
value: 300,
hue: 120,
+ icon: "tn-icon bx bx-file",
data: "big",
attributes: { "data-href": "#root/folder/big" }
},
- { id: "small", value: 100, data: "small", attributes: { id: "cell-small" } }
+ { id: "small", value: 100, icon: "tn-icon bx bx-note", data: "small", attributes: { id: "cell-small" } }
]
},
{ id: "bucket", value: 100, className: "bucket-cell", tooltip: "A crowd of notes" },
@@ -167,6 +168,34 @@ describe("Treemap", () => {
}
});
+ it("fits each cell's icon to its shorter side, capped, and drops it when illegibly small", () => {
+ const probe = renderTreemap(ROOT);
+ const iconIn = (selector: string) =>
+ probe.querySelector<HTMLElement>(`${selector} > .treemap-cell-icon`);
+
+ // A cell with room gets the icon it was given, at the capped size.
+ const big = iconIn('[data-href="#root/folder/big"]');
+ expect(big?.classList.contains("bx-file")).toBe(true);
+ expect(parseFloat(big?.style.fontSize ?? "")).toBe(24);
+
+ // 80% of the shorter side — a tenth left clear on either edge — until the cap takes over.
+ const small = probe.querySelector<HTMLElement>("#cell-small");
+ const shorterSide = Math.min(parseFloat(small?.style.width ?? ""), parseFloat(small?.style.height ?? ""));
+ expect(parseFloat(iconIn("#cell-small")?.style.fontSize ?? ""))
+ .toBeCloseTo(Math.min(shorterSide * 0.8, 24), 5);
+
+ // A cell that was given no icon shows none.
+ expect(iconIn(".bucket-cell")).toBeNull();
+
+ // Squeeze the map until the icons no longer read, and they go rather than turn into smudges
+ // — the cells themselves stay, so this is the icons dropping out and not an empty map.
+ render(null, container as HTMLDivElement);
+ mocks.size = { width: 20, height: 20 };
+ const squeezed = renderTreemap(ROOT);
+ expect(squeezed.querySelectorAll(".treemap-cell").length).toBeGreaterThan(0);
+ expect(squeezed.querySelectorAll(".treemap-cell-icon").length).toBe(0);
+ });
+
it("gives bigger values proportionally bigger areas", () => {
const probe = renderTreemap(ROOT);
const areaOf = (selector: string) => {
diff --git a/apps/client/src/widgets/react/charts/Treemap.tsx b/apps/client/src/widgets/react/charts/Treemap.tsx
index 0ac354e575..2a0892616a 100644
--- a/apps/client/src/widgets/react/charts/Treemap.tsx
+++ b/apps/client/src/widgets/react/charts/Treemap.tsx
@@ -20,6 +20,11 @@ export interface TreemapItem<T = unknown> {
hue?: number;
/** Extra classes on the cell, for special entries the consumer styles itself. */
className?: string;
+ /**
+ * Icon classes drawn centered in the cell, sized to it — what the cell holds, at a glance.
+ * Dropped on cells too small to render it legibly.
+ */
+ icon?: string;
/** Text for the chart's own tooltip, for cells that identify themselves rather than a note. */
tooltip?: string;
/**
@@ -53,6 +58,15 @@ const MAP_INSET = 2;
/** Layout coordinates are floats; edges meant to coincide can differ in the last bit. */
const EDGE_EPSILON = 0.5;
+/** Share of the cell's shorter side left clear around the icon, on each edge. */
+const ICON_MARGIN = 0.1;
+
+/** Past this the glyph stops reading as an icon and starts dominating its cell. */
+const MAX_ICON_SIZE = 24;
+
+/** Below this it is a smudge rather than a symbol, so the cell is better left as plain color. */
+const MIN_ICON_SIZE = 10;
+
/**
* A treemap over an arbitrary {@link TreemapItem} hierarchy, sized to fill its container and
* re-laid out whenever the container resizes.
@@ -110,6 +124,8 @@ export default function Treemap<T>({ root, onItemClick, onItemContextMenu, class
return null;
}
+ const iconSize = fittedIconSize(cellWidth, cellHeight);
+
return (
<div
key={item.id}
@@ -128,7 +144,11 @@ export default function Treemap<T>({ root, onItemClick, onItemContextMenu, class
onMouseEnter={(event) => showTooltip(item.tooltip, event)}
onMouseLeave={hideTooltip}
{...item.attributes}
- />
+ >
+ {item.icon && iconSize >= MIN_ICON_SIZE && (
+ <span className={clsx("treemap-cell-icon", item.icon)} style={{ fontSize: iconSize }} />
+ )}
+ </div>
);
})}
{tooltipNode}
@@ -136,6 +156,15 @@ export default function Treemap<T>({ root, onItemClick, onItemContextMenu, class
);
}
+/**
+ * The icon size a cell affords: it fits the shorter side with {@link ICON_MARGIN} clear on either
+ * edge, and stops growing at {@link MAX_ICON_SIZE} — past that a large cell would read as a huge
+ * glyph rather than as an area.
+ */
+function fittedIconSize(cellWidth: number, cellHeight: number) {
+ return Math.min(Math.min(cellWidth, cellHeight) * (1 - 2 * ICON_MARGIN), MAX_ICON_SIZE);
+}
+
/**
* The rounding a cell needs so its block is a rounded card: a cell rounds a corner only where that
* corner is the block's own, leaving the cuts inside a block square. A cell that is a block by
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.spec.ts b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.spec.ts
index cb37fb76c7..edd09d68d3 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.spec.ts
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.spec.ts
@@ -1,7 +1,11 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import type FNote from "../../../../../entities/fnote";
-import type { ContextMenuEvent, MenuCommandItem, MenuItem } from "../../../../../menus/context_menu";
+import type {
+ ContextMenuEvent,
+ MenuCommandItem,
+ MenuItem
+} from "../../../../../menus/context_menu";
const mocks = vi.hoisted(() => ({
shown: undefined as { items: MenuItem<never>[] } | undefined,
@@ -60,7 +64,9 @@ const EXPORT = "bx bx-export";
const DELETE = "bx bx-trash destructive-action-icon";
function givenNote(noteId: string, type = "text", isContentAvailable = true) {
- mocks.notes.set(noteId, { noteId, type, isContentAvailable: () => isContentAvailable } as FNote);
+ mocks.notes.set(noteId, {
+ noteId, type, isContentAvailable: () => isContentAvailable
+ } as FNote);
}
function contextMenuEvent() {
@@ -79,7 +85,8 @@ function itemByIcon(icon: string) {
}
function icons() {
- return mocks.shown?.items.flatMap((item) => "uiIcon" in item && item.uiIcon ? [ item.uiIcon ] : []);
+ return mocks.shown?.items.flatMap((item) =>
+ "uiIcon" in item && item.uiIcon ? [ item.uiIcon ] : []);
}
/** Every item carries a nullary handler; the menu dispatches no commands by name. */
@@ -87,6 +94,10 @@ function invoke(icon: string) {
(itemByIcon(icon) as { handler?: () => void } | undefined)?.handler?.();
}
+function openFor(notePath: string[]) {
+ return openSpaceUsageContextMenu(contextMenuEvent(), notePath, mocks.showDetails);
+}
+
afterEach(() => {
mocks.shown = undefined;
mocks.notes.clear();
@@ -109,10 +120,12 @@ describe("openSpaceUsageContextMenu", () => {
expect(icons()).toEqual([ QUICK_EDIT, NEW_TAB, SHOW_DETAILS, EXPORT, DELETE ]);
invoke(QUICK_EDIT);
- expect(mocks.triggerCommand).toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "root/p/n1" });
+ expect(mocks.triggerCommand)
+ .toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "root/p/n1" });
invoke(NEW_TAB);
- expect(mocks.openContextWithNote).toHaveBeenCalledWith("n1", { activate: true, hoistedNoteId: null });
+ expect(mocks.openContextWithNote)
+ .toHaveBeenCalledWith("n1", { activate: true, hoistedNoteId: null });
invoke(SHOW_DETAILS);
expect(mocks.showDetails).toHaveBeenCalledWith([ "root", "p", "n1" ]);
@@ -129,10 +142,10 @@ describe("openSpaceUsageContextMenu", () => {
expect(mocks.deleteNotes).toHaveBeenCalledWith([ "b1" ], false, false);
});
- it("adds Download for the note types that hold a file, disabled when the content is unavailable", async () => {
+ it("adds Download for file-bearing types, disabled when the content is away", async () => {
givenNote("f1", "file");
mocks.branchIds.set("p/f1", "b1");
- await openSpaceUsageContextMenu(contextMenuEvent(), [ "root", "p", "f1" ], mocks.showDetails);
+ await openFor([ "root", "p", "f1" ]);
expect(itemByIcon(DOWNLOAD)?.enabled).toBe(true);
invoke(DOWNLOAD);
@@ -140,14 +153,14 @@ describe("openSpaceUsageContextMenu", () => {
// A protected image whose content is locked away: offered, but not actionable.
givenNote("i1", "image", false);
- await openSpaceUsageContextMenu(contextMenuEvent(), [ "root", "p", "i1" ], mocks.showDetails);
+ await openFor([ "root", "p", "i1" ]);
expect(itemByIcon(DOWNLOAD)?.enabled).toBe(false);
});
- it("disables Export and Delete on the root, which has no parent to place it under", async () => {
+ it("disables Export and Delete on the root, which has no parent to place it", async () => {
givenNote("root");
- await openSpaceUsageContextMenu(contextMenuEvent(), [ "root" ], mocks.showDetails);
+ await openFor([ "root" ]);
expect(itemByIcon(EXPORT)?.enabled).toBe(false);
expect(itemByIcon(DELETE)?.enabled).toBe(false);
@@ -158,7 +171,7 @@ describe("openSpaceUsageContextMenu", () => {
});
it("shows no menu at all for a note deleted since the usage was measured", async () => {
- await openSpaceUsageContextMenu(contextMenuEvent(), [ "root", "gone" ], mocks.showDetails);
+ await openFor([ "root", "gone" ]);
expect(mocks.shown).toBeUndefined();
});
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.ts b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.ts
index eccfa4dd0b..1a007b3054 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.ts
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/context_menu.ts
@@ -1,6 +1,9 @@
import appContext from "../../../../../components/app_context";
import type FNote from "../../../../../entities/fnote";
-import contextMenu, { type ContextMenuEvent, type MenuItem } from "../../../../../menus/context_menu";
+import contextMenu, {
+ type ContextMenuEvent,
+ type MenuItem
+} from "../../../../../menus/context_menu";
import branches from "../../../../../services/branches";
import froca from "../../../../../services/froca";
import { t } from "../../../../../services/i18n";
@@ -16,8 +19,8 @@ export type ShowDetailsHandler = (notePath: string[]) => void;
*
* `notePath` runs from the root (inclusive) down to the note: the charts already carry it for their
* links, and it is what identifies the placement to act on — a clone occupies space once, at the
- * canonical placement the usage figures were attributed to, so that is the branch Delete removes and
- * the path Export resolves.
+ * canonical placement the usage figures were attributed to, so that is the branch Delete removes
+ * and the path Export resolves.
*/
export async function openSpaceUsageContextMenu(
event: ContextMenuEvent,
@@ -29,7 +32,8 @@ export async function openSpaceUsageContextMenu(
const noteId = notePath[notePath.length - 1];
const parentNoteId = notePath[notePath.length - 2];
- // Silent: the usage snapshot predates the menu, so the note may already be gone — no menu, no error.
+ // Silent: the usage snapshot predates the menu, so the note may already be gone — no menu,
+ // no error.
const note = noteId ? await froca.getNote(noteId, true) : null;
if (!note) {
@@ -120,7 +124,7 @@ export function openNoteInNewTab(noteId: string) {
});
}
-/** The note types whose content is a saveable file — the same ones the ribbon offers Download for. */
+/** Note types whose content is a saveable file — the same ones the ribbon offers Download for. */
function isDownloadable(note: FNote) {
return note.type === "file" || note.type === "image";
}
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.spec.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.spec.tsx
index 32240b06bf..5dc0284d0a 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.spec.tsx
@@ -26,6 +26,13 @@ vi.mock("../../../../react/hooks", () => ({
useElementSize: () => ({ width: 400, height: 300 })
}));
+vi.mock("../../../../../services/froca", () => ({
+ default: {
+ getNotes: async (noteIds: string[]) =>
+ noteIds.map((noteId) => ({ noteId, getIcon: () => `tn-icon bx bx-${noteId}` }))
+ }
+}));
+
import Overview from "./overview";
const OVERVIEW: SpaceUsageOverviewResponse = {
@@ -66,6 +73,19 @@ describe("Overview", () => {
expect(probe.querySelector(".treemap-cell-deleted")).not.toBeNull();
});
+ it("dresses note cells in their froca icons and the buckets in what they stand for", async () => {
+ const probe = renderOverview();
+ const iconIn = (selector: string) =>
+ probe.querySelector(`${selector} > .treemap-cell-icon`)?.className;
+
+ // The map draws first and picks the note icons up on the next render.
+ await vi.waitFor(() => expect(iconIn('[data-href="#root/n1"]')).toContain("bx-n1"));
+
+ expect(iconIn(".treemap-cell-other")).toContain("bx-dots-horizontal-rounded");
+ expect(iconIn(".treemap-cell-hidden")).toContain("bx-hide");
+ expect(iconIn(".treemap-cell-deleted")).toContain("bx-trash-alt");
+ });
+
it("quick-edits a clicked note and offers the menu on right-click, while the bucket cells stay inert", () => {
const probe = renderOverview();
const cell = probe.querySelector('[data-href="#root/n1"]');
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsx
index d3cc4e2c95..8aab3c0f70 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview.tsx
@@ -1,6 +1,7 @@
import type { SpaceUsageOverviewResponse } from "@triliumnext/commons";
-import { useMemo } from "preact/hooks";
+import { useEffect, useMemo, useState } from "preact/hooks";
+import froca from "../../../../../services/froca";
import { t } from "../../../../../services/i18n";
import { formatSize } from "../../../../../services/utils";
import Treemap, { type TreemapItem } from "../../../../react/charts/Treemap";
@@ -23,6 +24,8 @@ interface OverviewProps {
/** The treemap over the whole database: every large note at its tree location. */
export default function Overview({ overview, onShowDetails }: OverviewProps) {
+ const icons = useNoteIcons(overview);
+
// The labels are formatted here rather than in the model, which stays free of i18n: a bucket
// stands for a crowd, so its tooltip names how many notes it holds and how much they take.
const model = useMemo(() => buildOverviewModel(overview, {
@@ -39,8 +42,9 @@ export default function Overview({ overview, onShowDetails }: OverviewProps) {
overview.deletedNotes.size
),
includeRevisions: INCLUDE_REVISIONS,
+ getIcon: (noteId) => icons.get(noteId),
makeSizeDetail: (size) => t("space_usage.cell_size", { size: formatSize(size) })
- }), [ overview ]);
+ }), [ overview, icons ]);
return (
<div className="space-usage-overview">
@@ -54,6 +58,32 @@ export default function Overview({ overview, onShowDetails }: OverviewProps) {
);
}
+/**
+ * Batch-loads the icons the cells wear — one froca call for the whole ranking, not one per cell.
+ * The map draws immediately and picks the icons up on the next render: an icon is an extra reading
+ * of a cell, never something the layout should wait for.
+ */
+function useNoteIcons(overview: SpaceUsageOverviewResponse) {
+ const [ icons, setIcons ] = useState(new Map<string, string>());
+
+ useEffect(() => {
+ let cancelled = false;
+
+ // Silent: a note deleted since the usage was computed must not fail the whole view.
+ void froca.getNotes(overview.notes.map((note) => note.noteId), true).then((notes) => {
+ if (!cancelled) {
+ setIcons(new Map(notes.map((note) => [ note.noteId, note.getIcon() ])));
+ }
+ });
+
+ return () => {
+ cancelled = true;
+ };
+ }, [ overview ]);
+
+ return icons;
+}
+
/**
* "Other 1928 notes (512 MiB)" — the same "name (size)" wording the donut segments use, so a
* bucket reads alike wherever it appears. Composed here rather than baked into the count keys,
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.ts b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.ts
index 85eb6f0aff..5910a8be36 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.ts
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.spec.ts
@@ -87,6 +87,24 @@ describe("buildOverviewModel", () => {
expect(childById(model, "top").hue).toBe(hueOf("root"));
});
+ it("dresses both a plain cell and a self-cell in the note's icon, leaving unknown notes plain", () => {
+ const model = buildOverviewModel(
+ response([ entry("parent", [ "parent" ], { ownSize: 50 }), entry("child", [ "parent", "child" ], { ownSize: 10 }) ]),
+ {
+ otherNotesLabel: "Other notes",
+ hiddenNotesLabel: "Hidden notes",
+ deletedNotesLabel: "Deleted notes",
+ includeRevisions: false,
+ getIcon: (noteId) => noteId === "parent" ? "tn-icon bx bx-folder" : undefined
+ }
+ );
+
+ const parent = childById(model, "parent");
+ expect(childById(parent, "parent/own").icon).toBe("tn-icon bx bx-folder");
+ // Not yet loaded (or already gone): the cell simply keeps its color and nothing else.
+ expect(childById(parent, "child").icon).toBeUndefined();
+ });
+
it("gives an entry that is also an ancestor a nested self-cell wearing its children's hue", () => {
const model = build(response([
entry("parent", [ "parent" ], { ownSize: 50 }),
@@ -139,17 +157,21 @@ describe("buildOverviewModel", () => {
expect(other.tooltip).toBe("Other notes");
// No `data-href`: a crowd of notes has no note preview to show.
expect(other.attributes).toBeUndefined();
+ // A bucket names no note, so it wears what it stands for.
+ expect(other.icon).toBe("bx bx-dots-horizontal-rounded");
// Hidden space gets a cell too — every byte the status line counts is on the map.
const hidden = childById(model, "/hidden-notes");
expect(hidden.value).toBe(7);
expect(hidden.className).toBe("treemap-cell-hidden");
expect(hidden.tooltip).toBe("Hidden notes");
+ expect(hidden.icon).toBe("bx bx-hide");
const deleted = childById(model, "/deleted-notes");
expect(deleted.value).toBe(22);
expect(deleted.className).toBe("treemap-cell-deleted");
expect(deleted.tooltip).toBe("Deleted notes");
+ expect(deleted.icon).toBe("bx bx-trash-alt");
});
it("places an entry for the root itself as a top-level cell", () => {
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.ts b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.ts
index 775095b907..e7b916a53e 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.ts
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/overview_model.ts
@@ -17,6 +17,11 @@ interface OverviewModelOptions {
deletedNotesLabel: string;
/** Folds revision sizes into each cell's weight. */
includeRevisions: boolean;
+ /**
+ * The note's icon classes, for the cell to wear. Resolved by the caller, which has froca; a note
+ * not loaded (or already gone) simply yields none and its cell stays plain.
+ */
+ getIcon?: (noteId: string) => string | undefined;
/**
* Wording for the size a note cell contributes to its hover tooltip, given the weight its area
* encodes. Omit to leave the cells silent about their size.
@@ -37,7 +42,7 @@ interface OverviewModelOptions {
*/
export function buildOverviewModel(
overview: SpaceUsageOverviewResponse,
- { otherNotesLabel, hiddenNotesLabel, deletedNotesLabel, includeRevisions, makeSizeDetail }: OverviewModelOptions
+ { otherNotesLabel, hiddenNotesLabel, deletedNotesLabel, includeRevisions, getIcon, makeSizeDetail }: OverviewModelOptions
): TreemapItem<OverviewCell> {
const root: TreemapItem<OverviewCell> = { id: "root", children: [] };
const nodesByNoteId = new Map<string, TreemapItem<OverviewCell>>();
@@ -87,28 +92,34 @@ export function buildOverviewModel(
...(makeSizeDetail ? { "data-tooltip-detail": makeSizeDetail(weight) } : {})
};
+ const icon = getIcon?.(entry.noteId);
+
if (node.children?.length) {
node.children.push({
id: `${entry.noteId}/own`,
value: weight,
// The self-cell sits among the note's own children, so it wears their group hue.
hue: hueOf(entry.noteId),
+ icon,
data: cell,
attributes
});
} else {
node.value = weight;
node.hue = hueOf(path.at(-2) ?? ROOT_NOTE_ID);
+ node.icon = icon;
node.data = cell;
node.attributes = attributes;
}
}
+ // The buckets name no note, so they wear what they stand for rather than a note's own icon.
root.children?.push(
{
id: "/other-notes",
value: bucketWeight(overview.otherNotes, includeRevisions),
className: "treemap-cell-other",
+ icon: "bx bx-dots-horizontal-rounded",
tooltip: otherNotesLabel,
data: {}
},
@@ -116,6 +127,7 @@ export function buildOverviewModel(
id: "/hidden-notes",
value: bucketWeight(overview.hiddenNotes, includeRevisions),
className: "treemap-cell-hidden",
+ icon: "bx bx-hide",
tooltip: hiddenNotesLabel,
data: {}
},
@@ -123,6 +135,7 @@ export function buildOverviewModel(
id: "/deleted-notes",
value: overview.deletedNotes.size,
className: "treemap-cell-deleted",
+ icon: "bx bx-trash-alt",
tooltip: deletedNotesLabel,
data: {}
}