From 40bfd827d2173bd9a21b62a8b50e88ea0ee9b5c2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 27 Aug 2025 23:36:50 +0300 Subject: [PATCH] chore(react/floating_buttons): improve sizing --- apps/client/src/widgets/FloatingButtons.tsx | 36 +++++++++++-------- .../client/src/widgets/react/ActionButton.tsx | 7 ++-- 2 files changed, 26 insertions(+), 17 deletions(-) diff --git a/apps/client/src/widgets/FloatingButtons.tsx b/apps/client/src/widgets/FloatingButtons.tsx index 9528ede08..af66571d8 100644 --- a/apps/client/src/widgets/FloatingButtons.tsx +++ b/apps/client/src/widgets/FloatingButtons.tsx @@ -1,7 +1,7 @@ import { t } from "i18next"; import "./FloatingButtons.css"; import Button from "./react/Button"; -import ActionButton from "./react/ActionButton"; +import ActionButton, { ActionButtonProps } from "./react/ActionButton"; import FNote from "../entities/fnote"; import NoteContext from "../components/note_context"; import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useTriliumEvent, useTriliumEvents, useTriliumOption, useTriliumOptionBool } from "./react/hooks"; @@ -154,7 +154,7 @@ export default function FloatingButtons() { } function RefreshBackendLogButton({ parentComponent, noteContext }: FloatingButtonContext) { - return parentComponent.triggerEvent("refreshData", { ntxId: noteContext.ntxId })} @@ -165,7 +165,7 @@ function SwitchSplitOrientationButton({ }: FloatingButtonContext) { const [ splitEditorOrientation, setSplitEditorOrientation ] = useTriliumOption("splitEditorOrientation"); const upcomingOrientation = splitEditorOrientation === "horizontal" ? "vertical" : "horizontal"; - return setSplitEditorOrientation(upcomingOrientation)} @@ -175,7 +175,7 @@ function SwitchSplitOrientationButton({ }: FloatingButtonContext) { function ToggleReadOnlyButton({ note }: FloatingButtonContext) { const [ isReadOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly"); - return setReadOnly(!isReadOnly)} @@ -194,7 +194,7 @@ function EditButton({ noteContext }: FloatingButtonContext) { }, 1700); }, []); - return { @@ -221,7 +221,7 @@ function ShowTocWidgetButton({ noteContext }: FloatingButtonContext) { } function ShowHighlightsListWidgetButton({ noteContext }: FloatingButtonContext) { - return { @@ -234,7 +234,7 @@ function ShowHighlightsListWidgetButton({ noteContext }: FloatingButtonContext) } function RunActiveNoteButton() { - return openInAppHelpFromUrl(note.mime.endsWith("frontend") ? "Q2z6av6JZVWm" : "MEtfsqa5VwNi")} @@ -250,7 +250,7 @@ function OpenTriliumApiDocsButton({ note }: FloatingButtonContext) { } function SaveToNoteButton({ note }: FloatingButtonContext) { - return { @@ -269,26 +269,26 @@ function SaveToNoteButton({ note }: FloatingButtonContext) { function RelationMapButtons({ parentComponent, noteContext }: FloatingButtonContext) { return ( <> - parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId: noteContext.ntxId })} /> - parentComponent.triggerEvent("relationMapResetPanZoom", { ntxId: noteContext.ntxId })} />
- parentComponent.triggerEvent("relationMapResetZoomIn", { ntxId: noteContext.ntxId })} /> - parentComponent.triggerEvent("relationMapResetZoomOut", { ntxId: noteContext.ntxId })} @@ -298,6 +298,14 @@ function RelationMapButtons({ parentComponent, noteContext }: FloatingButtonCont ) } +function FloatingButton({ className, ...props }: ActionButtonProps) { + return +} + /** * Show button that displays floating button after click on close button */ diff --git a/apps/client/src/widgets/react/ActionButton.tsx b/apps/client/src/widgets/react/ActionButton.tsx index 5636372d8..c97aa01ca 100644 --- a/apps/client/src/widgets/react/ActionButton.tsx +++ b/apps/client/src/widgets/react/ActionButton.tsx @@ -3,16 +3,17 @@ import { CommandNames } from "../../components/app_context"; import { useStaticTooltip } from "./hooks"; import keyboard_actions from "../../services/keyboard_actions"; -interface ActionButtonProps { +export interface ActionButtonProps { text: string; titlePosition?: "bottom" | "left"; // TODO: Use it icon: string; className?: string; onClick?: (e: MouseEvent) => void; triggerCommand?: CommandNames; + noIconActionClass?: boolean; } -export default function ActionButton({ text, icon, className, onClick, triggerCommand, titlePosition }: ActionButtonProps) { +export default function ActionButton({ text, icon, className, onClick, triggerCommand, titlePosition, noIconActionClass }: ActionButtonProps) { const buttonRef = useRef(null); const [ keyboardShortcut, setKeyboardShortcut ] = useState(); @@ -30,7 +31,7 @@ export default function ActionButton({ text, icon, className, onClick, triggerCo return