From 2769af3db577afe386cd3254e03762a6af02b955 Mon Sep 17 00:00:00 2001 From: Connor Yoh Date: Fri, 3 Oct 2025 15:38:38 +0100 Subject: [PATCH] reworked modal for small screens --- .../public/locales/en-GB/translation.json | 7 +- .../shared/NavigationWarningModal.tsx | 98 +++++++++---------- 2 files changed, 51 insertions(+), 54 deletions(-) diff --git a/frontend/public/locales/en-GB/translation.json b/frontend/public/locales/en-GB/translation.json index 71f0bb90b..b28923f63 100644 --- a/frontend/public/locales/en-GB/translation.json +++ b/frontend/public/locales/en-GB/translation.json @@ -1,9 +1,10 @@ { - "unsavedChanges": "You have unsaved changes to your PDF. What would you like to do?", + "unsavedChanges": "You have unsaved changes to your PDF.", + "areYouSure": "Are you sure you want to leave?", "unsavedChangesTitle": "Unsaved Changes", "keepWorking": "Keep Working", - "discardChanges": "Discard Changes", - "applyAndContinue": "Apply & Continue", + "discardChanges": "Discard & Leave", + "applyAndContinue": "Save & Leave", "exportAndContinue": "Export & Continue", "language": { "direction": "ltr" diff --git a/frontend/src/components/shared/NavigationWarningModal.tsx b/frontend/src/components/shared/NavigationWarningModal.tsx index b1b935738..f5a8cdfe2 100644 --- a/frontend/src/components/shared/NavigationWarningModal.tsx +++ b/frontend/src/components/shared/NavigationWarningModal.tsx @@ -1,25 +1,19 @@ -import { Modal, Text, Button, Group, Stack } from '@mantine/core'; -import { useNavigationGuard } from '../../contexts/NavigationContext'; -import { useTranslation } from 'react-i18next'; +import { Modal, Text, Button, Group, Stack } from "@mantine/core"; +import { useNavigationGuard } from "../../contexts/NavigationContext"; +import { useTranslation } from "react-i18next"; +import ArrowBackIcon from "@mui/icons-material/ArrowBack"; +import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline"; +import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline"; interface NavigationWarningModalProps { onApplyAndContinue?: () => Promise; onExportAndContinue?: () => Promise; } -const NavigationWarningModal = ({ - onApplyAndContinue, - onExportAndContinue -}: NavigationWarningModalProps) => { - +const NavigationWarningModal = ({ onApplyAndContinue, onExportAndContinue }: NavigationWarningModalProps) => { const { t } = useTranslation(); - const { - showNavigationWarning, - hasUnsavedChanges, - cancelNavigation, - confirmNavigation, - setHasUnsavedChanges - } = useNavigationGuard(); + const { showNavigationWarning, hasUnsavedChanges, cancelNavigation, confirmNavigation, setHasUnsavedChanges } = + useNavigationGuard(); const handleKeepWorking = () => { cancelNavigation(); @@ -45,6 +39,7 @@ const NavigationWarningModal = ({ setHasUnsavedChanges(false); confirmNavigation(); }; + const BUTTON_WIDTH = "10rem"; if (!hasUnsavedChanges) { return null; @@ -56,55 +51,56 @@ const NavigationWarningModal = ({ onClose={handleKeepWorking} title={t("unsavedChangesTitle", "Unsaved Changes")} centered - size="xl" - closeOnClickOutside={false} - closeOnEscape={false} + size="auto" + closeOnClickOutside={true} + closeOnEscape={true} > - - - {t("unsavedChanges", "You have unsaved changes to your PDF. What would you like to do?")} + + + + {t("unsavedChanges", "You have unsaved changes to your PDF.")} + + {t("areYouSure", "Are you sure you want to leave?")} + + + {/* Desktop layout: 2 groups side by side */} + + - - - - - - {onExportAndContinue && ( - - )} - + + {onApplyAndContinue && ( - )} + + {/* Mobile layout: centered stack of 4 buttons */} + + + + {onApplyAndContinue && ( + + )} + );