From 86dd9aa42a8f26727ca5f57cc61ccb392f7f7677 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 23 Aug 2025 10:47:46 +0300 Subject: [PATCH] chore(react/ribbon): integrate expand/collapse button --- .../client/src/widgets/react/ActionButton.tsx | 7 +-- apps/client/src/widgets/react/hooks.tsx | 8 ++-- apps/client/src/widgets/ribbon/NoteMapTab.tsx | 45 +++++++++++++++++-- apps/client/src/widgets/ribbon/style.css | 2 +- .../src/widgets/ribbon_widgets/note_map.ts | 38 ---------------- 5 files changed, 51 insertions(+), 49 deletions(-) diff --git a/apps/client/src/widgets/react/ActionButton.tsx b/apps/client/src/widgets/react/ActionButton.tsx index 5adacc5c1..65eb60469 100644 --- a/apps/client/src/widgets/react/ActionButton.tsx +++ b/apps/client/src/widgets/react/ActionButton.tsx @@ -1,13 +1,14 @@ interface ActionButtonProps { text: string; icon: string; + className?: string; onClick?: () => void; } -export default function ActionButton({ text, icon, onClick }: ActionButtonProps) { +export default function ActionButton({ text, icon, className, onClick }: ActionButtonProps) { return - - - -`; - export default class NoteMapRibbonWidget extends NoteContextAwareWidget { private openState!: "small" | "full"; @@ -50,37 +42,7 @@ export default class NoteMapRibbonWidget extends NoteContextAwareWidget { this.noteMapWidget.setDimensions(); }); - const handleResize = () => { - if (!this.noteMapWidget.graph) { - // no graph has been even rendered - return; - } - - if (this.openState === "full") { - this.setFullHeight(); - } else if (this.openState === "small") { - this.setSmallSize(); - } - }; - new ResizeObserver(handleResize).observe(this.$widget[0]); } - setSmallSize() { - const SMALL_SIZE_HEIGHT = 300; - const width = this.$widget.width() ?? 0; - - this.$widget.find(".note-map-container").height(SMALL_SIZE_HEIGHT).width(width); - } - - setFullHeight() { - const { top } = this.$widget[0].getBoundingClientRect(); - - const height = ($(window).height() ?? 0) - top; - const width = this.$widget.width() ?? 0; - - this.$widget.find(".note-map-container") - .height(height) - .width(width); - } }