This roadmap is currently empty.
@@ -18,9 +20,9 @@ export function EmptyRoadmap(props: EmptyRoadmapProps) {
{canManage && (
-
+
Edit Roadmap
)}
diff --git a/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx b/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx
index 48a2993dd..a5ef54be9 100644
--- a/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx
+++ b/src/components/CustomRoadmap/FlowRoadmapRenderer.tsx
@@ -10,13 +10,15 @@ import {
import { pageProgressMessage } from '../../stores/page';
import { useToast } from '../../hooks/use-toast';
import type { Node } from 'reactflow';
-import { useCallback, type MouseEvent, useMemo } from 'react';
+import { useCallback, type MouseEvent, useMemo, useState, useRef } from 'react';
import {
INITIAL_DESKTOP_ZOOM,
INITIAL_MOBILE_ZOOM,
calculateDimensions,
} from '../../../editor/utils/roadmap';
import { isMobile } from '../../../editor/utils/is-mobile';
+import { EmptyRoadmap } from './EmptyRoadmap';
+import { cn } from '../../lib/classname';
type FlowRoadmapRendererProps = {
roadmap: RoadmapDocument;
@@ -26,6 +28,9 @@ export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) {
const { roadmap } = props;
const roadmapId = String(roadmap._id!);
+ const [hideRenderer, setHideRenderer] = useState(false);
+ const editorWrapperRef = useRef
(null);
+
const initialZoom = useMemo(
() => (isMobile() ? INITIAL_MOBILE_ZOOM : INITIAL_DESKTOP_ZOOM),
[]
@@ -134,23 +139,44 @@ export function FlowRoadmapRenderer(props: FlowRoadmapRendererProps) {
}, []);
return (
- {
- renderResourceProgress('roadmap', roadmapId).then(() => {});
- }}
- onTopicClick={handleTopicClick}
- onTopicRightClick={handleTopicRightClick}
- onTopicShiftClick={handleTopicShiftClick}
- onTopicAltClick={handleTopicAltClick}
- onButtonNodeClick={handleLinkClick}
- onLinkClick={handleLinkClick}
- fontFamily="Balsamiq Sans"
- fontURL="/fonts/balsamiq.woff2"
- />
+ <>
+ {hideRenderer && (
+
+ )}
+ {
+ renderResourceProgress('roadmap', roadmapId).then(() => {
+ if (roadmap?.nodes?.length === 0) {
+ setHideRenderer(true);
+ editorWrapperRef?.current?.classList.add('hidden');
+ }
+ });
+ }}
+ onTopicClick={handleTopicClick}
+ onTopicRightClick={handleTopicRightClick}
+ onTopicShiftClick={handleTopicShiftClick}
+ onTopicAltClick={handleTopicAltClick}
+ onButtonNodeClick={handleLinkClick}
+ onLinkClick={handleLinkClick}
+ fontFamily="Balsamiq Sans"
+ fontURL="/fonts/balsamiq.woff2"
+ />
+ >
);
}