JSFiddle - React, Tailwind, and code Playground

by nithyanandam venu

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://troolee.github.io/gridstack.js/dist/gridstack.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.0/jquery-ui.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.5.0/lodash.min.js"></script>
<script src="https://troolee.github.io/gridstack.js/dist/gridstack.js"></script>
<script src="https://troolee.github.io/gridstack.js/dist/gridstack.jQueryUI.js"></script>
 <div class="container-fluid">
        <h1>Float grid demo</h1>

        <div>
            <a class="btn btn-default" id="add-new-widget" href="#">Add Widget</a>
        </div>

        <br/>

        <div class="grid-stack">
        </div>
    </div>

CSS

.grid-stack {
    background: lightgoldenrodyellow;
    min-height:250px;
}

.grid-stack-item-content {
    color: #2c3e50;
    text-align: center;
    background-color: #18bc9c;
}

JavaScript

$(function () {
            var options = {
                float: true
            };
            $('.grid-stack').gridstack(options);

            new function () {
                this.items = [
                    {x: 0, y: 0, width: 2, height: 2},
                    {x: 3, y: 1, width: 1, height: 2},
                    {x: 4, y: 1, width: 1, height: 1},
                    {x: 2, y: 3, width: 3, height: 1},
//                    {x: 1, y: 4, width: 1, height: 1},
//                    {x: 1, y: 3, width: 1, height: 1},
//                    {x: 2, y: 4, width: 1, height: 1},
                    {x: 0, y: 0, width: 1, height: 1}
                ];

                this.grid = $('.grid-stack').data('gridstack');

                this.addNewWidget = function () {
                    var node = this.items.pop() || {
                                x: 1,
                                y: 1 ,
                                width: 1 + 3 * Math.random(),
                                height: 1 + 3 * Math.random()
                            };
                    this.grid.addWidget($('<div><div class="grid-stack-item-content" /><div/>'),
                        node.x, node.y, node.width, node.height);
                    return false;
                }.bind(this);

                $('#add-new-widget').click(this.addNewWidget);
            };
        });