npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

deepnav

v1.0.6

Published

Reusable multilevel navigation utility written in vanilla JS.

Downloads

13

Readme

DeepNav Navigation System

Created by Jacob Runge

Visit my website! Also, check out the DeepNav demo! Code on GitHub

About DeepNav

The purpose of DeepNav is to provide a flexible, multilevel, drop-in navigation system that requires minimal in-HTML markup. DeepNav supports as many levels of navigation as good taste will allow, and then some. You need only set up a couple of divs and anchors, initialize DeepNav, and you're good to go!

Features

  • As many nested levels of navigation as you dare
  • Options for click-to-open menus, hover-only menus, or top-level hovering with clickable submenus
  • Easy-to-implement responsivity
  • Easily stylable and highly customizable

How to

  1. Include deepnav.js in a script tag in your document (minfied here), or via NPM using npm install deepnav, and including it in your source code with import DeepNav from 'deepnav'.
  2. Create a navigation structure like the one shown below. This structure should include a div with an ID of your choosing. Your submenu anchors should contain a class called 'deepnav-link' and be followed by a div with the class 'sublinks'.
  3. Initialize DeepNav using new DeepNav(_yourChosenID_)
  4. DeepNav should now take over your navigation structure... but it's not looking like you want it to. Fortunately, DeepNav() takes an optional second parameter, which you can pass an object full of settings (detailed in the next section).

Customization

DeepNav takes an object full of options as it's second parameter. Those options include:

  • hoverMode: Possible values include 'all', 'top_only', or boolean false; default is false. This determines whether or not your anchors will open submenus on hover (they always respond to 'click'). 'all' signifies that all anchors will open submenus on hover (this is really a nightmare with a stacked menu); 'top_only' means that only your top-level anchors will respond to hover (you have to click on submenu anchors); false means users have to click.
  • alignSubmenus: Possible values include 'right', 'left', and 'center' (default 'center'). This affects how dropdown menus are displayed relative to the anchor when DeepNav is not in 'stacked' mode (i.e. a horizontal rather than a vertical menu). No worries--DeepNav will do its best not to let your menu go off-screen; if a menu is aligned 'left' and goes off-screen to the right, DeepNav will automatically change alignment to 'right' for that menu.
  • showContentArrows: Possible values include boolean true or false (default true). This determines whether or not DeepNav adds open/close arrows to submenus. You MUST encode your HTML with UTF-8 (meta charset='utf-8' in the document head) for this to work anywhere outside of Chrome.
  • showDefaultAnimations: Possible values include boolean true or false (default true). This determines whether or not DeepNav is allowed to animate the opening and closing of your submenus. For the most part, I think the animations are sufficient for most designs.
  • showAestheticStyling: Possible values include boolean true or false (default true). You may want to set this one to false to give you some control over the aesthetic styling, or else your navigation will come out looking like it does in the demo at the top of this page; otherwise, it is simple to override these styles if you wish to include them as a jumping off point.
  • displayMode: Possible values include 'reponsive', 'horizontal', and 'stacked'; default is 'responsive'. 'Horizontal' will leave the menu in horizontal mode (best for wide screens); 'stacked' will leave the menu in 'stacked'/vertical mode (best for mobile devices in, say, a hamburger menu). 'responsive' will adapt itself between 'stacked' and 'horizontal' based on a breakpoint. 'responsive' also plays with the navigation style when your menu is in Hover Mode, removing hover functionality while the menu is stacked.
  • breakpoint: A number value; default is 500. This defines the pixel width at which your menu changes from horizontal to stacked while in the responsive Display Mode.

You can change any of these preferences on the fly if you set up a reference to your DeepNav instance (var myNav = new DeepNav('coolId')) by altering myNav.settings.settingIWantToChange

Styling

DeepNav programmatically sets some initial styles for each instance of DeepNav that you invoke. These styles are placed at the beginning of your document head so that they can be overridden easily, but the aesthetic styles are pretty tough to override. I recommend you disable them.