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

@thednp/navbar

v3.3.0

Published

🧭 Navbar Modern Navigation Component

Downloads

104

Readme

Navbar - Modern Navigation Component

Coverage Status ci NPM Version NPM Downloads jsDeliver typescript version vitest version vite version

The mobile first menu navigation for today's modern web, sourced with Typescript and packed with lots of features.

Demo

Download the package and check the docs folder, or check it online here.

Navbar Highlights

  • Mobile First Design
  • Accessibility Focus
  • TypeScript sourced and powerful build tools
  • SCSS sources with flexible mixins and CSS variables
  • very light footprint, 5kb in size when minified
  • 3 sets of positions top (main), left or right
  • provides a set of options for JavaScript initialization
  • DATA API allows you to automatically initiate without JS invocation
  • modern browsers supported

How It Works

On mobile

  • uses the native events behavior, it requires some elements to click on
  • shows the <button class="navbar-toggle"> element for element visibility toggle
  • menu items have a <button class="subnav-toggle"> element that enables visibility of the submenus
  • makes use of the open-mobile class to toggle submenus via the click handler

On the desktop

  • hides mobile specific elements and changes event behavior to mouse hover
  • opens submenus on mouseenter, by adding open and open-position classes to the menu item, in rapid succession
  • hides submenus on mouseleave, by removing the above classes in a delayed succesion

On both mobile and desktop, Navbar.js allows for full keyboard navigation via the TAB and SPACE keys. In addition, directional arrows provide navigation on desktop with RTL support.

Install

pnpm install -D @thednp/navbar
yarn add -D @thednp/navbar
npm install -D @thednp/navbar
deno add -D npm:@thednp/navbar@latest

Browser Usage

Download the latest package. unpack and inspect the contents. You need to copy the navbar.js and navbar.css or their minified variations to your app assets folders as follows. Link the required CSS in your document <head> tag

<link href="../assets/css/navbar.css" rel="stylesheet">

Link the required JS in your document <body> tag, though it should work in the <head> as well

<script src="../assets/js/navbar.js"></script>

Initiate the function for your elements at the end of your <body> tag

<script>
var myMenu = new Navbar('selector');
</script>

To use the DATA-API, you need to provide the data-function="navbar" attribute to your navbar, like so:

<nav class="navbar" data-function="navbar">
  <a href="#" title="App Name">Brand Name</a>
  <button class="navbar-toggle">
    <i class="menu-icon"></i>
  </button>
  <div>
    <ul class="nav">
      <li><a href="#">Link Title</a></li>
      <li><a href="#">Another Link Title</a></li>
    </ul>
  </div>
</nav>

Alternatively you can use only the menu itself and use the specific attribute:

<div class="sidebar">
  <ul class="nav" data-function="navbar">
    <li><a href="#">Link Title</a></li>
    <li><a href="#">Another Link</a></li>
  </ul>
</div>

Other initialization and markup options apply, explained in the demo.

Typescript / ES

import Navbar from '@thednp/navbar'

const myNav = new Navbar('#myNav')

License

Navbar is released under MIT License.