Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(icon_picker): inset the icon grid from the popup's left edge
Elian Doran2d47ceb5cd58
diff --git a/apps/client/src/widgets/note_icon.css b/apps/client/src/widgets/note_icon.cssindex cb9ebe3dab..ce7244e69f 100644--- a/apps/client/src/widgets/note_icon.css+++ b/apps/client/src/widgets/note_icon.css@@ -113,6 +113,7 @@ body.mobile .modal.icon-switcher {.icon-list {--scroll-fade-top: 0px;+ --icon-list-inset: 0px;margin: auto;flex-grow: 1;height: 100%;diff --git a/apps/client/src/widgets/react/IconPicker.css b/apps/client/src/widgets/react/IconPicker.cssindex de2478b517..4b87e628b0 100644--- a/apps/client/src/widgets/react/IconPicker.css+++ b/apps/client/src/widgets/react/IconPicker.css@@ -22,6 +22,8 @@*/.icon-picker .icon-list {--scroll-fade-top: 20px;+ /* Added to the width set in IconPicker.tsx, so the inset cells do not overflow sideways. */+ --icon-list-inset: 6px;height: clamp(12rem, 100vh - 8rem, 500px);overflow: auto;}@@ -34,6 +36,8 @@font-size: 180%;/* Keeps the first row clear of the `.scroll-edge-fade` mask while the grid is at the top. */top: var(--scroll-fade-top);+ /* The cells carry an inline `left`, so a margin is what moves them off the edge. */+ margin-inline-start: var(--icon-list-inset);}.icon-picker .icon-list span:hover {diff --git a/apps/client/src/widgets/react/IconPicker.spec.tsx b/apps/client/src/widgets/react/IconPicker.spec.tsxindex 4ee9603eb9..8c3712887f 100644--- a/apps/client/src/widgets/react/IconPicker.spec.tsx+++ b/apps/client/src/widgets/react/IconPicker.spec.tsx@@ -93,13 +93,13 @@ describe("IconPicker", () => {expect(regularList).toBeTruthy();expect(compactList).toBeTruthy();- // Nine columns of the compact cell, and the ten the stylesheet asks for besides.- expect(compactList?.style.width).toBe("370px");+ // Nine columns of the compact cell, plus 10px and the inset the stylesheet sets.+ expect(compactList?.style.width).toBe("calc(370px + var(--icon-list-inset))");// Eight rows and a quarter, the quarter being what tells the reader there is more below.expect(compactList?.style.height).toBe("330px");// The regular grid keeps the height the stylesheet gives it, which follows the screen.- expect(regularList?.style.width).toBe("442px");+ expect(regularList?.style.width).toBe("calc(442px + var(--icon-list-inset))");expect(regularList?.style.height).toBe("");});});diff --git a/apps/client/src/widgets/react/IconPicker.tsx b/apps/client/src/widgets/react/IconPicker.tsxindex 24d73d9742..a862614926 100644--- a/apps/client/src/widgets/react/IconPicker.tsx+++ b/apps/client/src/widgets/react/IconPicker.tsx@@ -90,7 +90,7 @@ export default function IconPicker({ onSelect, onReset, resetText, columnCount,class="icon-list"ref={iconListRef}style={{- width: `${columnCount * iconSize + 10}px`,+ width: `calc(${columnCount * iconSize + 10}px + var(--icon-list-inset))`,// The CSS sets the height of the regular grid; the compact grid shows// `COMPACT_ROWS` rows....(compact && { height: `${COMPACT_ROWS * iconSize}px` })