JSFiddle - React, Tailwind, and code Playground

by Adrian Babb

HTML

<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<ul id="icon_menu">
  <li class="draggable"></li>
</ul>
<div class="droppable"></div>

CSS

#icon_menu {
  width: 200px;
  height: auto;
  float: right;
}

#icon_menu li {
  width: 45px;
  height: 45px;
  float: left;
}

.draggable {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: rgba(127, 214, 236, 0.5);
}

.droppable {
  width: 200px;
  height: 100px;
  border: 1px solid #000000;
  float: left;
}

.draggable.ui-resizable:after {
  content: "?";
  position: absolute;
  top: -5px;
  right: -5px;
  font-size: .7em;
  background-color: #5f6a72;
  color: #ffffff;
  width: 20px;
  height: 20px;
  text-align: center;
  line-height: 20px;
  border-radius: 50%;
}

JavaScript

$(document).ready(function($) {

  $(".droppable").droppable({
    accept: '.draggable',
    drop: function(event, ui) {
      var $clone = ui.helper.clone();
      if (!$clone.is('.inside-droppable')) {
        $(this).append($clone.addClass('inside-droppable').draggable({
          containment: '.droppable',
          scroll: false,
          tolerance: 'pointer',
          position: 'relative',
        }));

        $clone.resizable({
          aspectRatio: 'true',
          ghost: 'true',
          handles: 'ne, nw, se, sw',
          maxHeight: 200,
          maxWidth: 200,
          minHeight: 30,
          minWidth: 30
        });
      }
    }
  });
  $(".draggable").draggable({
    helper: 'clone',
    revert: "invalid",
    scroll: false
  });
});