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

hut-tabs

v0.1.0

Published

HTML UI Toolkit tabs component

Downloads

6

Readme

hut-tabs

NPM

Build Status Dependency Status

HTML UI Toolkit tabs component

Break up your content into multiple tabs. Switch between tabs on the client using JS.

Example

View the live example

With the following HTML:

<div id="my-tabs" class="hut-tabs">
    <ul class="tabs-list">
        <li>General</li>
        <li>Dogs</li>
        <li>Cats</li>
    </ul>
    <div class="tabs-section">
        General boring information here...
    </div>
    <div class="tabs-section">
        Cute pics of puppies
    </div>
    <div id="kittens" class="tabs-section">
        Cute pics of kittens
    </div>
</div>

Give it behavior with the following JS:

var tabs = require('hut-tabs');

var myTabs = tabs(document.querySelector('#my-tabs'));

// Select the first tab
myTabs.select(0);

// Select the kittens tab
myTabs.select(document.querySelector('#kittens'));

JS Reference

tabs(element)

Creates a new tabs component and attaches the event handlers. It will return a new object that contains the function documented below. The first tab is automatically selected.

#selected

An object that indicates the currently selected section. It is an object that contains a header property with the header li DOM node and a content property with the .tabs-section DOM node.

#select(section)

Selects a tab section. If section is a number, it will select the section at that index (for example use 0 if selecting the first section). If section is an element, it must be one of the tabs-section elements.

Event: select(section)

Triggered when a new section is selected. section will be an object that contains a header property with the li header DOM node and a content property with the .tabs-section DOM node.

Style Reference

The base CSS style only defines basic layout and formatting of the accordion. You should add your own style when using it. Import the base style by using npm-css and add @import "hut-tabs" to your stylesheet. Use the selectors defined below for your own styling.

.hut-tabs

The root of each tabs component. This contains the .tabs-list element and all of the .tabs-section elements.

.tabs-list

The list of tab headers. It must be a ul list with li child elements.

.tabs-list li

The title/header for a tab. There should be a header for each .tabs-section element, and the header elements must be in the same order as the section elements.

.tabs-list li.tabs-selected

The .tabs-selected class is added to the header element when the section for that header is selected.

.tabs-section

The content for a tab section. There should be a header (in .tabs-list) for each section. Normally the .tabs-section is hid until it is selected.

.tabs-section.tabs-selected

The .tabs-selected class is added to the section element when it is selected.