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

tabs-more-button

v2.0.0

Published

A lightweight library for making tabbed interfaces responsive by hiding overflow tabs while keeping the active tab visible.

Downloads

77

Readme

tabs-more-button

Test coverage NPM version License npm download Build Status

tabs-more-button is a lightweight library designed to enhance your tabbed interfaces by making them responsive.​ This package does not create or manage tabs, but it intelligently hides overflow tabs while ensuring that the active tab remains visible. Ideal for scenarios where space is limited

Features

  • Responsive

  • Vertical support

  • rtl support

  • Flexible style

  • High performance

Installation

$ npm install tabs-more-button --save

or

$ yarn add tabs-more-button

If you need to directly include script in your html, use the following links :

<script src="https://unpkg.com/tabs-more-button@latest/dist/tabs-more-button.min.js"></script>

Minimal Usage

html :

<div id="container">
  <ul id="tablist" style="display:inline-flex;">
    <li>Tab 0</li>
    <li>Tab 1</li>
    <li>Tab 2</li>
    <li>Tab 3</li>
    <li style="color:red;">Active Tab 4</li>
    <li>Tab 5</li>
    <li>Tab 6</li>
  </ul>
  <button id="view-more-button">more</button>
</div>

js :

import tabsMoreButton from 'tabs-more-button';

const options = {
  buttonElement: document.getElementById('view-more-button'),
  containerElement: document.getElementById('container'),
  tablistElement: document.getElementById('tablist'),
};
const instance = new tabsMoreButton(options);

let hiddenTabs = instance.resize(4 /*selectedTabIndex*/);
addEventListener('resize', () => {
  hiddenTabs = instance.resize(4 /*selectedTabIndex*/);
});
document.getElementById('view-more-button').addEventListener('click', () => console.table(hiddenTabs));

Rules

  • view more button is required to display the hidden tabs and should be next sibling element of Tablist element

  • tabs and view more button should be kept on same line

  • Should not be any gap between view more button and Tablist

options

  • buttonElement

    • type : HtmlELement
    • description : view more button
  • containerElement

    • type : HtmlELement
    • description : parent element of view more button and Tablist element
  • tablistElement

    • type : HtmlELement
    • description : the Tablist element
  • tabDisplay?

    • type : string
    • description : display value for each tab element
    • default value : inline-flex
  • containerDisplay?

    • type : "flex"|"block"
    • description : display value for containerElement
    • default value : flex

instance methods

  • resize

    • type : function
    • description : makes tabs responsive by hiding overflow tabs except active tab
    • arguments :
      • selectedTabIndex :
        • type : Number
        • description : index of active tab element in the tablist element
      • direction? :
        • type : "ltr" | "rtl"
        • description : direction value of tablist element
        • default value : "ltr"
      • isVertical? :
        • type : Boolean
        • description : true means tablist element is vertical
        • default value : false
    • return :
      • type : Array<{ el: HTMLElement, index: Number }>
      • description : array of hidden tabs data

Test

$ npm run test

License

MIT