JSFiddle - React, Tailwind, and code Playground

by velo_ninja

HTML

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Wiring Diagram Editor</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/konva.min.js"></script>
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: Arial, sans-serif;
      display: flex;
      min-height: 100vh;
    }

    #toolbox {
      width: 200px;
      border-right: 2px solid #ccc;
      padding: 20px;
      background: #f9f9f9;
      box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    }

    .symbol {
      background: #f0f0f0;
      border: 1px solid #ccc;
      border-radius: 5px;
      margin: 10px 0;
      padding: 10px;
      cursor: pointer;
      text-align: center;
      transition: background 0.3s ease;
    }

    .symbol:hover {
      background: #e0e0e0;
    }

    #canvas-wrapper {
      flex: 1;
      height: 98vh;
      position: relative;
      border: 2px solid #333;
      margin-left: 20px;
    }

    #context-menu {
      display: none;
      position: absolute;
      background-color: #fff;
      box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
      border-radius: 5px;
      padding: 10px;
      z-index: 1000;
    }

    #context-menu ul {
      list-style-type: none;
      padding: 0;
    }

    #context-menu li {
      padding: 8px 12px;
      cursor: pointer;
      border-bottom: 1px solid #ccc;
    }

    #context-menu li:last-child {
      border-bottom: none;
    }

    #context-menu li:hover {
      background-color: #f5f5f5;
    }

    #context-menu li.active {
      background-color: #cfe2f3;
    }

    /* Adjust the cursor */
    .cursor-pointer {
      cursor: pointer;
    }
  </style>
</head>
<body>

  <!-- Toolbox (Left Sidebar) -->
  <div id="toolbox">
    <div id="addHopper" class="symbol cursor-pointer">Hopper</div>
    <div id="addControl" class="symbol cursor-pointer">Control Panel</div>
    <div...