mirror of
https://github.com/zadam/trilium.git
synced 2025-12-17 13:49:58 +01:00
feat(layout/inline-title): hide note type switcher when empty
This commit is contained in:
@@ -47,6 +47,7 @@ body.prefers-centered-content .inline-title {
|
|||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
gap: 5px;
|
gap: 5px;
|
||||||
|
min-height: 60px;
|
||||||
--badge-radius: 12px;
|
--badge-radius: 12px;
|
||||||
|
|
||||||
.ext-badge {
|
.ext-badge {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import { formatDateTime } from "../../utils/formatters";
|
|||||||
import NoteIcon from "../note_icon";
|
import NoteIcon from "../note_icon";
|
||||||
import NoteTitleWidget from "../note_title";
|
import NoteTitleWidget from "../note_title";
|
||||||
import { Badge } from "../react/Badge";
|
import { Badge } from "../react/Badge";
|
||||||
import { useNoteContext, useNoteProperty, useStaticTooltip } from "../react/hooks";
|
import { useNoteBlob, useNoteContext, useNoteProperty, useStaticTooltip } from "../react/hooks";
|
||||||
import { joinElements } from "../react/react_utils";
|
import { joinElements } from "../react/react_utils";
|
||||||
import { useNoteMetadata } from "../ribbon/NoteInfoTab";
|
import { useNoteMetadata } from "../ribbon/NoteInfoTab";
|
||||||
import { onWheelHorizontalScroll } from "../widget_utils";
|
import { onWheelHorizontalScroll } from "../widget_utils";
|
||||||
@@ -132,6 +132,7 @@ function TextWithValue({ i18nKey, value, valueTooltip }: {
|
|||||||
//#region Note type switcher
|
//#region Note type switcher
|
||||||
function NoteTypeSwitcher() {
|
function NoteTypeSwitcher() {
|
||||||
const { note } = useNoteContext();
|
const { note } = useNoteContext();
|
||||||
|
const blob = useNoteBlob(note);
|
||||||
const currentNoteType = useNoteProperty(note, "type");
|
const currentNoteType = useNoteProperty(note, "type");
|
||||||
const noteTypes = useMemo(() => NOTE_TYPES.filter((nt) => !nt.reserved && !nt.static), []);
|
const noteTypes = useMemo(() => NOTE_TYPES.filter((nt) => !nt.reserved && !nt.static), []);
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ function NoteTypeSwitcher() {
|
|||||||
className="note-type-switcher"
|
className="note-type-switcher"
|
||||||
onWheel={onWheelHorizontalScroll}
|
onWheel={onWheelHorizontalScroll}
|
||||||
>
|
>
|
||||||
{noteTypes.map(noteType => noteType.type !== currentNoteType && (
|
{blob?.contentLength === 0 && noteTypes.map(noteType => noteType.type !== currentNoteType && (
|
||||||
<Badge
|
<Badge
|
||||||
key={noteType.type}
|
key={noteType.type}
|
||||||
text={noteType.title}
|
text={noteType.title}
|
||||||
|
|||||||
Reference in New Issue
Block a user