JSFiddle - React, Tailwind, and code Playground

by Roman Bruckner

HTML

<html>
<head>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jointjs/3.4.4/joint.css" />
</head>
<body>
      <!-- content -->
      <div id="paper"></div>

      <!-- dependencies -->
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.4.0/backbone.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jointjs/3.4.4/joint.js"></script>
    
    </body>
</html>

JavaScript

var portsIn = {
  position: {
    name: 'left'
  },
  attrs: {
    portBody: {
      fill: '#023047',
      stroke: '#023047'
    }
  },
  label: {
    position: {
      name: 'left',
      args: {
        y: 0,
        x: 16
      },

    },
    markup: [{
      tagName: 'text',
      selector: 'label',
      className: 'label-text'
    }]
  },
  markup: [{
    tagName: 'rect',
    selector: 'portBody',
    width: 25,
    attributes: {
      'fill': 'transparent'
    }
  }]
};

var portsOut = {
  position: {
    name: 'right'
  },
  attrs: {
    portBody: {
      fill: '#E6A502',
      stroke: '#023047'
    }
  },
  label: {
    position: {
      name: 'right',
      args: {
        y: 0,
        x: -15
      }
    },
    markup: [{
      tagName: 'text',
      selector: 'label',
      className: 'label-text'
    }]
  },
  markup: [{
    tagName: 'rect',
    selector: 'portBody',
    width: 25,
    attributes: {
      'fill': 'transparent'
    }

  }]
};

var componentList = [
{
    componentName: "A",
    incomingPort: ["11", "12", "13"],
    outgoingPort: [{
        srcPort: "1A",
        destPort: "21",
        destElem: "B"
      },
      {
        srcPort: "1B",
        destPort: "22",
        destElem: "B"
      },
      {
        srcPort: "1C",
        destPort: "31",
        destElem: "C"
      },
    ],
    position: {
      x: 50,
      y: 150
    },
  },
  {
    componentName: "B",
    incomingPort: ["21", "22", "23"],
    outgoingPort: [],
    position: {
      x: 300,
      y: 100
    },
  },
  {
    componentName: "C",
    incomingPort: ["31", "32", "33"],
    outgoingPort: [],
    position: {
      x: 300,
      y: 200
    },
  }
];

var graph = new joint.dia.Graph({}, {
  cellNamespace: joint.shapes
});

const paper = new joint.dia.Paper({
  el: document.getElementById('paper'),
  width: 800,
  height: 900,
  model: graph,
  defaultConnectionPoint: {
    name: 'boundary'
  },
  cellViewNamespace: joint.shapes,
  gridSize: 10,
  async: true,
 ...