From ba2c86fe1bad6f2e3a7a20fde8f7f3727bc18657 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Mon, 22 Aug 2022 16:09:24 +0530 Subject: [PATCH] refactor: Move footer to its own component (#5609) --- src/components/Actions.tsx | 44 ++++++++++++++++ src/components/Footer.tsx | 99 +++++++++++++++++++++++++++++++++++ src/components/LayerUI.tsx | 104 +++---------------------------------- 3 files changed, 151 insertions(+), 96 deletions(-) create mode 100644 src/components/Footer.tsx diff --git a/src/components/Actions.tsx b/src/components/Actions.tsx index e23b02d0..8cd1d2ab 100644 --- a/src/components/Actions.tsx +++ b/src/components/Actions.tsx @@ -26,6 +26,8 @@ import { ToolButton } from "./ToolButton"; import { hasStrokeColor } from "../scene/comparisons"; import { trackEvent } from "../analytics"; import { hasBoundTextElement, isBoundToContainer } from "../element/typeChecks"; +import clsx from "clsx"; +import { actionToggleZenMode } from "../actions"; export const SelectedShapeActions = ({ appState, @@ -269,3 +271,45 @@ export const ZoomActions = ({ ); + +export const UndoRedoActions = ({ + renderAction, + className, +}: { + renderAction: ActionManager["renderAction"]; + className?: string; +}) => ( +
+ {renderAction("undo", { size: "small" })} + {renderAction("redo", { size: "small" })} +
+); + +export const ExitZenModeAction = ({ + executeAction, + showExitZenModeBtn, +}: { + executeAction: ActionManager["executeAction"]; + showExitZenModeBtn: boolean; +}) => ( + +); + +export const FinalizeAction = ({ + renderAction, + className, +}: { + renderAction: ActionManager["renderAction"]; + className?: string; +}) => ( +
+ {renderAction("finalize", { size: "small" })} +
+); diff --git a/src/components/Footer.tsx b/src/components/Footer.tsx new file mode 100644 index 00000000..297a2124 --- /dev/null +++ b/src/components/Footer.tsx @@ -0,0 +1,99 @@ +import clsx from "clsx"; +import { ActionManager } from "../actions/manager"; +import { AppState, ExcalidrawProps } from "../types"; +import { + ExitZenModeAction, + FinalizeAction, + UndoRedoActions, + ZoomActions, +} from "./Actions"; +import { useDevice } from "./App"; +import { Island } from "./Island"; +import { Section } from "./Section"; +import Stack from "./Stack"; + +const Footer = ({ + appState, + actionManager, + renderCustomFooter, + showExitZenModeBtn, +}: { + appState: AppState; + actionManager: ActionManager; + renderCustomFooter?: ExcalidrawProps["renderFooter"]; + showExitZenModeBtn: boolean; +}) => { + const device = useDevice(); + const showFinalize = + !appState.viewModeEnabled && appState.multiElement && device.isTouchScreen; + return ( + + ); +}; + +export default Footer; diff --git a/src/components/LayerUI.tsx b/src/components/LayerUI.tsx index 168e701d..a4b28733 100644 --- a/src/components/LayerUI.tsx +++ b/src/components/LayerUI.tsx @@ -10,7 +10,7 @@ import { calculateScrollCenter, getSelectedElements } from "../scene"; import { ExportType } from "../scene/types"; import { AppProps, AppState, ExcalidrawProps, BinaryFiles } from "../types"; import { muteFSAbortError } from "../utils"; -import { SelectedShapeActions, ShapesSwitcher, ZoomActions } from "./Actions"; +import { SelectedShapeActions, ShapesSwitcher } from "./Actions"; import { BackgroundPickerAndDarkModeToggle } from "./BackgroundPickerAndDarkModeToggle"; import CollabButton from "./CollabButton"; import { ErrorDialog } from "./ErrorDialog"; @@ -39,7 +39,7 @@ import { trackEvent } from "../analytics"; import { useDevice } from "../components/App"; import { Stats } from "./Stats"; import { actionToggleStats } from "../actions/actionToggleStats"; -import { actionToggleZenMode } from "../actions"; +import Footer from "./Footer"; interface LayerUIProps { actionManager: ActionManager; @@ -381,99 +381,6 @@ const LayerUI = ({ ); }; - const renderBottomAppMenu = () => { - return ( - - ); - }; - const dialogs = ( <> {appState.isLoading && } @@ -565,7 +472,12 @@ const LayerUI = ({ > {dialogs} {renderFixedSideContainer()} - {renderBottomAppMenu()} +