summaryrefslogtreecommitdiffstats
path: root/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx')
-rw-r--r--packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx85
1 files changed, 85 insertions, 0 deletions
diff --git a/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx b/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx
new file mode 100644
index 0000000..5da0a08
--- /dev/null
+++ b/packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx
@@ -0,0 +1,85 @@
+import React from "react";
+import { FilledButton } from "../FilledButton";
+import { useExcalidrawActionManager, useExcalidrawSetAppState } from "../App";
+import { actionSaveFileToDisk } from "../../actions";
+import { useI18n } from "../../i18n";
+import { actionChangeExportEmbedScene } from "../../actions/actionExport";
+
+export type ActionProps = {
+ title: string;
+ children: React.ReactNode;
+ actionLabel: string;
+ onClick: () => void;
+};
+
+export const Action = ({
+ title,
+ children,
+ actionLabel,
+ onClick,
+}: ActionProps) => {
+ return (
+ <div className="OverwriteConfirm__Actions__Action">
+ <h4>{title}</h4>
+ <div className="OverwriteConfirm__Actions__Action__content">
+ {children}
+ </div>
+ <FilledButton
+ variant="outlined"
+ color="muted"
+ label={actionLabel}
+ size="large"
+ fullWidth
+ onClick={onClick}
+ />
+ </div>
+ );
+};
+
+export const ExportToImage = () => {
+ const { t } = useI18n();
+ const actionManager = useExcalidrawActionManager();
+ const setAppState = useExcalidrawSetAppState();
+
+ return (
+ <Action
+ title={t("overwriteConfirm.action.exportToImage.title")}
+ actionLabel={t("overwriteConfirm.action.exportToImage.button")}
+ onClick={() => {
+ actionManager.executeAction(actionChangeExportEmbedScene, "ui", true);
+ setAppState({ openDialog: { name: "imageExport" } });
+ }}
+ >
+ {t("overwriteConfirm.action.exportToImage.description")}
+ </Action>
+ );
+};
+
+export const SaveToDisk = () => {
+ const { t } = useI18n();
+ const actionManager = useExcalidrawActionManager();
+
+ return (
+ <Action
+ title={t("overwriteConfirm.action.saveToDisk.title")}
+ actionLabel={t("overwriteConfirm.action.saveToDisk.button")}
+ onClick={() => {
+ actionManager.executeAction(actionSaveFileToDisk, "ui");
+ }}
+ >
+ {t("overwriteConfirm.action.saveToDisk.description")}
+ </Action>
+ );
+};
+
+const Actions = Object.assign(
+ ({ children }: { children: React.ReactNode }) => {
+ return <div className="OverwriteConfirm__Actions">{children}</div>;
+ },
+ {
+ ExportToImage,
+ SaveToDisk,
+ },
+);
+
+export { Actions };