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

@rocketsquirrelio/nav

v1.0.1

Published

An accessible, responsive navigation component for WordPress.

Downloads

4

Readme

Nav Component

This is a reworking of 10up's Navigation Component for WordPress development. The notable change is using Dart Sass to be the primary CSS preprocessor. The benefit of this is the ability to use the latest language features which enables the CSS to be highly customizable. The departures from the original component are noted in Specific Changes.

npm install @rocketsquirrelio/nav

Markup

This is the markup template expected by the component.

<nav class="site-navigation" role="navigation" itemscope="itemscope" itemtype="http://schema.org/SiteNavigationElement">

   <a href="#primary-nav" aria-controls="primary-nav">
   	<span class="screen-reader-text">Primary Menu</span>
   	<span aria-hidden="true">☰</span>
   </a>

   <?php
   	wp_nav_menu( array(
   		'theme_location' => 'primary',
   		'menu_class'     => 'primary-menu',
   		'menu_id'        => 'primary-nav',
   		) );
   ?>

</nav>

Sass Component

The most basic usage is to simply include the component into the stylesheet.

@use '@rocketsquirrelio/nav';

Dropdown Mixin

The dropdown mixin allows full customization at the point of implementation to customize the specific pseudo-element (:after).

@include nav.dropdown-icon {
    content: '+';
    display: inline-block;
    font-weight: 700;
    margin-left: .25em;
}

Advanced Usage

This version takes advantage of the latest language features in Dart Sass. Override the default media query and dropdown selector for the Dropdown Mixin.

// => style.scss
@use '@rocketsquirrelio/nav' with (
	$menu-class: 'primary-menu',
    $media-query: '(min-width: 48em)',
    $dropdown-selector: '.menu-item-has-children > a:after',
);

| Variable | Default Value | Description | |:---------|:--------------|:------------| |$media-query|min-width: 48em|The breakpoint when the menu should switch to the mobile version. This should match the media query passed in the JavaScript component.| |$dropdown-selector|.menu-item-has-children > a:after|The full selector to target placing an icon.|

JavaScript Component

Incorporate the component directly into a JavaScript build process.

Example Usage

import Nav from '@rocketsquirrelio/nav';

new Nav( '#primary-nav', {
    action: 'click',
    breakpoint: '(min-width: 48em)',
	onCreate: function() {
		console.log( 'onCreate callback' );
	},
	onOpen: function() {
		console.log( 'onOpen callback' );
	},
	onClose: function() {
		console.log( 'onClose callback' );
	},
	onSubmenuOpen: function() {
		console.log( 'onSubmenuOpen callback' );
	},
	onSubmenuClose: function() {
		console.log( 'onSubmenuClose callback' );
	}
} );

Specific Changes

Any changes from the original component have been noted below.

CSS Changes

There was one opinionated, non-structural line of CSS removed. The margin-right rule applied to .menu-item was removed to create a more raw template for development. This rule was likely implemented for accessibility, but it is easier to handle this at the point of implementation. (source)

Implementation Changes

This version removes mutation of the global window object and does not ship with a dist/ folder. It cannot be used as a standalone implementation.