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
feat(options): name the settings page beside the way back on mobile
Elian Doranf2a1ee8e65d1
diff --git a/apps/client/src/widgets/dialogs/OptionsDialog.tsx b/apps/client/src/widgets/dialogs/OptionsDialog.tsxindex 99f0a560de..0178d0d09b 100644--- a/apps/client/src/widgets/dialogs/OptionsDialog.tsx+++ b/apps/client/src/widgets/dialogs/OptionsDialog.tsx@@ -71,6 +71,7 @@ export default function OptionsDialog() {inPage={mobileView === "page"}onBack={() => switchMobileView("list")}backTitle={t("options.back")}+ pageTitle={<ActivePageTitle />}listTitle={t("options.title")}listIcon="bx bx-cog"/>@@ -116,6 +117,16 @@ export default function OptionsDialog() {);}+/**+ * Names the settings page on show, for the master-detail header to carry beside the way back. A+ * component of its own rather than something the dialog reads: the dialog is what provides the note+ * context the title comes from, so it cannot consume it itself.+ */+function ActivePageTitle() {+ const { note } = useNoteContext();+ return <>{note?.title}</>;+}+/*** The children of `_options` to list in the settings modal, filtered to those applicable to the* running platform (see {@link isOptionPageVisibleOnPlatform}). Shared by the desktop sidebardiff --git a/apps/client/src/widgets/react/master_detail.tsx b/apps/client/src/widgets/react/master_detail.tsxindex b33d9a591b..a016869e30 100644--- a/apps/client/src/widgets/react/master_detail.tsx+++ b/apps/client/src/widgets/react/master_detail.tsx@@ -137,8 +137,7 @@ export function MasterDetailHeader({ inPage, onBack, backTitle, pageTitle, listT// does not shift as the views change.listIcon && <span class={clsx("tn-master-detail-icon icon-action", listIcon)} aria-hidden="true" />)}- {/* A page that names itself (the settings pages do) passes no title, and gets no room- taken for one. */}+ {/* A page that names itself passes no title, and gets no room taken for one. */}{(inPage ? pageTitle : listTitle) && (<h5 class="tn-master-detail-title">{inPage ? pageTitle : listTitle}</h5>)}diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.cssindex c69c862a65..048e40ad7c 100644--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.css@@ -98,3 +98,31 @@ body.experimental-feature-new-layout .options-page-header {background: var(--main-background-color);margin-bottom: 1em;}++/* In the mobile master-detail flow the page is already named beside the way back, in the dialog's own+ header (see MasterDetailHeader) — the small title a phone has the width for. The banner drops its+ copy rather than saying it twice down the screen. */+.modal.mobile-master-detail {+ .options-page-header-icon,+ .options-page-header-title {+ display: none;+ }++ /* The name was all it carried, so it stands down rather than leaving an empty band above the+ first card. */+ .options-page-header-title-only:not(:has(.options-page-header-help)) {+ display: none;+ }++ /* All but the help button, which stays reachable — as a page action at the head of the content,+ though, rather than as a bar: the bar was there to hold the name. */+ .options-page-header-title-only {+ position: static;+ border-bottom: none;+ padding-block: 0;++ .options-page-header-main {+ justify-content: flex-end;+ }+ }+}diff --git a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsxindex bdef5baf0d..51c0e8f5cd 100644--- a/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx+++ b/apps/client/src/widgets/type_widgets/options/components/OptionsPageHeader.tsx@@ -1,9 +1,10 @@import "./OptionsPageHeader.css";+import clsx from "clsx";import { ComponentChildren } from "preact";-import { useNoteContext } from "../../../react/hooks";import HelpButton from "../../../react/HelpButton";+import { useNoteContext } from "../../../react/hooks";interface OptionsPageHeaderProps {/**@@ -40,7 +41,9 @@ export default function OptionsPageHeader({ actions, below, helpUrl }: OptionsPaif (!note && !actions && !below) return null;return (- <div className="options-page-header">+ // A header carrying nothing but the page's name is marked as such: on a phone the name is+ // shown beside the way back instead, leaving this with no band of its own to draw (see CSS).+ <div className={clsx("options-page-header", !actions && !below && "options-page-header-title-only")}><div className="options-page-header-inner">{(note || actions) && (<div className="options-page-header-main">@@ -48,7 +51,9 @@ export default function OptionsPageHeader({ actions, below, helpUrl }: OptionsPa<div className="options-page-header-titles"><span className={`options-page-header-icon ${note.getIcon()}`} aria-hidden="true" /><h2 className="options-page-header-title">{note.title}</h2>- {helpUrl && <HelpButton helpPage={helpUrl} />}+ {/* Classed so it can be told from the name it stands beside: on a+ phone the name moves into the dialog's header and this stays. */}+ {helpUrl && <HelpButton className="options-page-header-help" helpPage={helpUrl} />}</div>)}{actions && <div className="options-page-header-actions">{actions}</div>}