From fc33f0c04e603484ac879da74354521cf6f7d041 Mon Sep 17 00:00:00 2001 From: havn Date: Tue, 21 May 2024 13:13:30 +0200 Subject: [PATCH] feat: added minimap to bottom left. Moved tutorial button to the right in accordance with design. fixed ts errors in affected files --- components/CanvasButtons.tsx | 2 ++ components/canvas/Canvas.tsx | 23 ++++++++------ .../canvas/CanvasTutorial/CanvasTutorial.tsx | 14 ++++----- components/canvas/MiniMapCustom.tsx | 31 +++++++++++++++++++ 4 files changed, 53 insertions(+), 17 deletions(-) create mode 100644 components/canvas/MiniMapCustom.tsx diff --git a/components/CanvasButtons.tsx b/components/CanvasButtons.tsx index 79d825f3..3bfa8a46 100644 --- a/components/CanvasButtons.tsx +++ b/components/CanvasButtons.tsx @@ -1,6 +1,7 @@ import { CategorizationPageButton } from "./CategorizationPageButton"; import styles from "./CanvasButtons.module.scss"; import { ManageLabelsButton } from "./Labels/ManageLabelsButton"; +import { CanvasTutorial } from "@/components/canvas/CanvasTutorial/CanvasTutorial"; type CanvasButtonsProps = { handleClickLabel: () => void; @@ -14,5 +15,6 @@ export const CanvasButtons = ({
{userCanEdit && } +
); diff --git a/components/canvas/Canvas.tsx b/components/canvas/Canvas.tsx index 7fbdd6f3..2d709655 100644 --- a/components/canvas/Canvas.tsx +++ b/components/canvas/Canvas.tsx @@ -15,13 +15,12 @@ import { NodeDataFull } from "types/NodeData"; import { NodeDataApi } from "types/NodeDataApi"; import { NodeTypes } from "types/NodeTypes"; import { Project } from "types/Project"; -import { Graph } from "../../types/Graph"; -import { uid } from "../../utils/uuid"; +import { Graph } from "@/types/Graph"; +import { uid } from "@/utils/uuid"; import { DeleteNodeDialog } from "../DeleteNodeDialog"; import { LiveIndicator } from "../LiveIndicator"; import { SideBar } from "../SideBar"; import styles from "./Canvas.module.scss"; -import { CanvasTutorial } from "./CanvasTutorial/CanvasTutorial"; import { nodeElementTypes } from "./NodeElementTypes"; import { OldFlytButton } from "./OldFlytButton"; import { ToBeToggle } from "./ToBeToggle"; @@ -33,7 +32,8 @@ import { useNodeDrag } from "./hooks/useNodeDrag"; import { useNodeMerge } from "./hooks/useNodeMerge"; import { useWebSocket } from "./hooks/useWebSocket"; import { getQIPRContainerWidth } from "./utils/getQIPRContainerWidth"; -import { useProjectId } from "../../hooks/useProjectId"; +import { useProjectId } from "@/hooks/useProjectId"; +import { MiniMapCustom } from "@/components/canvas/MiniMapCustom"; type CanvasProps = { graph: Graph; @@ -167,8 +167,8 @@ const Canvas = ({ (node) => node.id === parentNodeId ); if ( - tempParentNode && depthDeepestNode && + tempParentNode?.data.depth && tempParentNode.data.depth < depthDeepestNode ) { tempEdges = tempEdges.filter( @@ -232,7 +232,10 @@ const Canvas = ({ if (mergedNodesLooping.has(nodeId)) { const nodeDuplicate = mergedNodesLooping.get(nodeId)![0]; const loopCount = mergedNodesLooping.get(nodeId)![1]; - if (nodeDuplicate?.data?.depth <= parentDepth) { + if ( + nodeDuplicate.data.depth && + nodeDuplicate.data.depth <= parentDepth + ) { nodeDuplicate.data.depth = parentDepth + 1; } mergedNodesLooping.set(nodeId, [nodeDuplicate, loopCount + 1]); @@ -247,7 +250,7 @@ const Canvas = ({ } else { data.depth = parentDepth + 1; data?.children?.forEach((child) => { - setSingleNodeDepth(child, data.depth); + if (data.depth) setSingleNodeDepth(child, data.depth); }); } }; @@ -262,7 +265,7 @@ const Canvas = ({ mergedNodesReady = []; dupeMergedNodesReady.forEach((node) => { node.data.children.forEach((child) => { - setSingleNodeDepth(child, node.data.depth); + if (node.data.depth) setSingleNodeDepth(child, node.data.depth); }); }); } @@ -309,7 +312,7 @@ const Canvas = ({ + - {createdBeforeSecondMajorRelease && ( )} diff --git a/components/canvas/CanvasTutorial/CanvasTutorial.tsx b/components/canvas/CanvasTutorial/CanvasTutorial.tsx index 2276a7c9..1fad93f0 100644 --- a/components/canvas/CanvasTutorial/CanvasTutorial.tsx +++ b/components/canvas/CanvasTutorial/CanvasTutorial.tsx @@ -1,5 +1,5 @@ import { Button, Dialog, Icon } from "@equinor/eds-core-react"; -import { close } from "@equinor/eds-icons"; +import { help_outline, close } from "@equinor/eds-icons"; import addNewMainActivity from "../../../public/CanvasTutorial/add-new-main-activity.gif"; import addNewSubActivity from "../../../public/CanvasTutorial/add-new-sub-activity.gif"; import addNewChoice from "../../../public/CanvasTutorial/add-new-choice.gif"; @@ -15,6 +15,7 @@ import { CanvasTutorialButtonGroup } from "./CanvasTutorialButtonGroup"; import { CanvasTutorialSection } from "./CanvasTutorialSection"; import { InlineImage } from "./InlineImage"; import { useCanvasTutorial } from "./hooks/useCanvasTutorial"; +import { ButtonWrapper } from "@/components/ButtonWrapper"; const title = "Tutorial"; @@ -24,13 +25,12 @@ export const CanvasTutorial = () => { return ( <> - + aria-haspopup="dialog" + /> { + switch (node.type) { + case NodeTypes.mainActivity: + return colors.NODE_MAINACTIVITY; + case NodeTypes.subActivity: + return colors.NODE_SUBACTIVITY; + case NodeTypes.choice: + return colors.NODE_CHOICE; + case NodeTypes.waiting: + return colors.NODE_WAITING; + default: + return colors.NODE_GENERIC; + } + }; + + return ( + + ); +}