Skip to content

Commit

Permalink
feat: add drawing canvas loading overlay
Browse files Browse the repository at this point in the history
  • Loading branch information
gkuzin13 committed Dec 10, 2023
1 parent 8708eb9 commit e5f0c49
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions apps/client/src/components/Layout/MainLayout/MainLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type Konva from 'konva';
import { useCallback, useRef, useState } from 'react';
import DrawingCanvas from '@/components/Canvas/DrawingCanvas/DrawingCanvas';
import { Suspense, lazy, useCallback, useRef, useState } from 'react';
import {
getIntersectingNodes,
getLayerNodes,
Expand All @@ -23,6 +22,11 @@ import {
import usePageMutation from '@/hooks/usePageMutation';
import { useWebSocket } from '@/contexts/websocket';
import useAutoFocus from '@/hooks/useAutoFocus/useAutoFocus';
import Loader from '@/components/Elements/Loader/Loader';

const DrawingCanvas = lazy(
() => import('@/components/Canvas/DrawingCanvas/DrawingCanvas'),
);

const MainLayout = () => {
const [selectedNodesIds, setSelectedNodesIds] = useState<string[]>([]);
Expand Down Expand Up @@ -168,11 +172,13 @@ const MainLayout = () => {
<Panels stageRef={stageRef} selectedNodesIds={selectedNodesIds} />
<ContextMenu.Root onContextMenuOpen={handleContextMenuOpen}>
<ContextMenu.Trigger>
<DrawingCanvas
ref={stageRef}
size={windowSize}
onNodesSelect={handleNodesSelect}
/>
<Suspense fallback={<Loader fullScreen>Loading Assets...</Loader>}>
<DrawingCanvas
ref={stageRef}
size={windowSize}
onNodesSelect={handleNodesSelect}
/>
</Suspense>
</ContextMenu.Trigger>
</ContextMenu.Root>
</Styled.Container>
Expand Down

0 comments on commit e5f0c49

Please sign in to comment.