From c6d97e3d4bcbb364b3fb7bab02881994c490fc0b Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 12 Dec 2025 21:29:40 +0200 Subject: [PATCH] feat(status_bar): basic integration of attribute editor --- apps/client/src/widgets/layout/StatusBar.css | 112 +++++++++--------- apps/client/src/widgets/layout/StatusBar.tsx | 69 ++++++++--- .../src/widgets/ribbon/OwnedAttributesTab.tsx | 3 +- 3 files changed, 112 insertions(+), 72 deletions(-) diff --git a/apps/client/src/widgets/layout/StatusBar.css b/apps/client/src/widgets/layout/StatusBar.css index 094e2d3b8..e5ee87a08 100644 --- a/apps/client/src/widgets/layout/StatusBar.css +++ b/apps/client/src/widgets/layout/StatusBar.css @@ -2,70 +2,74 @@ contain: none; border-top: 1px solid var(--main-border-color); background-color: var(--left-pane-background-color); - display: flex; - align-items: center; - padding-inline: 0.25em; - min-height: 32px; - > .breadcrumb-row { - flex-grow: 1; - } - - > .actions-row { - padding: 0.1em; + .status-bar-main-row { + min-height: 32px; display: flex; - gap: 0.1em; - font-size: 0.85em; + align-items: center; + padding-inline: 0.25em; - .btn { - padding: 0 0.5em !important; - background: transparent; + > .breadcrumb-row { + flex-grow: 1; + } + + > .actions-row { + padding: 0.1em; display: flex; - align-items: center; - border: 0; + gap: 0.1em; + font-size: 0.85em; - &:focus, - &:hover { - background: var(--input-background-color); - } - } + .btn { + padding: 0 0.5em !important; + background: transparent; + display: flex; + align-items: center; + border: 0; - .status-bar-dropdown-button { - &:after { - content: unset; - } - } - } - - .dropdown { - .dropdown-toggle { - padding: 0.1em 0.25em; - } - } - - .dropdown-note-info { - width: max-content; - - ul { - list-style-type: none; - padding: 0.5em; - margin: 0; - display: table; - - li { - display: table-row; - - > strong { - display: table-cell; - padding: 0.2em 0; + &:focus, + &:hover { + background: var(--input-background-color); } + } - > span { - display: table-cell; - user-select: text; - padding-left: 2em; + .status-bar-dropdown-button { + &:after { + content: unset; + } + } + } + + .dropdown { + .dropdown-toggle { + padding: 0.1em 0.25em; + } + } + + .dropdown-note-info { + width: max-content; + + ul { + list-style-type: none; + padding: 0.5em; + margin: 0; + display: table; + + li { + display: table-row; + + > strong { + display: table-cell; + padding: 0.2em 0; + } + + > span { + display: table-cell; + user-select: text; + padding-left: 2em; + } } } } } + } diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsx index 6696cea3e..b3ed74b5b 100644 --- a/apps/client/src/widgets/layout/StatusBar.tsx +++ b/apps/client/src/widgets/layout/StatusBar.tsx @@ -9,6 +9,7 @@ import { useContext, useRef, useState } from "preact/hooks"; import { CommandNames } from "../../components/app_context"; import NoteContext from "../../components/note_context"; import FNote from "../../entities/fnote"; +import attributes from "../../services/attributes"; import { t } from "../../services/i18n"; import { ViewScope } from "../../services/link"; import { openInAppHelpFromUrl } from "../../services/utils"; @@ -20,11 +21,11 @@ import { useActiveNoteContext, useStaticTooltip, useTriliumEvent } from "../reac import Icon from "../react/Icon"; import { ParentComponent } from "../react/react_utils"; import { ContentLanguagesModal, useLanguageSwitcher } from "../ribbon/BasicPropertiesTab"; +import AttributeEditor, { AttributeEditorImperativeHandlers } from "../ribbon/components/AttributeEditor"; import { NoteSizeWidget, useNoteMetadata } from "../ribbon/NoteInfoTab"; import { useAttachments } from "../type_widgets/Attachment"; import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector"; import Breadcrumb from "./Breadcrumb"; -import attributes from "../../services/attributes"; interface StatusBarContext { note: FNote; @@ -38,19 +39,23 @@ export default function StatusBar() { return (
- {context && <> -
- -
+ {context && } -
- - - - - -
- } +
+ {context && <> +
+ +
+ +
+ + + + + +
+ } +
); } @@ -81,14 +86,18 @@ function StatusBarDropdown({ children, icon, text, buttonClassName, titleOptions ); } -function StatusBarButton({ className, icon, text, title, triggerCommand }: { +interface StatusBarButtonBaseProps { className?: string; icon: string; title: string; text?: string | number; disabled?: boolean; - triggerCommand: CommandNames; -}) { +} + +type StatusBarButtonWithCommand = StatusBarButtonBaseProps & { triggerCommand: CommandNames; }; +type StatusBarButtonWithClick = StatusBarButtonBaseProps & { onClick: () => void; }; + +function StatusBarButton({ className, icon, text, title, ...restProps }: StatusBarButtonWithCommand | StatusBarButtonWithClick) { const parentComponent = useContext(ParentComponent); const buttonRef = useRef(null); useStaticTooltip(buttonRef, { @@ -103,7 +112,13 @@ function StatusBarButton({ className, icon, text, title, triggerCommand }: { ref={buttonRef} className={clsx("btn select-button", className)} type="button" - onClick={() => parentComponent?.triggerCommand(triggerCommand)} + onClick={() => { + if ("triggerCommand" in restProps) { + parentComponent?.triggerCommand(restProps.triggerCommand); + } else { + restProps.onClick(); + } + }} >  {text} @@ -246,7 +261,27 @@ function AttributesButton({ note }: StatusBarContext) { icon="bx bx-list-check" title={t("status_bar.attributes_title")} text={t("status_bar.attributes", { count })} + onClick={() => { + alert("Hi"); + }} /> ); } + +function AttributesPane({ note, noteContext }: StatusBarContext) { + const parentComponent = useContext(ParentComponent); + const api = useRef(null); + + return ( +
+ {parentComponent &&
+ ); +} //#endregion diff --git a/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx b/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx index ae3d90c07..b80d748b5 100644 --- a/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx +++ b/apps/client/src/widgets/ribbon/OwnedAttributesTab.tsx @@ -1,4 +1,5 @@ import { useMemo, useRef } from "preact/hooks"; + import { useLegacyImperativeHandlers, useTriliumEvents } from "../react/hooks"; import AttributeEditor, { AttributeEditorImperativeHandlers } from "./components/AttributeEditor"; import { TabContext } from "./ribbon-interface"; @@ -25,5 +26,5 @@ export default function OwnedAttributesTab({ note, hidden, activate, ntxId, ...r