diff --git a/src/App.js b/src/App.js index f3827bf..8317037 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,9 @@ import './App.css'; +import Diagram from './diagram'; function App() { return ( -

- Hello world! -

+ ); } diff --git a/src/diagram/index.jsx b/src/diagram/index.jsx new file mode 100644 index 0000000..2634373 --- /dev/null +++ b/src/diagram/index.jsx @@ -0,0 +1,44 @@ +import React, { useEffect, useRef } from "react"; +import { dia, shapes } from "jointjs"; + +function Diagram() { + const canvas = useRef(null); + + useEffect(() => { + const graph = new dia.Graph(); + + new dia.Paper({ + el: document.getElementById("canvas"), + background: { + color: "#F1F92A", + }, + model: graph, + height: window.height, + width: window.width, + gridSize: 1, + interactive: true, + }); + + const rect = new shapes.standard.Rectangle(); + rect.position(100, 100); + rect.resize(100, 40); + rect.attr({ + body: { + fill: "#7039FF", + }, + label: { + text: "hi", + fill: "white", + }, + }); + rect.addTo(graph); + }, []); + + return ( + <> +
+ + ); +} + +export default Diagram;