@ -40,8 +40,7 @@ interface LayerUIProps {
onLockToggle : ( ) = > void ;
}
export const LayerUI = React . memo (
( {
const LayerUI = ( {
actionManager ,
appState ,
setAppState ,
@ -54,7 +53,7 @@ export const LayerUI = React.memo(
} : LayerUIProps ) = > {
const isMobile = useIsMobile ( ) ;
function renderExportDialog() {
const renderExportDialog = ( ) = > {
const createExporter = ( type : ExportType ) : ExportCB = > (
exportedElements ,
scale ,
@ -92,44 +91,15 @@ export const LayerUI = React.memo(
} }
/ >
) ;
}
} ;
return isMobile ? (
< MobileMenu
appState = { appState }
elements = { elements }
actionManager = { actionManager }
exportButton = { renderExportDialog ( ) }
setAppState = { setAppState }
onUsernameChange = { onUsernameChange }
onRoomCreate = { onRoomCreate }
onRoomDestroy = { onRoomDestroy }
onLockToggle = { onLockToggle }
/ >
) : (
< >
{ appState . isLoading && < LoadingMessage / > }
{ appState . errorMessage && (
< ErrorDialog
message = { appState . errorMessage }
onClose = { ( ) = > setAppState ( { errorMessage : null } ) }
/ >
) }
{ appState . showShortcutsDialog && (
< ShortcutsDialog
onClose = { ( ) = > setAppState ( { showShortcutsDialog : null } ) }
/ >
) }
< FixedSideContainer side = "top" >
< HintViewer appState = { appState } elements = { elements } / >
< div className = "App-menu App-menu_top" >
< Stack.Col gap = { 4 } >
const renderCanvasActions = ( ) = > (
< Section heading = "canvasActions" >
{ / * t h e z I n d e x e n s u r e s t h i s m e n u h a s h i g h e r s t a c k i n g o r d e r ,
see https : //github.com/excalidraw/excalidraw/pull/1445 */}
< Island padding = { 4 } style = { { zIndex : 1 } } >
< Stack.Col gap = { 4 } >
< Stack.Row gap = { 1 } justifyContent = { "space-between" } >
< Stack.Row gap = { 1 } justifyContent = "space-between" >
{ actionManager . renderAction ( "loadScene" ) }
{ actionManager . renderAction ( "saveScene" ) }
{ renderExportDialog ( ) }
@ -147,7 +117,9 @@ export const LayerUI = React.memo(
< / Stack.Col >
< / Island >
< / Section >
{ showSelectedShapeActions ( appState , elements ) && (
) ;
const renderSelectedShapeActions = ( ) = > (
< Section heading = "selectedShapeActions" >
< Island className = { CLASSES . SHAPE_ACTIONS_MENU } padding = { 4 } >
< SelectedShapeActions
@ -158,7 +130,20 @@ export const LayerUI = React.memo(
/ >
< / Island >
< / Section >
) }
) ;
const renderFixedSideContainer = ( ) = > {
const shouldRenderSelectedShapeActions = showSelectedShapeActions (
appState ,
elements ,
) ;
return (
< FixedSideContainer side = "top" >
< HintViewer appState = { appState } elements = { elements } / >
< div className = "App-menu App-menu_top" >
< Stack.Col gap = { 4 } >
{ renderCanvasActions ( ) }
{ shouldRenderSelectedShapeActions && renderSelectedShapeActions ( ) }
< / Stack.Col >
< Section heading = "shapes" >
{ ( heading ) = > (
@ -197,9 +182,10 @@ export const LayerUI = React.memo(
< / Stack.Col >
< / div >
< / FixedSideContainer >
< aside >
< GitHubCorner / >
< / aside >
) ;
} ;
const renderFooter = ( ) = > (
< footer role = "contentinfo" >
< LanguageList
onChange = { ( lng ) = > {
@ -221,10 +207,44 @@ export const LayerUI = React.memo(
< / button >
) }
< / footer >
) ;
return isMobile ? (
< MobileMenu
appState = { appState }
elements = { elements }
actionManager = { actionManager }
exportButton = { renderExportDialog ( ) }
setAppState = { setAppState }
onUsernameChange = { onUsernameChange }
onRoomCreate = { onRoomCreate }
onRoomDestroy = { onRoomDestroy }
onLockToggle = { onLockToggle }
/ >
) : (
< >
{ appState . isLoading && < LoadingMessage / > }
{ appState . errorMessage && (
< ErrorDialog
message = { appState . errorMessage }
onClose = { ( ) = > setAppState ( { errorMessage : null } ) }
/ >
) }
{ appState . showShortcutsDialog && (
< ShortcutsDialog
onClose = { ( ) = > setAppState ( { showShortcutsDialog : null } ) }
/ >
) }
{ renderFixedSideContainer ( ) }
< aside >
< GitHubCorner / >
< / aside >
{ renderFooter ( ) }
< / >
) ;
} ,
( prev , next ) = > {
} ;
const areEqual = ( prev : LayerUIProps , next : LayerUIProps ) = > {
const getNecessaryObj = ( appState : AppState ) : Partial < AppState > = > {
const {
draggingElement ,
@ -247,5 +267,6 @@ export const LayerUI = React.memo(
prev . elements === next . elements &&
keys . every ( ( key ) = > prevAppState [ key ] === nextAppState [ key ] )
) ;
} ,
) ;
} ;
export default React . memo ( LayerUI , areEqual ) ;