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

ampersand-tab-view

v1.0.1

Published

Tabbed view for Ampersand.js

Downloads

5

Readme

ampersand-tab-view

Tabbed view for Ampersand.js

Usage

ampersand-tab-view can be instantiated like any ampersand view class:

var TabView = require('ampersand-tab-view')
var view = new TabView({ ... })

However, there are some arguments that you must provide:

  • el: The element in which the content of the tabs should be rendered
  • tabContainer: The DOM element in which the tabs itself should be rendered
  • tabViewClass: A view class for the tabs

To get a better overview, check out the example in example/.

Requirements for the tabViewClass

The tabViewClass must be specified when using ampersand-tab-view and is used to display single tabs. This way you have the ultimate control over the tab's look and feel.

When a new tab is opened, the view class is being instantiated with a TabViewModel set as model. This model has only two properties:

  • id: A random identifier. You probably won't need this one
  • title: The title of the tab. You define how (or if) it will be rendered

You also have the control over when a tab should be closed. Just trigger a close event if you want the tab and its content removed.

If you think a tab should be activated, trigger the activate event.

The library itself controls then which tab is active, which should be activated when one is closed and so on. To represent this visually, we defined two methods that should to be implemented in your tab view class:

  • activateTab: Just set the CSS class there
  • deactivateTab: You probably want to remove the CSS class again

API

openTab(title, contentView)

Opens (and activates) a new tab. Returns the tab's id.

activateTab(id)

Activate the tab with the given id.