JSFiddle - React, Tailwind, and code Playground

by someprimetime

HTML

<!DOCTYPE html>

<div id="nav-container">
    <div>Nav menu</div>
    <ul class="nav-list">
        <li><a href="#">Item 1</a></li>
        <li><a href="#">Item 2</a></li>
        <li><a href="#">Item 3</a></li>
    </ul>
    
    <ul class="stacked-menu" data-open="false">
        <li></li>
        <li></li>
        <li></li>
    </ul>
</div>



</html>

SCSS

body {
    background: #eee;
    margin: 0;
    padding: 0;
}

ul {
    list-style-type: none;
}


#nav-container {
    font-family: Helvetica, Arial, sans-serif;
    font-size: 12px;
    box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.2);
    border: 1px solid #888;
    border-top: none;
    background: #fff;
    color: #000;
    position: relative;
    left: -150px;
    float: left;
    width: 100%;
    width: 200px;
    height: 500px;
    padding: 10px;
    clear: both;
    
}

#nav-content {
    
    color: red;
    position: absolute;
}


#main-container {
    float: left;
    width: 100%;
}

.stacked-menu {
    cursor: pointer;
    position: absolute;
    left: 125px;
    top: 0;
    
    &:hover {
        li {
            background: #555;
            }
    }
}

.stacked-menu li {
    background: #ccc;
    width: 40px;
    height: 5px;
    margin-bottom: 3px;
}

JavaScript

$(function() {
    
    var $stackedMenu = $('.stacked-menu');
    
    $stackedMenu.on('click', function() {
        // Do some stuff, user clicked
        var $menu = $(this),
            $navContainer = $menu.closest('#nav-container'),
            $listElements = $menu.find('li'),
            $cachedVar = $menu.attr('data-open');
        
        // Menu is closed, open it
        if ($cachedVar === 'false') {
            // Remove the class
            $listElements.removeClass('open');
            
            // Set menu open to true
            $menu.attr('data-open', 'true');
            
            // Open menu
            $navContainer.animate({'left' : '0'});
        } else {
            $listElements.addClass('open');
            
            $menu.attr('data-open', 'false');
            
            $navContainer.animate({'left' : '-150px'});
        }
    });
    
});