Skip to content

Build your personal knowledge base with Trilium Notes

feat(options/mobile): improve layout and design

Elian Doran61f6d013853a
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.css b/apps/client/src/widgets/dialogs/OptionsDialog.css
index a228c56d38..ac2093c3eb 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.css
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.css
@@ -58,9 +58,6 @@ body.mobile .modal.options-dialog .modal-dialog .modal-content .modal-body {
body.mobile .modal.options-dialog .options-mobile-nav {
height: 100%;
overflow: auto;
-}
-
-body.mobile .modal.options-dialog .options-mobile-nav .settings-navigation {
padding: 8px 25px;
}
@@ -80,8 +77,12 @@ body.mobile .modal.options-dialog.mobile-view-page:not(.mobile-transition-to-pag
}
/* The back button + page title in the custom header replace the static "Options" title. */
-body.mobile .modal.options-dialog .modal-header > .modal-title {
- display: none;
+body.mobile .modal.options-dialog .modal-header {
+ border-bottom: 1px solid var(--main-border-color);
+
+ > .modal-title {
+ display: none;
+ }
}
/* Directional slide mirroring the setup wizard's page animation: opening a page, the list slides
@@ -172,6 +173,17 @@ body[dir=rtl].mobile .modal.options-dialog.mobile-transition-to-list {
min-width: 0;
}
+/* Decorative settings icon shown in the list view. It borrows the `icon-action` class so it keeps
+ exactly the back button's footprint (the title doesn't shift between views), with the
+ interactive affordances neutralized. */
+.options-mobile-page-header .options-header-icon {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ pointer-events: none;
+ cursor: default;
+}
+
.options-mobile-page-header .options-mobile-page-title {
margin: 0;
overflow: hidden;
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.tsx b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
index f2fdda749a..338d5dc648 100644
--- a/apps/client/src/widgets/dialogs/OptionsDialog.tsx
+++ b/apps/client/src/widgets/dialogs/OptionsDialog.tsx
@@ -8,7 +8,8 @@ import { t } from "../../services/i18n";
import utils from "../../services/utils";
import NoteDetail from "../NoteDetail";
import ActionButton from "../react/ActionButton";
-import { useContainedLinkNavigation, useNoteContext, useTriliumEvent } from "../react/hooks";
+import FormList, { FormListItem } from "../react/FormList";
+import { useChildNotes, useContainedLinkNavigation, useNoteContext, useTriliumEvent } from "../react/hooks";
import Modal from "../react/Modal";
import { NoteContextContext, ParentComponent } from "../react/react_utils";
import SettingsNavigation from "../type_widgets/options/components/SettingsNavigation";
@@ -128,7 +129,14 @@ export default function OptionsDialog() {
setShown(false);
}}
>
- {isMobile && <div className="options-mobile-nav"><SettingsSidebar /></div>}
+ {isMobile && (
+ <div className="options-mobile-nav">
+ <MobileSettingsList onSelect={(noteId) => {
+ void noteContext.setNote(noteId, { keepActiveDialog: true });
+ switchMobileView("page");
+ }} />
+ </div>
+ )}
<NoteDetail />
</Modal>
</NoteContextContext.Provider>
@@ -148,20 +156,48 @@ function SettingsSidebar() {
}
/**
- * Replaces the "Options" title in the mobile page view: a back button returning to the master list
- * of pages, followed by the title of the page in view (the static title is hidden via CSS).
+ * The settings page list shown as the master view of the mobile master-detail flow, using the
+ * standard list component rather than the desktop sidebar's compact selector.
+ */
+function MobileSettingsList({ onSelect }: { onSelect: (noteId: string) => void }) {
+ const pages = useChildNotes("_options");
+ const { noteId: activeNoteId } = useNoteContext();
+ return (
+ <FormList onSelect={onSelect}>
+ {pages.map((page) => (
+ <FormListItem
+ key={page.noteId}
+ icon={page.getIcon()}
+ value={page.noteId}
+ active={page.noteId === activeNoteId}
+ >
+ {page.title}
+ </FormListItem>
+ ))}
+ </FormList>
+ );
+}
+
+/**
+ * Replaces the static "Options" title on mobile. In the page view it shows a back button returning
+ * to the master list followed by the title of the page in view; in the list view a decorative
+ * settings icon takes the button's place (keeping the same footprint so the title doesn't shift
+ * between views) followed by the dialog title.
*/
function MobilePageHeader({ onBack }: { onBack?: () => void }) {
const { note } = useNoteContext();
return (
<div className="options-mobile-page-header">
- <ActionButton
- icon="bx bx-chevron-left"
- text={t("options.back")}
- onClick={onBack}
- style={{ visibility: onBack ? "visible" : "hidden" }}
- />
- <h5 className="options-mobile-page-title">{note?.title}</h5>
+ {onBack ? (
+ <ActionButton
+ icon="bx bx-chevron-left"
+ text={t("options.back")}
+ onClick={onBack}
+ />
+ ) : (
+ <span className="options-header-icon icon-action bx bx-cog" aria-hidden="true" />
+ )}
+ <h5 className="options-mobile-page-title">{onBack ? note?.title : t("options.title")}</h5>
</div>
);
}