1- import React , { Children , cloneElement } from 'react' ;
1+ import React , { Children , cloneElement , useState , useEffect } from 'react' ;
22import DiscordButton from './ui/DiscordButton' ;
33import FeedbackButton from './ui/FeedbackButton' ;
44import type { ExcalidrawImperativeAPI } from '@atyrode/excalidraw/types' ;
55import type { NonDeletedExcalidrawElement } from '@atyrode/excalidraw/element/types' ;
66import type { AppState } from '@atyrode/excalidraw/types' ;
77import { MainMenuConfig } from './ui/MainMenu' ;
88import { renderCustomEmbeddable } from './CustomEmbeddableRenderer' ;
9+ import AuthDialog from './ui/AuthDialog' ;
910
1011const defaultInitialData = {
1112 elements : [ ] ,
@@ -25,6 +26,8 @@ interface ExcalidrawWrapperProps {
2526 onChange : ( elements : NonDeletedExcalidrawElement [ ] , state : AppState ) => void ;
2627 MainMenu : any ;
2728 renderTopRightUI ?: ( ) => React . ReactNode ;
29+ isAuthenticated ?: boolean | null ;
30+ isAuthLoading ?: boolean ;
2831}
2932
3033export const ExcalidrawWrapper : React . FC < ExcalidrawWrapperProps > = ( {
@@ -35,7 +38,19 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
3538 onChange,
3639 MainMenu,
3740 renderTopRightUI,
41+ isAuthenticated = null ,
42+ isAuthLoading = false ,
3843} ) => {
44+ // Add state for modal animation
45+ const [ isExiting , setIsExiting ] = useState ( false ) ;
46+
47+ // Handle auth state changes
48+ useEffect ( ( ) => {
49+ if ( isAuthenticated === true ) {
50+ setIsExiting ( true ) ;
51+ }
52+ } , [ isAuthenticated ] ) ;
53+
3954 const renderExcalidraw = ( children : React . ReactNode ) => {
4055 const Excalidraw = Children . toArray ( children ) . find (
4156 ( child : any ) =>
@@ -65,7 +80,14 @@ export const ExcalidrawWrapper: React.FC<ExcalidrawWrapperProps> = ({
6580 </ div >
6681 ) ) ,
6782 } ,
68- < MainMenuConfig MainMenu = { MainMenu } excalidrawAPI = { excalidrawAPI } />
83+ < >
84+ < MainMenuConfig MainMenu = { MainMenu } excalidrawAPI = { excalidrawAPI } />
85+ { ! isAuthLoading && isAuthenticated === false && (
86+ < AuthDialog
87+ onClose = { ( ) => { } }
88+ />
89+ ) }
90+ </ >
6991 ) ;
7092 } ;
7193
0 commit comments