From a45414240c7ec52ea6f3372cb815cf197703371e Mon Sep 17 00:00:00 2001 From: florianbgt Date: Wed, 15 Jan 2025 12:29:51 +0100 Subject: [PATCH] change layout --- .../components/FileExplorer/FileExplorer.tsx | 91 ++++++++++---- .../src/components/FileExplorer/Skeleton.tsx | 15 +++ .../SplitConfigureTree/SplitConfigureTree.tsx | 18 ++- packages/app/src/layout/ReactFlow.tsx | 111 +++--------------- .../app/src/pages/splitConfigure/index.tsx | 2 +- packages/app/src/pages/visualizer.tsx | 3 +- packages/app/src/pages/visualizer/index.tsx | 17 ++- 7 files changed, 131 insertions(+), 126 deletions(-) create mode 100644 packages/app/src/components/FileExplorer/Skeleton.tsx diff --git a/packages/app/src/components/FileExplorer/FileExplorer.tsx b/packages/app/src/components/FileExplorer/FileExplorer.tsx index f8c4b50..905f0b7 100644 --- a/packages/app/src/components/FileExplorer/FileExplorer.tsx +++ b/packages/app/src/components/FileExplorer/FileExplorer.tsx @@ -1,6 +1,7 @@ -import { Button, TextField, Tooltip } from "@radix-ui/themes"; +import { Button, ScrollArea, TextField, Tooltip } from "@radix-ui/themes"; import { useEffect, useState } from "react"; import { Link, useParams } from "react-router"; +import { FileExplorerSkeleton } from "./Skeleton"; interface FileProp { path: string; @@ -13,11 +14,13 @@ interface TreeData { } export default function FileExplorer(props: { + busy: boolean; files: FileProp[]; focusedId?: string; onNodeFocus: (id: string) => void; onNodeUnfocus: (id: string) => void; }) { + const [isOpen, setIsOpen] = useState(true); const [search, setSearch] = useState(""); const [treeData, setTreeData] = useState([]); @@ -115,34 +118,76 @@ export default function FileExplorer(props: { }, [props.files, search]); return ( -
- setSearch(e.target.value)} - > - +
+
+ +
+ +
+ {props.busy ? ( + + ) : ( + <> + setSearch(e.target.value)} + className={`transition-all duration-300 overflow-hidden ${!isOpen && "w-0"}`} + > + + + + + + + + + + + )} +
); } diff --git a/packages/app/src/components/FileExplorer/Skeleton.tsx b/packages/app/src/components/FileExplorer/Skeleton.tsx new file mode 100644 index 0000000..ecaba2d --- /dev/null +++ b/packages/app/src/components/FileExplorer/Skeleton.tsx @@ -0,0 +1,15 @@ +import { Skeleton } from "@radix-ui/themes"; + +export function FileExplorerSkeleton() { + return ( +
+ + + + + + + +
+ ); +} diff --git a/packages/app/src/components/ReactFlow/SplitConfigureTree/SplitConfigureTree.tsx b/packages/app/src/components/ReactFlow/SplitConfigureTree/SplitConfigureTree.tsx index 42b443a..7629fcb 100644 --- a/packages/app/src/components/ReactFlow/SplitConfigureTree/SplitConfigureTree.tsx +++ b/packages/app/src/components/ReactFlow/SplitConfigureTree/SplitConfigureTree.tsx @@ -17,8 +17,10 @@ import GroupNode from "./GroupNode"; import EndpointNode from "./EndpointNode"; import SmoothEdge from "../SmoothEdge"; import Controls from "../Controls"; +import { ReactFlowSkeleton } from "../Skeleton"; export default function SplitConfigureTree(props: { + loading: boolean; busy: boolean; endpoints: Endpoint[]; isOutOfSynced: boolean; @@ -190,11 +192,15 @@ export default function SplitConfigureTree(props: { } useEffect(() => { - const element = document.querySelector(".react-flow__panel") as HTMLElement; - if (element) { - element.style.display = "none"; + if (!props.loading) { + const element = document.querySelector( + ".react-flow__panel", + ) as HTMLElement; + if (element) { + element.style.display = "none"; + } } - }, []); + }, [props.loading]); function onNodeDragStart(_event: React.MouseEvent, node: Node) { setNodes((nds) => @@ -216,6 +222,10 @@ export default function SplitConfigureTree(props: { ); } + if (props.loading) { + return ; + } + return ( (null); - // Set to 0px initially, and then update it to the actual height with the useEffect - const [height, setHeight] = useState("0px"); - - useEffect(() => { - if (containerRef.current) { - const { height: computedHeight } = window.getComputedStyle( - containerRef.current, - ); - setHeight(computedHeight); - } - }, []); - - const [isCollapsed, setIsCollapsed] = useState(false); - - const toggleSidebar = () => { - setIsCollapsed(!isCollapsed); - }; - return ( -
- -
-
-
-
+
+ {props.sideBarSlot && ( +
+ {props.sideBarSlot} +
+ )} +
+
+ + logo + NanoAPI + +
- {props.busy ? ( - - ) : ( - <> - {props.sideBarSlot && ( -
component must be wrapped in an element with a width and height." - style={{ height }} - > - - {props.sideBarSlot} -
- )} - {props.chartSlot} - - )} + {props.chartSlot}
diff --git a/packages/app/src/pages/splitConfigure/index.tsx b/packages/app/src/pages/splitConfigure/index.tsx index 66f0f62..9e68885 100644 --- a/packages/app/src/pages/splitConfigure/index.tsx +++ b/packages/app/src/pages/splitConfigure/index.tsx @@ -95,9 +95,9 @@ export default function SplitConfigure() { return ( } sideBarSlot={ ("TB"); useEffect(() => { - const element = document.querySelector(".react-flow__panel") as HTMLElement; - if (element) { - element.style.display = "none"; + if (!context.busy) { + const element = document.querySelector( + ".react-flow__panel", + ) as HTMLElement; + if (element) { + element.style.display = "none"; + } } - }, []); + }, [context.busy]); useEffect(() => { computeNodesAndEdgesFromFiles(context.files); @@ -172,6 +177,10 @@ export default function Visualizer() { context.onNodeUnfocus(); } + if (context.busy) { + return ; + } + return (