Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile): name the note panel's tabs in text

Elian Doran8f9efedfc366
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css
index d4b039b4b0..aa0d32acea 100644
--- a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css
+++ b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.css
@@ -13,10 +13,6 @@ body.mobile .modal.mobile-note-panel {
padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom));
}
- .modal-header .tab-strip {
- flex: 1;
- }
-
.modal-body {
flex: 1 1 auto;
min-height: 0;
diff --git a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx
index e26b29d8c5..6489061d85 100644
--- a/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx
+++ b/apps/client/src/widgets/mobile_widgets/MobileNotePanel.tsx
@@ -8,8 +8,9 @@ import { t } from "../../services/i18n";
import ActionButton from "../react/ActionButton";
import { useNoteContext } from "../react/hooks";
import Modal from "../react/Modal";
+import TabStrip from "../react/TabStrip";
import { RightPaneTabBodies, useRightPaneTabs } from "../sidebar/RightPanelContainer";
-import RightPaneTabs, { RightPaneTabId } from "../sidebar/RightPaneTabs";
+import { RightPaneTabId } from "../sidebar/RightPaneTabs";
/** The mobile layout loads no script widgets for the right pane. */
const NO_CUSTOM_WIDGETS = new WidgetsByParent();
@@ -43,7 +44,7 @@ function MobileNotePanelModal({ shown, onHidden }: { shown: boolean; onHidden: (
<Modal
className="mobile-note-panel"
size="md"
- title={<RightPaneTabs tabs={tabs} activeTabId={activeTab?.id} onSelect={setSelectedTabId} />}
+ title={<TabStrip labelled tabs={tabs} activeTabId={activeTab?.id} onSelect={setSelectedTabId} />}
ariaLabel={t("mobile_detail_menu.note_panel")}
show={shown}
onHidden={onHidden}
diff --git a/apps/client/src/widgets/react/TabStrip.css b/apps/client/src/widgets/react/TabStrip.css
index de565e6efa..63e8643280 100644
--- a/apps/client/src/widgets/react/TabStrip.css
+++ b/apps/client/src/widgets/react/TabStrip.css
@@ -56,3 +56,21 @@
line-height: 1;
}
}
+
+.tab-strip.tab-strip-labelled {
+ flex: 1;
+ justify-content: stretch;
+
+ div.btn-group {
+ flex: 1;
+
+ button.tab-strip-tab {
+ flex: 1 1 0;
+ width: auto;
+ height: 36px;
+ padding-inline: 8px;
+ font-size: 0.9rem;
+ white-space: nowrap;
+ }
+ }
+}
diff --git a/apps/client/src/widgets/react/TabStrip.tsx b/apps/client/src/widgets/react/TabStrip.tsx
index 7658a94691..a0821faf95 100644
--- a/apps/client/src/widgets/react/TabStrip.tsx
+++ b/apps/client/src/widgets/react/TabStrip.tsx
@@ -18,6 +18,8 @@ interface TabStripProps<T extends string> {
onSelect: (tabId: T) => void;
/** The host's own class, for the geometry of the row the strip heads. */
className?: string;
+ /** Name each tab in text across the full width instead of an icon, for touch screens with no tooltips. */
+ labelled?: boolean;
}
/**
@@ -28,16 +30,17 @@ 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 }: TabStripProps<T>) {
+export default function TabStrip<T extends string>({ tabs, activeTabId, onSelect, className, labelled }: TabStripProps<T>) {
return (
// Centred in the row rather than run up against its start (see TabStrip.css).
- <div class={clsx("tab-strip", className)}>
+ <div class={clsx("tab-strip", labelled && "tab-strip-labelled", className)}>
<div class="btn-group tab-strip-group" role="tablist">
{tabs.map((tab) => (
<TabStripTab
key={tab.id}
tab={tab}
active={tab.id === activeTabId}
+ labelled={labelled}
onSelect={() => onSelect(tab.id)}
/>
))}
@@ -46,12 +49,12 @@ export default function TabStrip<T extends string>({ tabs, activeTabId, onSelect
);
}
-function TabStripTab<T extends string>({ tab, active, onSelect }: { tab: TabStripTabDefinition<T>; active: boolean; onSelect: () => void }) {
+function TabStripTab<T extends string>({ tab, active, labelled, onSelect }: { tab: TabStripTabDefinition<T>; active: boolean; labelled?: boolean; onSelect: () => void }) {
const buttonRef = useRef<HTMLButtonElement>(null);
- // No tab is named in the strip, the selected one included: every tab is the same icon-sized
- // segment, which is what keeps a whole group inside a panel narrow enough to only fit the icons.
- // The name is the tooltip, and it is the only place it appears.
- useStaticTooltip(buttonRef, {
+ // 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
+ // icons. The name is the tooltip, and it is the only place it appears.
+ useStaticTooltip(buttonRef, labelled ? undefined : {
title: tab.title,
placement: "bottom",
fallbackPlacements: [ "bottom" ],
@@ -64,13 +67,13 @@ function TabStripTab<T extends string>({ tab, active, onSelect }: { tab: TabStri
type="button"
role="tab"
aria-selected={active}
- aria-label={tab.title}
+ aria-label={labelled ? undefined : tab.title}
// `icon-action` is what the button group sizes and fills its segments by; `active` is what
// it raises the one on show with.
class={clsx("tab-strip-tab icon-action", active && "active")}
onClick={onSelect}
>
- <span class={clsx("tab-strip-tab-icon tn-icon", tab.icon)} />
+ {labelled ? tab.title : <span class={clsx("tab-strip-tab-icon tn-icon", tab.icon)} />}
</button>
);
}