JSFiddle - React, Tailwind, and code Playground

by tonyleeper

HTML

<nav class="menu">
    <ul>
        <li>Home</li>
        <li>Page 1</li>
        <li>Page 2</li>
    </ul>
</nav>
<section class="content">
    <article class="application-bar">
        <button class="menu-toggle">|||</button>
    </article>
    <article class="inner-content">
        Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum quo dolor ipsam repellat provident minus esse at autem ratione quos quod a laborum aperiam reiciendis dicta optio vitae minima non.
    </article>
</section>

CSS

html, body {
    font-family: arial;
    height: 100%;
    padding: 0;
    margin: 0;
}

.menu {
    cursor: default;
    height: 100%;
    position: fixed;
    z-index: 0;
    background-color: #454b53;
    color: #fff;
    width: 200px;
}

.menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.menu ul li {
    padding: 15px;
}

.menu ul li:hover {
    background-color: #576172;
}

.application-bar {
    height: 31px;
    background-color: #454b53;
}

.menu-toggle {
    outline: 0;
    margin: 0;
    background-color: #454b53;
    color: white;
    border: 0;
    font-size: 19px;
    padding: 0px 0px 3px 0px;
    height: 30px;
    width : 30px;
    overflow: hidden;
    transform: rotateZ(90deg);
}

.content {
    height: 100%;
    width: 100%;
    position: fixed;
    z-index: 1;
    background-color: #5f6570;
    box-shadow: black 0 0 15px;
    transition: transform .5s;
    box-sizing: border-box;
}

.content.show-menu {
    transform: translateX(200px);
}

.content.show-menu .menu-toggle {
    background-color: #296acc;
}



.inner-content {
    overflow: auto;
    background-color: #fff;
    border-radius: 5px;
    padding: 15px;
    margin: 15px;
    height: calc(100% - 90px);
}

JavaScript

var menuToggle = document.querySelectorAll('.menu-toggle')[0];
menuToggle.addEventListener('click', function (e) {
    document.getElementsByClassName('content')[0].classList.toggle('show-menu');
});

document.body.addEventListener('click', function (e) {
    document.getElementsByClassName('content')[0].classList.remove('show-menu');
}, true);