diff options
| author | kj_sh604 | 2026-03-15 16:19:35 -0400 |
|---|---|---|
| committer | kj_sh604 | 2026-03-15 16:19:35 -0400 |
| commit | 6ec259a0e71174651bae95d4628138bf6fd68742 (patch) | |
| tree | 5e33c6a5ec091ecabfcb257fdc7b6a88ed8754ac /packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx | |
| parent | 16c8578b15c727f22921f8a80a56ee4d4e7f2272 (diff) | |
refactor: packages/
Diffstat (limited to 'packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx')
| -rw-r--r-- | packages/excalidraw/components/OverwriteConfirm/OverwriteConfirmActions.tsx | 85 |
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 }; |
