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/tab_switcher): basic rendering of tab content
Elian Doran3367bb2e5b16
diff --git a/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx b/apps/client/src/widgets/collections/legacy/ListOrGridView.tsxindex 61f79cc8da..61c7193a6e 100644--- a/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx+++ b/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx@@ -155,7 +155,7 @@ function NoteAttributes({ note }: { note: FNote }) {return <span className="note-list-attributes" ref={ref} />;}-function NoteContent({ note, trim, noChildrenList, highlightedTokens, includeArchivedNotes }: {+export function NoteContent({ note, trim, noChildrenList, highlightedTokens, includeArchivedNotes }: {note: FNote;trim?: boolean;noChildrenList?: boolean;diff --git a/apps/client/src/widgets/mobile_widgets/TabSwitcher.css b/apps/client/src/widgets/mobile_widgets/TabSwitcher.cssindex 16121f8b02..db4cc74a3c 100644--- a/apps/client/src/widgets/mobile_widgets/TabSwitcher.css+++ b/apps/client/src/widgets/mobile_widgets/TabSwitcher.css@@ -8,5 +8,22 @@display: grid;grid-template-columns: 1fr 1fr;gap: 1em;++ .tab-card {+ background: var(--card-background-color);+ border-radius: 1em;++ header {+ padding: 0.5em 1em;+ border-bottom: 1px solid var(--main-border-color);+ }++ .tab-preview {+ height: 180px;+ overflow: hidden;+ font-size: 0.5em;+ padding: 1em;+ }+ }}}diff --git a/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx b/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsxindex 89a40eda2a..5429e244cc 100644--- a/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx+++ b/apps/client/src/widgets/mobile_widgets/TabSwitcher.tsx@@ -4,6 +4,8 @@ import { createPortal } from "preact/compat";import { useEffect, useState } from "preact/hooks";import appContext from "../../components/app_context";+import NoteContext from "../../components/note_context";+import { NoteContent } from "../collections/legacy/ListOrGridView";import { LaunchBarActionButton } from "../launch_bar/launch_bar_widgets";import { useTriliumEvent } from "../react/hooks";import Modal from "../react/Modal";@@ -49,13 +51,33 @@ function TabBarModelContent() {return (<div className="tabs">- {mainNoteContexts.map((tabContext) => (- <span key={tabContext.ntxId}>{tabContext.note?.title}</span>+ {mainNoteContexts.map((noteContext) => (+ <Tab key={noteContext.ntxId} noteContext={noteContext} />))}</div>);}+function Tab({ noteContext }: {+ noteContext: NoteContext;+}) {+ const { note } = noteContext;++ return (+ <div class="tab-card">+ <header>{noteContext.note?.title}</header>+ <div className="tab-preview">+ {note && <NoteContent+ note={note}+ highlightedTokens={undefined}+ trim+ includeArchivedNotes={false}+ />}+ </div>+ </div>+ );+}+function useMainNoteContexts() {const [ noteContexts, setNoteContexts ] = useState(appContext.tabManager.getMainNoteContexts());