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

tab-style-mobile-menu

v1.0.0

Published

## Description

Downloads

2

Readme

tab-style-mobile-menu

Description

This is a simple JS function that creates a tab-style menu at the top of the website when the site is accessed on mobile. It does this by reading the document for links with specific class names and converting them into a nav-bar.

GitHub Repository

Live Preview Example

How to use

Without NPM

  • Download the file here and include the following <script> tag in the head of your html document.

  • <script src='path/to/file/main.js' defer>

  • Then for the links you want to have displayed as tabs add the class name menu-item-displayed

  • For the links you want hidden under the hamburger icon add the class name menu-item-under-icon

  • Example:

    <a class="menu-item-displayed" href="#">link 1</a>
    <a class="menu-item-displayed" href="#">link 2</a>
    <a class="menu-item-displayed" href="#">link 3</a>
    <a class="menu-item-under-icon" href="#">other link 1</a>
    <a class="menu-item-under-icon" href="#">other link 2</a>
    <a class="menu-item-under-icon" href="#">other link 3</a>

With NPM (preferred)

  • Enter the following into the command line: npm i tab-style-mobile-menu

  • There are three ways to use this module with NPM

    1. Without a module bundler: The steps are the same as without NPM except add the following script tag to the head of your html file: <script src='node_modules/tab-style-mobile-menu/dist/main.js' defer>

    2. With bundler nodes already added to html document: Simply add the following line to the import list of your index.js file: import 'tab-style-mobile-menu'

    3. If adding the links programmatically add the following line after appending your links: mobileMenu.addNavBar();

      Example:

    import { mobileMenu } from 'tab-style-mobile-menu'
    
    const link1 = document.createElement("a");
    link1.textContent = "link1";
    link1.classList = "menu-item-displayed";
    document.body.appendChild(link1);
    const link2 = document.createElement("a");
    link2.textContent = "link2";
    link2.classList = "menu-item-displayed";
    document.body.appendChild(link2);
    const link3 = document.createElement("a");
    link3.textContent = "link3";
    link3.classList = "menu-item-displayed";
    document.body.appendChild(link3);
    
    const otherLink1 = document.createElement("a");
    otherLink1.textContent = "otherLink1";
    otherLink1.classList = "menu-item-displayed";
    document.body.appendChild(otherLink1);
    const otherLink2 = document.createElement("a");
    otherLink2.textContent = "otherLink2";
    otherLink2.classList = "menu-item-displayed";
    document.body.appendChild(otherLink2);
    const otherLink3 = document.createElement("a");
    otherLink3.textContent = "otherLink3";
    otherLink3.classList = "menu-item-displayed";
    document.body.appendChild(otherLink3);
    
    mobileMenu.addNavBar();
  • Note module will not remove and nav bars present. If this module is used more than once it could cause problems.

How to Style

Nav Bar Container

  • Use class .menu-bar

List of Main Links

  • Use class .list-displayed

List of Extra Links

  • Use class .list-under-icon

Hamburger Icon

  • Use class .hamburger

Bugs and suggestions

  • Report bugs and suggestions here

Motivations

The motivations behind this project are to practice creating commonly used JS web functions using standard JS and practicing publishing node packages.