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

@digital-butlers/tabs

v0.0.14

Published

A convenient library with tabs for everyday tasks

Downloads

51

Readme

Tabs

Usage

Create an HTML markup


<div data-tabs="wrapper">
  <div data-tabs="tabs">
    <button>Tab 1</button>
    <button>Tab 2</button>
    <button>Tab 3</button>
  </div>
  <ul data-tabs="content">
    <li>
      <p>Tab 1 content</p>
    </li>
    <li>
      <p>Tab 2 content</p>
    </li>
    <li>
      <p>Tab 3 content</p>
    </li>
  </ul>
</div>

Create tabs instance

const tabs = new Tabs(
  '[data-tabs="wrapper"]', // your custom wrapper selector or an HTML Element
  { // config object
    tabbuttonsListSelector: '[data-tabs="tabs"]', // your custom tab list selector
    tabpanelsListSelector: '[data-tabs="content"]', // your custom content panels list selector
  }
);

Tabs will not initialize, if quantity of buttons and content blocks are not equal

Import styles in CSS or SCSS

@import '@digital-butlers/tabs/scss';
@import '@digital-butlers/tabs/css';

API

Config Properties

tabbuttonsListSelector

Type: string
Default: '[data-tabs="tabs"]'
Description: Css selector for elements with tabs

tabpanelsListSelector

Type: string
Default: '[data-tabs="content"]'
Description: Css selector for elements with tabs content

deletableTabs

Type: boolean
Default: false
Description: Ability to delete tabs and their contents.

initialTab

Type: number
Default: 0
Description: Id of the tab will be active after tabs initialization. buttons.

orientation

Type: horizontal | vertical
Default: horizontal
Description: orientation of tab buttons layout.

triggerEvent

Type: click | mouseover
Default: click
Description: which event will trigger the tab changing.

equalHeight

Type: boolean
Default: false
Description: set height of tab panels as same as the tallest panel.

matchMediaRule

Type: mediaQueryString
Default: undefined
Description: will prevent the tab changings if window.matchmedia doesn't match

devMode

Type: boolean
Default: false
Description: Shows unnecessary errors if something went wrong

autoplay

Type: object

Autoplay config object

delay

Type: number
Default: 0
Description: Autoplay delay. A value of 0 disables autoplay.

on

Type: object
Description: Callbacks that can be initialized after some events with tabs

Events callback config object

tabChange

Type: function
Default: undefined
Description: Callback will be started after every tab changing event

beforeInit

Type: function
Default: undefined
Description: Callback will be started before tabs initialization

afterInit

Type: function
Default: undefined
Description: Callback will be started after tabs initialization

Properties

activeIndex

Type: number
Description: Index of current active tab.

nextIndex

Type: number
Description: Index of tab after current active (0 if cuurent tab is last).

prevIndex

Type: number
Description: Index of tab before current active (last if cuurent tab is first).

lastIndex

Type: number
Description: Index of last tab.

tabsWrapper

Type: HTMLElement
Description: Main Tabs wrapper HTML Element.

tabList

Type: HTMLElement
Description: Tab buttons wrapper HTML Element.

tabPanelsList

Type: HTMLElement
Description: Tab content wrapper HTML Element.

tabs

Type: HTMLElement[]
Description: Array of tab-buttons HTML elements

panels

Type: HTMLElement[]
Description: Array of tab-panels HTML elements

generatedId

Type: string
Description: Automatically generated unique identificator which is assigned as the prefix in id's to each element inside main tabs wrapper

Methods

goTo(index)

Return: -
Arguments: id
Description: makes tab with target id active.

goToNext()

Return: -
Arguments: { loop: boolean }. By default loop = true, so after last tab first tab will turn active Description: go to next tab.

goToPrev()

Return: -
Arguments: { loop: boolean }. By default loop = true, so after first tab last tab will turn active. Description: go to previous tab.

stopAutoPlay()

Return: -
Arguments: -
Description: Stop the autoplay animation.

update()

Return: -
Arguments: -
Description: Update all indexes, properties and attributes for each tab.

changeTriggerEvent(event)

Return: -
Arguments: 'click' | 'mouseover'
Description: Changes the trigger event. Shows console error for unsupported events.

destroy()

Return: -
Arguments: -
Description: Irreversible action! Remove all indexes, classes, properties and attributes for each tab.

License

MIT