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

clic-clac

v3.0.0

Published

Accessible tabs and toggle buttons

Downloads

17

Readme

CLIC - CLAC

License GitHub Release Dependency status Build Status

EXAMPLES

http://mynameislau.github.io/clic-clac

HOW TO USE

import clic-clac in your main js file (or simply embed it via a <script> tag) Initiate the behaviors using the init method.

import * as clicClac from 'clic-clac';
clicClac.init();

or you can init only expand or tablist :

import { expand } from 'clic-clac';
expand.init('any-dom-selector'); // default is [data-expand]

If you import it via a script tag, the name of the library in the window object is clicClac.

EXPAND

  • The init function parameter is a DOM selector targeting the button that toggles an element.
  • data-controls="idOfTheControlledElement" tells the lib which element this button is controlling
    This can be a list of ids separated by spaces.
  • data-expand-default-state sets the default aria state of the element
  • If you want your content to collapse when you click outside of the area, add a data-click-outside attribute with the deselect value to the controlled element.

TABLIST

  • The init function parameter is a DOM selector targeting the tablist main element.

  • The id of the element will be the name of the tablist (used to fill the aria-owns attribute later). You can specify if the tablist is multiselectable with the data-multiselectable attribute. On each tab button, set a data-tab-for attribute which value is the id. If your tab button is a link (<a>), you can juste specify the id with an anchor link (href="#xy"). of the controlled tab panel.
    Set a data-owner attribute to specify the tablist that owns the tab.

  • Set a data-expand-default-state attribtue to true or false if you want to specify a default state for this tab

  • If you don't want at least one tab selected at all times, add a data-at-least-one attribute to the tablist element with the value false.

  • If you want your content to collapse when you click outside of the area, add a data-click-outside attribute with the deselect value.

EVENTS

Every time an attribute is modified, a custom clic-clac-state-update event is dispatched on the element whose attribute changed. You can use this event as a hook to add custom js behaviours. The detail property holds infos about the element :

  • attribute : which attribute changed
  • prevState: previous value of the attribute
  • newState : new value of the attribute