From eba93a3b6c4d04053a6b3a7436acf8406b28cc6e Mon Sep 17 00:00:00 2001 From: ConnorYoh <40631091+ConnorYoh@users.noreply.github.com> Date: Fri, 3 Oct 2025 17:02:05 +0100 Subject: [PATCH] Frontend V2 Ui Tweaks (#4590) * Top Controls only show when files > 0 * Moved content down so top controls don't obscure * Viewer background set to match workbench and shadow around pages added so that page boundaries are visible * unsaved-changes modal rework --------- Co-authored-by: Connor Yoh --- .../public/locales/en-GB/translation.json | 7 +- .../src/components/fileEditor/FileEditor.tsx | 4 +- frontend/src/components/layout/Workbench.tsx | 11 +- .../src/components/pageEditor/PageEditor.tsx | 2 +- .../shared/NavigationWarningModal.tsx | 101 ++++++++---------- .../src/components/viewer/LocalEmbedPDF.tsx | 5 +- 6 files changed, 64 insertions(+), 66 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/fileEditor/FileEditor.tsx b/frontend/src/components/fileEditor/FileEditor.tsx index 00bf22480..305903b0c 100644 --- a/frontend/src/components/fileEditor/FileEditor.tsx +++ b/frontend/src/components/fileEditor/FileEditor.tsx @@ -348,7 +348,7 @@ const FileEditor = ({ - + {activeStirlingFileStubs.length === 0 && !zipExtractionProgress.isExtracting ? ( @@ -446,7 +446,7 @@ const FileEditor = ({ onSelectFiles={handleLoadFromStorage} /> - + ); diff --git a/frontend/src/components/layout/Workbench.tsx b/frontend/src/components/layout/Workbench.tsx index 8089d1a44..f0f9a542e 100644 --- a/frontend/src/components/layout/Workbench.tsx +++ b/frontend/src/components/layout/Workbench.tsx @@ -146,10 +146,12 @@ export default function Workbench() { } > {/* Top Controls */} - + {activeFiles.length > 0 && ( + + )} {/* Dismiss All Errors Button */} @@ -159,6 +161,7 @@ export default function Workbench() { className="flex-1 min-h-0 relative z-10 workbench-scrollable " style={{ transition: 'opacity 0.15s ease-in-out', + paddingTop: activeFiles.length > 0 ? '3.5rem' : '0', }} > {renderMainContent()} diff --git a/frontend/src/components/pageEditor/PageEditor.tsx b/frontend/src/components/pageEditor/PageEditor.tsx index ee77d142d..0cab1f947 100644 --- a/frontend/src/components/pageEditor/PageEditor.tsx +++ b/frontend/src/components/pageEditor/PageEditor.tsx @@ -662,7 +662,7 @@ const PageEditor = ({ const displayedPages = displayDocument?.pages || []; return ( - + {!mergedPdfDocument && !globalProcessing && activeFileIds.length === 0 && ( diff --git a/frontend/src/components/shared/NavigationWarningModal.tsx b/frontend/src/components/shared/NavigationWarningModal.tsx index b1b935738..8188be435 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(); @@ -38,13 +32,14 @@ const NavigationWarningModal = ({ confirmNavigation(); }; - const handleExportAndContinue = async () => { + const _handleExportAndContinue = async () => { if (onExportAndContinue) { await onExportAndContinue(); } setHasUnsavedChanges(false); confirmNavigation(); }; + const BUTTON_WIDTH = "10rem"; if (!hasUnsavedChanges) { return null; @@ -56,55 +51,53 @@ 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?")} + + - - - - - - - - {onExportAndContinue && ( - - )} - + + {onApplyAndContinue && ( - )} + + {/* Mobile layout: centered stack of 4 buttons */} + + + + {onApplyAndContinue && ( + + )} + ); diff --git a/frontend/src/components/viewer/LocalEmbedPDF.tsx b/frontend/src/components/viewer/LocalEmbedPDF.tsx index c0ef68990..bc65c5557 100644 --- a/frontend/src/components/viewer/LocalEmbedPDF.tsx +++ b/frontend/src/components/viewer/LocalEmbedPDF.tsx @@ -274,7 +274,7 @@ export function LocalEmbedPDF({ file, url, enableAnnotations = false, onSignatur e.preventDefault()}