From b496ca04a65330891e91dbe3f9b34dd765c9e78a Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 25 May 2024 13:14:04 -0700 Subject: [PATCH] wip: initial relation pane styling Signed-off-by: Alex --- view/src/components/Diagram/Diagram.tsx | 20 ++++++-------- view/src/components/Diagram/InsertPanel.tsx | 29 +++++++++++++++++---- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/view/src/components/Diagram/Diagram.tsx b/view/src/components/Diagram/Diagram.tsx index 642e1e1..f6b82eb 100644 --- a/view/src/components/Diagram/Diagram.tsx +++ b/view/src/components/Diagram/Diagram.tsx @@ -25,7 +25,7 @@ import ReactFlow, { getConnectedEdges, } from "reactflow"; -import { InsertPanel, InstancePane, InstanceItem } from "./InsertPanel"; +import { InsertPanel, InsertPane, InstanceItem, RelationItem } from "./InsertPanel"; // Icons import { IconDownload } from "@nasa-jpl/react-stellar"; @@ -661,20 +661,16 @@ function Diagram({ /> - + {insertItems.map((item) => { return })} - - -
    -
  • Test
  • -
  • Test
  • -
  • Test
  • -
  • Test
  • -
  • Test
  • -
-
+ + + {insertItems.map((item) => { + return + })} +
diff --git a/view/src/components/Diagram/InsertPanel.tsx b/view/src/components/Diagram/InsertPanel.tsx index 1d5a302..31935f9 100644 --- a/view/src/components/Diagram/InsertPanel.tsx +++ b/view/src/components/Diagram/InsertPanel.tsx @@ -31,22 +31,41 @@ export const InstanceItem: React.FC = ({ label, style }) => { }, []); return ( -
+
- {label} + {label}
); }; -export const InstancePane: React.FC = ({ children }) => { +export const RelationItem: React.FC = ({ label, style }) => { + // TODO: handle onDrag Look at react-beautiful-dnd + // TODO: handle cloning object after dragging + // TODO: handle dropping object after letting go of the mouse + const ref = useRef(null); + + useEffect(() => { + const el = ref.current; + invariant(el); + return draggable({element: el}); + }, []); + + return ( +
+ {label} + +
+ ); +}; + +export const InsertPane: React.FC = ({ label, children }) => { // Refer to http://www.opencaesar.io/oml-tutorials/#tutorial1-create-oml-vocabulary - // h-24 pl-2 flex flex-col items-center space-y-2 overflow-y-auto max-h-[9rem] z-10 return (
- {"Instance"} + {label}
{children}