From 319e753e7eb405c35aef795ab70ede63699c3336 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 15 Oct 2025 23:37:08 +0300 Subject: [PATCH] feat(collection/presentation): add a button to toggle slide overview --- .../src/translations/en/translation.json | 3 ++- .../collections/presentation/index.tsx | 26 +++++++++++++++++++ .../client/src/widgets/react/ActionButton.tsx | 9 ++++--- 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 04e0eff76..8dee04c63 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -2031,7 +2031,8 @@ }, "presentation_view": { "edit-slide": "Edit this slide", - "start-presentation": "Start presentation" + "start-presentation": "Start presentation", + "slide-overview": "Toggle an overview of the slides" }, "command_palette": { "tree-action-name": "Tree: {{name}}", diff --git a/apps/client/src/widgets/collections/presentation/index.tsx b/apps/client/src/widgets/collections/presentation/index.tsx index 52339dc36..a370a793a 100644 --- a/apps/client/src/widgets/collections/presentation/index.tsx +++ b/apps/client/src/widgets/collections/presentation/index.tsx @@ -52,6 +52,23 @@ export default function PresentationView({ note, noteIds }: ViewModeProps<{}>) { } function ButtonOverlay({ containerRef, apiRef }: { containerRef: RefObject, apiRef: RefObject }) { + const [ isOverviewActive, setIsOverviewActive ] = useState(false); + useEffect(() => { + const api = apiRef.current; + if (!api) return; + setIsOverviewActive(api.isOverview()); + const onEnabled = () => setIsOverviewActive(true); + const onDisabled = () => setIsOverviewActive(false); + api.on("overviewshown", onEnabled); + api.on("overviewhidden", onDisabled); + return () => { + api.off("overviewshown", onEnabled); + api.off("overviewhidden", onDisabled); + }; + }, [ apiRef ]); + + console.log("Active ", isOverviewActive); + return (
+ { + apiRef.current?.toggleOverview(); + }} + /> + void; triggerCommand?: CommandNames; noIconActionClass?: boolean; frame?: boolean; + active?: boolean; + disabled?: boolean; } -export default function ActionButton({ text, icon, className, onClick, triggerCommand, titlePosition, noIconActionClass, frame }: ActionButtonProps) { +export default function ActionButton({ text, icon, className, onClick, triggerCommand, titlePosition, noIconActionClass, frame, active, disabled }: ActionButtonProps) { const buttonRef = useRef(null); const [ keyboardShortcut, setKeyboardShortcut ] = useState(); @@ -32,8 +34,9 @@ export default function ActionButton({ text, icon, className, onClick, triggerCo return