JSFiddle - React, Tailwind, and code Playground

by nathan

HTML

<div id="header"></div>
<div id="panes">
    <div id="js">
        /* Enter JavaScript here */
    </div>
    <div id="tests" class="focussed">
        <div id="result-bar">
            No tests yet. Click here to add tests.
        </div>
        <div class="menu">
            <div class="scroll disabled"></div>
            <ul>
                <li class="selected">
                    Test 1
                    <span>Click to rename</span>
                </li>
                <li id="new-test">+ New test</li>
            </ul>
            <div class="scroll disabled"></div>
        </div>
        <div class="selected-test">
            
        </div>
    </div>
</div>

CSS

html, body {
    height: 600px;
    overflow: hidden;
    margin: 0;
    padding: 0;
    background-color: #cccccc;
}
#header {
    width: 100%;
    height: 50px;
    background-color: #666666;
}
#footer {
    position: absolute;
    bottom: 0;
    width: 100%;
    height: 10px;
    background-color: #666666;
}
#panes {
    width: 100%;
    height: 540px;
}
#panes>div {
    margin: 10px;
    background-color: #ffffff;
    -moz-transition: height 0.7s ease;
    -o-transition: height 0.7s ease;
    -webkit-transition: height 0.7s ease;
    transition: height 0.7s ease;
}
#panes>:not(.focussed) {
    height: 50px;
    cursor: pointer;
}
#panes>.focussed {
    height: 470px;
    cursor: auto;
}
/************** JS Pane ******************/
#js {
    padding: 5px;
    font-family: Courier New, monospace;
    font-size: 12px;
    overflow-y: hidden;
    outline-color: grey;
}
#js.focussed {
    overflow-y: scroll;
}
/************** Test Pane ******************/
#tests {
    overflow: hidden;
    display: box;
    -webkit-box-orient: horizontal;
}
#result-bar {
    margin: 10px;
    height: 30px;
    color: #ffffff;
    background-color: #999999;
    font-size: 20px;
    text-align: center;
    font-family: sans-serif;
}
#tests>.selected-test {
    background-color: #999999;
    height: 420px;
    margin-left: 150px;
}
#tests>.menu {
    height: 420px;
    background-color: #666666;
    width: 150px;
    /*position: absolute;
    top: 50px;
    left: 0;*/
}
#tests>.menu>.scroll {
    height: 20px;
}
#tests>.menu>ul {
    list-style: none;
    height: 380px;
    margin: 0;
    padding-left: 0;
}
#tests>.menu>ul>li {
    height: 40px;
    cursor: pointer;
}

#tests>.menu>ul>li>span {
    font-size: 0.6em;
    display: block;
}
#tests>.menu>ul>li.selected {
    background-color: #999999;
}

JavaScript

jQuery(function ($) {
    $('#panes>div').click(function (event) {
        if (!$(this).hasClass('focussed')) {
            $('#panes>div').toggleClass('focussed');
            event.preventDefault();
        }
    });
    $('#js').codeEditBox();
});

(function ($) {
    "use strict";

    // Use square bracket notation for Closure Compiler
    $.fn['codeEditBox'] = function (options) {
        var self = this, // so that we know what we're working with
            allowedCtrlKeys,
            otherCombinations;
        
        // Allow Ctrl + [TPAZXCVN]
        allowedCtrlKeys = [84, 80, 65, 90, 88, 67, 86, 78];

        // Make it editable
        self.attr('contenteditable', true);

        // Prevent the control key being pressed
        self.keydown(function (event) {
            if (event.ctrlKey &&
                    $.inArray(allowedCtrlKeys, event.keyCode) !== -1) {
                event.preventDefault();
            }
        });
        return self;
    };
}(jQuery));