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-accordion

v0.1.0

Published

HTML UI Toolkit accordion component

Downloads

3

Readme

hut-accordion

NPM

Build Status Dependency Status

HTML UI Toolkit accordion component

A simple accordion where only one section can be opened at a time from multiple sections.

Example

View the live example

With the following HTML:

<div id="my-accordion" class="hut-accordion">
    <div class="accordion-section">
        <header class="accordion-header">
            <h3>Main</h3>
        </header>
        <section class="accordion-content">
            <p>Some content for main section.</p>
        </section>
    </div>
    <div class="accordion-section">
        <header class="accordion-header">
            <h3>Cats</h3>
        </header>
        <section class="accordion-content">
            <p>Some cute kittens...</p>
        </section>
    </div>
    <div id="dog-section" class="accordion-section">
        <header class="accordion-header">
            <h3>Dogs</h3>
        </header>
        <section class="accordion-content">
            <p>Some cute puppies...</p>
        </section>
    </div>
</div>

Give it accordion behavior with the following JS:

var Accordion = require('hut-accordion');

var myAccordion = new Accordion(document.querySelector('#my-accordion'));

// Open the dogs section
myAccordion.select(document.querySelector('#dog-section'));

// Collapse the currently opened section
myAccordion.select(null);

JS Reference

new Accordion(element)

Creates a new accordion and attaches the event handlers. When created, no sections are selected.

#selected

Contains the currently selected .accordion-section element, or null if no section is selected.

#select([element])

Selects a section. This will collapse any previously selected section. element must be a .accordion-section element or else null. If element is null or undefined, the currently selected section will be collapsed and no new section will be selected.

Event: selected(element)

Triggered when the selected section changes. element will be a .accordion-section element or else null if no section is selected.

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-modal" to your stylesheet. Use the selectors defined below for your own styling.

.hut-accordion

The root of each accordion component. This element contains all the sections in the accordion.

.accordion-section

An accordion section, which must be nested inside of the .hut-accordion element.

.accordion-section.accordion-selected

The .accordion-selected class is added to the .accordion-section element when that section is currently the selected section.

.accordion-header

The header element for a section. This is nested inside the .accordion-section element.

.accordion-content

The content element for a section. This section is normally hidden when not selected. This is nested inside the .accordion-section element.