Code Monkey home page Code Monkey logo

drawerr's Introduction

Drawerr

npm version

Drawerr is a mobile menu component that's simple and has no dependency on jQuery. It easily slides in with css animations(good for performance) when the hamburger button is clicked. Drawerr supports multi-level navigation so it's not hiding menu items( good for UX ).

image

Features

  • Multilevel support
  • Slide direction( left or right )
  • CSS animations( good for performance )
  • Hamburger included
  • Vanilla js, no jQuery
  • Overridable sass variables
  • browser support

Browser support

Tested on real browsers with BrowserStack.

IE11 and below

Use a service like polyfill.io

logo-01 1

Install via yarn & npm

npm install drawerr --save

yarn add drawerr

Usage

Required files

drawerr/
└── dist/
    └── drawerr.css
    └── drawerr.js

Include CSS file inside the

<link rel="stylesheet" href="dist/drawerr.css">

Include JS file before the closing body tag

<script src="dist/drawerr.js"></script>

Hamburger HTML

<button class="toggleDrawer">
    <span></span>
    <span></span>
    <span></span>
</button>

Drawerr HTML

Basic html is as follows:

<nav id="drawer" class="drawerr--init">
    <ul>
        <li>
            <span class="section-title active">Gezus</span>
            <ul>
                <li>
                    <a class="active" href="#">rebum</a>
                    <ul>
                        <li><a class="active" href="#">case novum</a></li>
                        <li><a href="#">iisque</a></li>
                    </ul>
                </li>
                <li><a href="#">vix purto</a></li>
            </ul>
        </li>

        <li>
            <span class="section-title">quodsi</span>
            <ul>
                <li><a href="#">nullam</a></li>
                <li>
                    <a href="#">corpora philosophia</a>
                    <ul>
                        <li>
                            <a href="#">mallan</a>
                        </li>
                        <li>
                            <a href="#">rebum</a>
                            <ul>
                                <li><a href="#">case novum</a></li>
                                <li>
                                    <a href="#">iqtario</a>
                                    <ul>
                                        <li><a href="#">faari</a></li>
                                        <li><a href="#">elissee</a></li>
                                    </ul>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>
<nav>

Drawerr JS

new drawerr().init(args);

Options

drawerr

Drawerr container selector

default: #drawerr

toggleBtn

Btn selector which contains the hamburger

default: .toggleBtn

btnText

Menu text under the hamburger

default MENU

navbar

Navbar selector to determine the offset height for drawerr to slide in

default: header

slideFrom

Direction where drawerr comes from

default:left

Events

Drawerr fires off events when it opens (drawerr-open) or closes (drawerr-close) the menu.

document.addEventListener('drawerr-open', function(){
    // do something
});

NOTE: the active class should be rendered or set via backend

Plans for the future

  • Testing with browserstack
  • More options based on the needs

drawerr's People

Contributors

ferdiesletering avatar melvinkoopmans avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.