Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile/tab_switcher): display note splits

Elian Dorane7f356b87c06
diff --git a/apps/client/src/widgets/mobile_widgets/TabSwitcher.css b/apps/client/src/widgets/mobile_widgets/TabSwitcher.css
index 47736a72f6..4518d76c2c 100644
--- a/apps/client/src/widgets/mobile_widgets/TabSwitcher.css
+++ b/apps/client/src/widgets/mobile_widgets/TabSwitcher.css
@@ -27,6 +27,9 @@
border-radius: 1em;
min-width: 0;
overflow: hidden;
+ height: 200px;
+ display: flex;
+ flex-direction: column;
&.with-hue {
background-color: hsl(var(--bg-hue), 8.8%, 11.2%);
@@ -49,6 +52,11 @@
overflow: hidden;
align-items: center;
color: var(--custom-color, inherit);
+ flex-shrink: 0;
+
+ &:not(:first-of-type) {
+ border-top: 1px solid rgba(150, 150, 150, 0.1);
+ }
>.tn-icon {
margin-inline-end: 0.4em;
@@ -68,7 +76,8 @@
}
.tab-preview {
- height: 180px;
+ flex-grow: 1;
+ height: 100%;
overflow: hidden;
font-size: 0.5em;
user-select: none;
@@ -100,6 +109,12 @@
h5 { font-size: 1.05em}
h6 { font-size: 1em; }
}
+
+ &.with-split {
+ .preview-placeholder {
+ font-size: 250%;
+ }
+ }
}
}
diff --git a/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx b/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx
index 78107ec810..c3d32129cc 100644
--- a/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx
+++ b/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx
@@ -1,7 +1,7 @@
import "./TabSwitcher.css";
import clsx from "clsx";
-import { createPortal } from "preact/compat";
+import { createPortal, Fragment } from "preact/compat";
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import appContext, { CommandNames } from "../../components/app_context";
@@ -141,35 +141,41 @@ function Tab({ noteContext, containerRef, selectTab, activeNtxId }: {
const iconClass = useNoteIcon(note);
const colorClass = note?.getColorClass() || '';
const workspaceTabBackgroundColorHue = getWorkspaceTabBackgroundColorHue(noteContext);
+ const subContexts = noteContext.getSubContexts();
return (
<div
ref={containerRef}
class={clsx("tab-card", {
active: noteContext.ntxId === activeNtxId,
- "with-hue": workspaceTabBackgroundColorHue !== undefined
+ "with-hue": workspaceTabBackgroundColorHue !== undefined,
+ "with-split": subContexts.length > 1
})}
onClick={() => selectTab(noteContext)}
style={{
"--bg-hue": workspaceTabBackgroundColorHue
}}
>
- <header className={colorClass}>
- {note && <Icon icon={iconClass} />}
- <span className="title">{noteContext.note?.title ?? t("tab_row.new_tab")}</span>
- <ActionButton
- icon="bx bx-x"
- text={t("tab_row.close_tab")}
- onClick={(e) => {
- // We are closing a tab, so we need to prevent propagation for click (activate tab).
- e.stopPropagation();
- appContext.tabManager.removeNoteContext(noteContext.ntxId);
- }}
- />
- </header>
- <div className={clsx("tab-preview", `type-${note?.type ?? "empty"}`)}>
- <TabPreviewContent note={note} />
- </div>
+ {subContexts.map(subContext => (
+ <Fragment key={subContext.ntxId}>
+ <header className={colorClass}>
+ {subContext.note && <Icon icon={iconClass} />}
+ <span className="title">{subContext.note?.title ?? t("tab_row.new_tab")}</span>
+ {subContext.isMainContext() && <ActionButton
+ icon="bx bx-x"
+ text={t("tab_row.close_tab")}
+ onClick={(e) => {
+ // We are closing a tab, so we need to prevent propagation for click (activate tab).
+ e.stopPropagation();
+ appContext.tabManager.removeNoteContext(subContext.ntxId);
+ }}
+ />}
+ </header>
+ <div className={clsx("tab-preview", `type-${subContext.note?.type ?? "empty"}`)}>
+ <TabPreviewContent note={subContext.note} />
+ </div>
+ </Fragment>
+ ))}
</div>
);
}