Skip to content

Commit

Permalink
wip: initial relation pane styling
Browse files Browse the repository at this point in the history
Signed-off-by: Alex <[email protected]>
  • Loading branch information
aematei committed May 25, 2024
1 parent 13f20d6 commit b496ca0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
20 changes: 8 additions & 12 deletions view/src/components/Diagram/Diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -661,20 +661,16 @@ function Diagram({
/>
<Panel position="top-left" className="flow-panel">
<InsertPanel>
<InstancePane>
<InsertPane label="Instance">
{insertItems.map((item) => {
return <InstanceItem label={item}/>
})}
</InstancePane>
<InstancePane>
<ul>
<li>Test</li>
<li>Test</li>
<li>Test</li>
<li>Test</li>
<li>Test</li>
</ul>
</InstancePane>
</InsertPane>
<InsertPane label="Relation">
{insertItems.map((item) => {
return <RelationItem label={item}/>
})}
</InsertPane>
</InsertPanel>
</Panel>
<Background gap={12} size={1} />
Expand Down
29 changes: 24 additions & 5 deletions view/src/components/Diagram/InsertPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,41 @@ export const InstanceItem: React.FC<InsertItemProps> = ({ label, style }) => {
}, []);

return (
<div className="flex flex-row items-center bg-opacity-0">
<div className="flex flex-row items-center">
<div className="relative left-[1px] z-10 h-2 w-2 border-[1px] rounded-full bg-black border-white "></div>
<div className="flex flex-none justify-center items-center rounded h-11 w-24 bg-[#ff0000] z-0 " ref={ref}>
<span className="text-center text-nowrap text-white">{label}</span>
<span className="text-center text-nowrap text-white text-[12px]">{label}</span>
</div>
<div className="relative right-[1px] z-10 h-2 w-2 border-[1px] rounded-full bg-black border-white"></div>
</div>
);
};

export const InstancePane: React.FC<any> = ({ children }) => {
export const RelationItem: React.FC<InsertItemProps> = ({ 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 (
<div className="flex flex-row justify-between bg-clip-text w-24" ref={ref}>
<span className="text-center text-nowrap text-white text-[12px]">{label}</span>
<span className="codicon codicon-arrow-right mr-2 text-[14px]"/>
</div>
);
};

export const InsertPane: React.FC<any> = ({ 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 (
<div className="p-2 rounded shadow-md bg-white/5 h-36">
<span className="font-bold">{"Instance"}</span>
<span className="font-bold">{label}</span>
<div className="flex flex-col h-28 items-center space-y-2 overflow-y-auto">
{children}
</div>
Expand Down

0 comments on commit b496ca0

Please sign in to comment.