Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile): improve note icon selector fit

Elian Doranc4d131dd23fb
diff --git a/apps/client/src/widgets/note_icon.css b/apps/client/src/widgets/note_icon.css
index 4ed6df6482..237f14076c 100644
--- a/apps/client/src/widgets/note_icon.css
+++ b/apps/client/src/widgets/note_icon.css
@@ -117,3 +117,17 @@ body.experimental-feature-new-layout {
}
}
}
+
+body.mobile .modal.icon-switcher {
+ .modal-body {
+ padding: 0;
+
+ > .filter-row {
+ padding: 0 var(--bs-modal-padding) var(--bs-modal-padding) var(--bs-modal-padding);
+ }
+ }
+
+ .icon-list {
+ margin: auto;
+ }
+}
diff --git a/apps/client/src/widgets/note_icon.tsx b/apps/client/src/widgets/note_icon.tsx
index 9c503c9fd5..019995a9f7 100644
--- a/apps/client/src/widgets/note_icon.tsx
+++ b/apps/client/src/widgets/note_icon.tsx
@@ -55,7 +55,7 @@ export default function NoteIcon() {
hideToggleArrow
disabled={viewScope?.viewMode !== "default"}
>
- { note && <NoteIconList note={note} onHide={() => dropdownRef?.current?.hide()} /> }
+ { note && <NoteIconList note={note} onHide={() => dropdownRef?.current?.hide()} columnCount={12} /> }
</Dropdown>
);
}
@@ -82,16 +82,17 @@ function MobileNoteIconSwitcher({ note, icon }: {
show={modalShown} onHidden={() => setModalShown(false)}
className="icon-switcher note-icon-widget"
>
- {note && <NoteIconList note={note} onHide={() => setModalShown(false)} />}
+ {note && <NoteIconList note={note} onHide={() => setModalShown(false)} columnCount={7} />}
</Modal>
), document.body)}
</div>
);
}
-function NoteIconList({ note, onHide }: {
+function NoteIconList({ note, onHide, columnCount }: {
note: FNote;
onHide: () => void;
+ columnCount: number;
}) {
const searchBoxRef = useRef<HTMLInputElement>(null);
const iconListRef = useRef<HTMLDivElement>(null);
@@ -156,6 +157,9 @@ function NoteIconList({ note, onHide }: {
<div
class="icon-list"
ref={iconListRef}
+ style={{
+ width: columnCount * 48,
+ }}
onClick={(e) => {
// Make sure we are not clicking on something else than a button.
const clickedTarget = e.target as HTMLElement;
@@ -171,9 +175,9 @@ function NoteIconList({ note, onHide }: {
>
{filteredIcons.length ? (
<Grid
- columnCount={12}
+ columnCount={columnCount}
columnWidth={48}
- rowCount={Math.ceil(filteredIcons.length / 12)}
+ rowCount={Math.ceil(filteredIcons.length / columnCount)}
rowHeight={48}
cellComponent={IconItemCell}
cellProps={{