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

@illinois-toolkit/ilw-accordion

v1.0.1

Published

Illinois Toolkit: a bunch of headers and each header can be opened to display more information.

Downloads

87

Readme

ilw-accordion

Links: ilw-accordion in Builder | Illinois Web Theme | Toolkit Development

Overview

This is a accordion component, where you have a bunch of headers and each header can be "opened" to display more information. This is useful when you have an information-dense page and you want to convey an overview of the page and its contents, and your users will want only one or two pieces of information (for example, an FAQ where someone is hunting for a specific question/answer). It's a more elegant "table of contents".

Do not use this control when a user is going to read the entire page or you need all the information displayed (like a person completing multiple steps of a process). If you find yourself in this situation, you may want to break the page into multiple pages.

This should not be used to replace the HTML details / summary elements. The accordion is for structured information with headers, while the details / summary elements is for information that does not contain header information. Instead, the accordion uses hidden="until-found". That makes it possible to search for text on the page even when the content is collapsed, and the browser opens the accordion to show matches.

There are two components bundled in this, the ilw-accordion and ilw-accordion-panel. The ilw-accordion should only contain one or more ilw-accordion-panel elements. The ilw-accordion-panel may contain headings, text, images, lists, links, and other rich-text information.

The ilw-accordion component has the following attributes:

  • theme: the theme/background of the line to the left of the accordion. Options are blue, orange, arches, industrial
  • width: whether or not this is contained in the parent (default), if it will expand to full width (full), or if just the background will expand and the text will be in a narrow window (auto), or if it will size itself (page). If auto is used, the left border will not be used.
  • limit: a boolean attribute that determines if other panels close when a panel is opened. Use this if the user will not be comparing information in different panels.

The ilw-accordion-panel component has the following slots:

  • summary: the HTML that is in the summary section and is always displayed.

The ilw-accordion-panel component has the following attribute:

  • open: a boolean attribute that will expand the panel.

Code Examples

<h2 id="accordion-header">Enrollment FAQ</h2>
<ilw-accordion aria-labelledby="accordion-header">
  <ilw-accordion-panel>
    <h3 slot="summary">What are the admission requirements for enrolling in a degree program?</h3>
    <p>To enroll in a degree program, you typically need to meet certain admission requirements, which may include:</p>
    <ul>
       <li>A high school diploma or equivalent (e.g., GED)</li>
       <li>Satisfactory SAT, ACT, or other standardized test scores (if required)
       <li>Completion of prerequisite courses, particularly for specialized programs (e.g., math and science courses for engineering)
       <li>Letters of recommendation, a personal statement, or an admissions essay
       <li>A minimum GPA requirement, which varies by program and institution
     </ul>
  </ilw-accordion-panel>
  <ilw-accordion-panel>
    <h3 slot="summary">How do I submit my application?</h3>
    <p>Applications are usually submitted online through the university's admissions portal.</p>
  </ilw-accordion-panel>
  <ilw-accordion-panel>
    <h3 slot="summary">When is the application deadline?</h3>
    <p>Application deadlines vary by program, so check the specific dates on the university’s website.</p>
  </ilw-accordion-panel>
</ilw-accordion>

Accessibility Notes and Use

This mainly follows the WAI Accordion pattern, but since the heading element is not provided by the component, we can't insert a button inside of it. Instead, the div wrapping the heading is given a button role and the appropriate event listeners. The div wrapper has the aria-controls and aria-expanded attributes.

The appearance of a section's header changes when the nested button role element receives focus. When the button loses focus, the header reverts to its default appearance.

The summary slot should contain a heading, and the heading should not be duplicated in the accordion panel body. The headings should be the same across the entire accordion (for example, do not mix h2 and h3 inside the same accordion).

A "nice-to-have" is to label the ilw-accordion component with a header using the aria-labelledby attribute.

External References

  • https://www.w3.org/WAI/ARIA/apg/patterns/accordion/examples/accordion/
  • https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details
  • https://daverupert.com/2019/12/why-details-is-not-an-accordion/
  • https://www.nngroup.com/articles/accordions-on-desktop/
  • https://www.w3.org/WAI/ARIA/apg/patterns/button/examples/button/