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

hypertabs

v5.0.2

Published

tabbed interface with hyperscript

Downloads

127

Readme

hypertabs

create a simple tabbed interface

Example

var Tabs = require('hypertabs')

var tabs = Tabs()

tabs.add(h('h1', 'foofoo'))
tabs.add(h('h1', 'baz'))

tabs.select(1) //change to the "baz" tab.

document.body.appendChild(tabs)

setTimeout(
  function () { tabs.select(0) },
  2000
)

When you call add, this creates a new tab, and it creates a page which contains the element you've provided. By default hypertabs assumes that the page size will be fixed and any scrolling will be done on the element you've provided (this is important if you care about preserving scroll position jumping between tabs).

API

Tabs(opts)

Instantiates a tabs setup. opts is an optional object which can contain any of the following keys:

  • onSelect - a callback function that is called when a tab is selected (called with ...)
  • onClose - a callback function that is called when a tab is closed (called with the page element being closed)
  • prepend - an html element which is prepended before your tabs in the 'tab nav'
  • append - an html element which is appended after your tabs in the 'tab nav'

tab#add(page)

Adds a new page and makes an associated tab for it

tab#remove

tab#has

tab#get

tab#select

tab#selectRelative

tab#fullscreen

tab#isFullscreen

Notifications

Hypertabs wraps content you give it in a div.page. It watches for whether there is a -notify class on this element, and keeps this class in sync with the appropriate tab. In this way, you can signal updates to a page that is not currently selected.

var welcomeTab = tabs.add(h('h1', 'Welcome!'))
var welcomePage = welcomeTab.page

welcomePage.classList.add('-notify')

welcomeTab.classList.contains('-notify')
// -> true

Adding more to yor nav bar

Hypertabs takes an optional second argument which allows you to easily prepend or append node to the tabs nav-bar.

var tabs = Tabs(onSelected, { prepend: status, append: aBurger })

Styling

Hypertabs follows a class pattern that is compatible with micro-css where styling is super tightly specified using the direct child only > and non-standard class prefixes to stop you from writing bad styles.

Your style schema for mcss is like:

Hypertabs {
  nav {
    section.tabs {
      div.tab {
        -selected {
        }

        -notify{
        }

        a.link {
        }

        a.close {
        }
      }
    }
  }

  section.content {
    div.page {
      *  // this is the element whos scroll position will be preserved
    }
  }
}

In classic css, use a the following schema as a template:

.Hypertabs {  }

.Hypertabs > nav {  }
.Hypertabs > nav > section.tabs {  }
.Hypertabs > nav > section.tabs > div.tab {  }
.Hypertabs > nav > section.tabs > div.tab.-selected {  }
.Hypertabs > nav > section.tabs > div.tab.-notify {  }
.Hypertabs > nav > section.tabs > div.tab > a.link {  }
.Hypertabs > nav > section.tabs > div.tab > a.close {  }

.Hypertabs > section.content {  }
.Hypertabs > section.content > div.page {  }

Getting scrolling of pages working can be a bit challenging with styling. The setup from an app which implements hypertabs can be found for both hortizontal and vertical formats in ./example.

License

MIT