feat(mobile/tab_switcher): improve display of empty tabs

This commit is contained in:
Elian Doran 2026-01-31 19:46:15 +02:00
parent 8f6cfe8a04
commit 8f3545624e
No known key found for this signature in database
2 changed files with 25 additions and 9 deletions

View File

@ -80,7 +80,8 @@
&.type-book,
&.type-contentWidget,
&.type-search {
&.type-search,
&.type-empty {
display: flex;
align-items: center;
justify-content: center;

View File

@ -6,6 +6,7 @@ import { useCallback, useEffect, useRef, useState } from "preact/hooks";
import appContext from "../../components/app_context";
import NoteContext from "../../components/note_context";
import FNote from "../../entities/fnote";
import { getHue, parseColor } from "../../services/css_class_manager";
import froca from "../../services/froca";
import { t } from "../../services/i18n";
@ -143,19 +144,33 @@ function Tab({ noteContext, containerRef, selectTab, activeNtxId }: {
/>
</header>
<div className={clsx("tab-preview", `type-${note?.type ?? "empty"}`)}>
{note?.type === "book"
? <PreviewPlaceholder icon={ICON_MAPPINGS[note.getLabelValue("viewType") ?? ""] ?? "bx bx-book"} />
: note && <NoteContent
note={note}
highlightedTokens={undefined}
trim
includeArchivedNotes={false}
/>}
<TabPreviewContent note={note} />
</div>
</div>
);
}
function TabPreviewContent({ note }: {
note: FNote | null
}) {
if (!note) {
return <PreviewPlaceholder icon="bx bx-plus" />;
}
if (note.type === "book") {
return <PreviewPlaceholder icon={ICON_MAPPINGS[note.getLabelValue("viewType") ?? ""] ?? "bx bx-book"} />;
}
return (
<NoteContent
note={note}
highlightedTokens={undefined}
trim
includeArchivedNotes={false}
/>
);
}
function PreviewPlaceholder({ icon}: {
icon: string;
}) {