Skip to content

Commit 2f5619d

Browse files
committed
feat: integrate BackupsModal into ExcalidrawWrapper and MainMenu
- Added BackupsModal component to ExcalidrawWrapper for managing canvas backups. - Updated MainMenuConfig to include handlers for showing and closing the BackupsModal. - Enhanced styles for the AuthDialog and BackupsModal to improve UI consistency. - Adjusted BackupsModal properties for better user interaction, including size and close behavior.
1 parent 34b19eb commit 2f5619d

File tree

5 files changed

+36
-22
lines changed

5 files changed

+36
-22
lines changed

src/frontend/src/ExcalidrawWrapper.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import type { AppState } from '@atyrode/excalidraw/types';
77
import { MainMenuConfig } from './ui/MainMenu';
88
import { renderCustomEmbeddable } from './CustomEmbeddableRenderer';
99
import AuthDialog from './ui/AuthDialog';
10+
import BackupsModal from './ui/BackupsDialog';
1011

1112
const defaultInitialData = {
1213
elements: [],
@@ -44,13 +45,21 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
4445
// Add state for modal animation
4546
const [isExiting, setIsExiting] = useState(false);
4647

48+
// State for BackupsModal
49+
const [showBackupsModal, setShowBackupsModal] = useState(false);
50+
4751
// Handle auth state changes
4852
useEffect(() => {
4953
if (isAuthenticated === true) {
5054
setIsExiting(true);
5155
}
5256
}, [isAuthenticated]);
5357

58+
// Handler for closing the backups modal
59+
const handleCloseBackupsModal = () => {
60+
setShowBackupsModal(false);
61+
};
62+
5463
const renderExcalidraw = (children: React.ReactNode) => {
5564
const Excalidraw = Children.toArray(children).find(
5665
(child: any) =>
@@ -81,12 +90,24 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
8190
)),
8291
},
8392
<>
84-
<MainMenuConfig MainMenu={MainMenu} excalidrawAPI={excalidrawAPI} />
93+
<MainMenuConfig
94+
MainMenu={MainMenu}
95+
excalidrawAPI={excalidrawAPI}
96+
showBackupsModal={showBackupsModal}
97+
setShowBackupsModal={setShowBackupsModal}
98+
/>
8599
{!isAuthLoading && isAuthenticated === false && (
86100
<AuthDialog
87101
onClose={() => {}}
88102
/>
89103
)}
104+
105+
{showBackupsModal && (
106+
<BackupsModal
107+
excalidrawAPI={excalidrawAPI}
108+
onClose={handleCloseBackupsModal}
109+
/>
110+
)}
90111
</>
91112
);
92113
};

src/frontend/src/styles/AuthDialog.scss

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
/* Auth Modal Styles */
22

3+
.excalidraw .Dialog--fullscreen {
4+
&.auth-modal, .auth-modal {
5+
.Dialog__close {
6+
display: none;
7+
}
8+
}
9+
}
10+
311
.excalidraw .Dialog--fullscreen {
412
.auth-modal {
513
&__logo-container {

src/frontend/src/styles/index.scss

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ body {
5555
font-size: 15px !important;
5656
}
5757

58-
.excalidraw .Dialog--fullscreen {
59-
.Dialog__close {
60-
display: none;
61-
}
62-
}
63-
6458
.excalidraw .Modal__background {
6559
background-color: rgba(0, 0, 0, 0);
6660
backdrop-filter: blur(0px);

src/frontend/src/ui/BackupsDialog.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ const BackupsModal: React.FC<BackupsModalProps> = ({
109109
<div className="backups-modal__wrapper">
110110
<Dialog
111111
className="backups-modal"
112-
size="small"
112+
size="regular"
113113
onCloseRequest={handleClose}
114114
title={
115115
<div className="backups-modal__title-container">
116116
<h2 className="backups-modal__title">Canvas Backups</h2>
117117
</div>
118118
}
119-
closeOnClickOutside={false}
119+
closeOnClickOutside={true}
120120
children={dialogContent}
121121
/>
122122
</div>

src/frontend/src/ui/MainMenu.tsx

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { ExcalidrawImperativeAPI } from '@atyrode/excalidraw/types';
44
import type { MainMenu as MainMenuType } from '@atyrode/excalidraw';
55

66
import { LogOut, SquarePlus, LayoutDashboard, SquareCode, Eye, Coffee, Grid2x2, User, Text, ArchiveRestore } from 'lucide-react';
7-
import BackupsModal from './BackupsDialog';
87
import { capture } from '../utils/posthog';
98
import { ExcalidrawElementFactory, PlacementMode } from '../lib/ExcalidrawElementFactory';
109
import { useUserProfile } from "../api/hooks";
@@ -13,11 +12,15 @@ import { queryClient } from "../api/queryClient";
1312
interface MainMenuConfigProps {
1413
MainMenu: typeof MainMenuType;
1514
excalidrawAPI: ExcalidrawImperativeAPI | null;
15+
showBackupsModal: boolean;
16+
setShowBackupsModal: (show: boolean) => void;
1617
}
1718

1819
export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
1920
MainMenu,
2021
excalidrawAPI,
22+
showBackupsModal,
23+
setShowBackupsModal,
2124
}) => {
2225
const { data, isLoading, isError } = useUserProfile();
2326

@@ -93,16 +96,10 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
9396
});
9497
};
9598

96-
const [showBackupsModal, setShowBackupsModal] = useState(false);
97-
9899
const handleCanvasBackupsClick = () => {
99100
setShowBackupsModal(true);
100101
};
101102

102-
const handleCloseBackupsModal = () => {
103-
setShowBackupsModal(false);
104-
};
105-
106103
const handleGridToggle = () => {
107104
if (!excalidrawAPI) return;
108105
const appState = excalidrawAPI.getAppState();
@@ -238,12 +235,6 @@ export const MainMenuConfig: React.FC<MainMenuConfigProps> = ({
238235
Logout
239236
</MainMenu.Item>
240237

241-
{showBackupsModal && (
242-
<BackupsModal
243-
excalidrawAPI={excalidrawAPI}
244-
onClose={handleCloseBackupsModal}
245-
/>
246-
)}
247238
</MainMenu>
248239
);
249240
};

0 commit comments

Comments
 (0)