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(mobile): switch the note panel's tabs with a bottom bar
Elian Doran4ae1c32158f5
diff --git a/apps/client/src/stylesheets/theme-next/ios.css b/apps/client/src/stylesheets/theme-next/ios.cssindex 0617fb1569..f83ec3f19c 100644--- a/apps/client/src/stylesheets/theme-next/ios.css+++ b/apps/client/src/stylesheets/theme-next/ios.css@@ -90,17 +90,6 @@ body.mobile.ios {.modal.mobile-note-panel {--modal-background-color: var(--grouped-background-color);-- /* The tab strip fills the header up to the close button instead of being centred as a title. */- .modal-header :is(.modal-title, .tn-master-detail-header) {- padding-inline-start: 0;- }-- &:not(.mobile-master-detail) .modal-header > .modal-title,- .modal-header .tn-master-detail-title > .modal-title {- display: flex;- }---note-panel-group-radius: var(--grouped-card-radius);--note-panel-group-spacing: 22px;--note-panel-group-background: var(--grouped-card-background-color);diff --git a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.cssindex 62d3fe3f07..43f87f5e6b 100644--- a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css+++ b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css@@ -2,19 +2,57 @@contain: none;}+body.mobile:has(.virtual-keyboard-opened) .modal.mobile-note-panel .modal-footer {+ display: none;+}+body.mobile .modal.mobile-note-panel {- &:not(.mobile-master-detail) .modal-header > .modal-title,- .tn-master-detail-title:has(> .modal-title) {- display: flex;- flex: 1;- min-width: 0;+ .modal-footer {+ padding: 4px 8px calc(max(var(--safe-area-inset-bottom, env(safe-area-inset-bottom)), 8px));+ border-top: 1px solid var(--main-border-color);}- .tn-master-detail-title > .modal-title {- display: flex;- color: var(--main-text-color);+ &.mobile-view-page .modal-footer {+ display: none;+ }++ .mobile-note-panel-tabs {flex: 1;- min-width: 0;++ div.btn-group {+ flex: 1;+ gap: 0;+ padding: 0;+ background: transparent;++ button.tab-strip-tab {+ flex: 1 1 0;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ gap: 2px;+ width: auto;+ height: 52px;+ padding-inline: 2px;+ color: var(--muted-text-color);++ &.active {+ color: var(--main-text-color);+ }+ }+ }++ .tab-strip-tab-icon {+ font-size: 1.45em;+ }++ .tab-strip-tab-label {+ max-width: 100%;+ overflow: hidden;+ text-overflow: ellipsis;+ font-size: 0.7rem;+ }}.modal-dialog {height: 85vh;@@ -44,14 +82,23 @@ body.mobile .modal.mobile-note-panel {display: flex;flex-direction: column;overflow-y: auto;- padding-bottom: calc(var(--note-panel-group-spacing, 16px) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));+ padding-bottom: var(--note-panel-group-spacing, 16px);&:has(#sidebar-chat) {padding-bottom: 0;}- &:not([data-tab-id="widgets"]) > .card:only-child > .card-header:has(> .card-header-buttons:empty) {- display: none;+ /* The header names the tab, so a lone section keeps only its buttons. The chat is wrapped in a+ `.lazy-component`. */+ &:not([data-tab-id="widgets"]) > .card:only-child > .card-header,+ &:not([data-tab-id="widgets"]) > :only-child > .card:only-child > .card-header {+ &:has(> .card-header-buttons:empty) {+ display: none;+ }++ > .card-header-title {+ visibility: hidden;+ }}.card > .card-header {@@ -110,7 +157,6 @@ body.mobile .modal.mobile-note-panel {border-width: 1px 0 0;border-radius: var(--note-panel-group-radius, 10px) var(--note-panel-group-radius, 10px) 0 0;outline-offset: -2px;- padding-bottom: calc(0.5rem + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));}> :is(#pdf-pages, #noteMap):not(.grow) .card-body {@@ -134,6 +180,10 @@ body.mobile .modal.mobile-note-panel {.tn-master-pane,.tn-detail-pane {padding-inline: 16px;+ padding-bottom: var(--note-panel-group-spacing, 16px);+ }++ .tn-detail-pane {padding-bottom: calc(var(--note-panel-group-spacing, 16px) + var(--safe-area-inset-bottom, env(safe-area-inset-bottom)));}}diff --git a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsxindex 9931c011ce..fc71e3a69c 100644--- a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx+++ b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx@@ -63,11 +63,12 @@ function MobileNotePanelModal({ shown, onHidden, widgetsByParent, selectedTabId,<MasterDetailModalclassName="mobile-note-panel"size="md"- // In `.modal-title`, which master_detail.css hides in favour of `MasterDetailHeader`.- title={(- <div className="modal-title">- <TabStrip labelled tabs={tabs} activeTabId={activeTab?.id} onSelect={setSelectedTabId} />- </div>+ title={activeTab?.title}+ footer={(+ <TabStrip+ className="mobile-note-panel-tabs" labelled withIcons+ tabs={tabs} activeTabId={activeTab?.id} onSelect={setSelectedTabId}+ />)}backTitle={t("attribute_list_panel.back")}ariaLabel={t("mobile_detail_menu.note_panel")}diff --git a/apps/client/src/widgets/react/TabStrip.tsx b/apps/client/src/widgets/react/TabStrip.tsxindex a0821faf95..5c6b6a6519 100644--- a/apps/client/src/widgets/react/TabStrip.tsx+++ b/apps/client/src/widgets/react/TabStrip.tsx@@ -20,6 +20,8 @@ interface TabStripProps<T extends string> {className?: string;/** Name each tab in text across the full width instead of an icon, for touch screens with no tooltips. */labelled?: boolean;+ /** With `labelled`, show the icon above the name, as a bottom tab bar does. */+ withIcons?: boolean;}/**@@ -30,10 +32,10 @@ interface TabStripProps<T extends string> {* track with the one on show raised out of it. The theme dresses the class; all the strip does is* size it to a header row, and leave the row itself to whoever it heads (see {@link className}).*/-export default function TabStrip<T extends string>({ tabs, activeTabId, onSelect, className, labelled }: TabStripProps<T>) {+export default function TabStrip<T extends string>({ tabs, activeTabId, onSelect, className, labelled, withIcons }: TabStripProps<T>) {return (// Centred in the row rather than run up against its start (see TabStrip.css).- <div class={clsx("tab-strip", labelled && "tab-strip-labelled", className)}>+ <div class={clsx("tab-strip", labelled && "tab-strip-labelled", labelled && withIcons && "tab-strip-with-icons", className)}><div class="btn-group tab-strip-group" role="tablist">{tabs.map((tab) => (<TabStripTab@@ -41,6 +43,7 @@ export default function TabStrip<T extends string>({ tabs, activeTabId, onSelecttab={tab}active={tab.id === activeTabId}labelled={labelled}+ withIcons={withIcons}onSelect={() => onSelect(tab.id)}/>))}@@ -49,7 +52,7 @@ export default function TabStrip<T extends string>({ tabs, activeTabId, onSelect);}-function TabStripTab<T extends string>({ tab, active, labelled, onSelect }: { tab: TabStripTabDefinition<T>; active: boolean; labelled?: boolean; onSelect: () => void }) {+function TabStripTab<T extends string>({ tab, active, labelled, withIcons, onSelect }: { tab: TabStripTabDefinition<T>; active: boolean; labelled?: boolean; withIcons?: boolean; onSelect: () => void }) {const buttonRef = useRef<HTMLButtonElement>(null);// Unless `labelled`, no tab is named in the strip, the selected one included: every tab is the// same icon-sized segment, which keeps a whole group inside a panel narrow enough to only fit the@@ -73,7 +76,8 @@ function TabStripTab<T extends string>({ tab, active, labelled, onSelect }: { taclass={clsx("tab-strip-tab icon-action", active && "active")}onClick={onSelect}>- {labelled ? tab.title : <span class={clsx("tab-strip-tab-icon tn-icon", tab.icon)} />}+ {(!labelled || withIcons) && <span class={clsx("tab-strip-tab-icon tn-icon", tab.icon)} />}+ {labelled && <span class="tab-strip-tab-label">{tab.title}</span>}</button>);}