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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@musodojo/note-collection-selector

v6.2.0

Published

A custom HTML element for selecting a note collection, and dispatching events with the details.

Readme

Note Collection Selector Web Component

note-collection-selector is a custom HTML element that allows users to select a musical note collection (e.g., "Major", "Dorian", ... "Major Pentatonic", ...) from a dialog and dispatch a custom event.

  • displays a button which opens a dialog containing grouped note collections.
  • includes a "more info" toggle to show details about each collection.
  • dispatches an event with the collection key and full collection object in the details.

Bundle

Create the dist/bundle.js file for the example

Deno

deno task bundle

Node

npm run bundle

See examples/example1.html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Note Collection Selector Example</title>
    <script type="module" src="../dist/bundle.js"></script>
  </head>
  <body>
    <h1>Note Collection Selector</h1>
    <note-collection-selector
      selected-note-collection-key="ionian"
    ></note-collection-selector>

    <script type="module">
      const selector = document.querySelector(
        "note-collection-selector",
      );

      selector.addEventListener("note-collection-selected", (e) => {
        console.log("Key:", e.detail.noteCollectionKey);
        console.log("Collection:", e.detail.noteCollection);
      });
    </script>
  </body>
</html>

Features

  • Note Collection Selection: Provides a user-friendly interface for choosing scales, chords, and other note collections.
  • Event Handling: Dispatches a note-collection-selected event when the user makes a selection, providing the selected key and data object.
  • Attributes and Properties:
    • selected-note-collection-key / selectedNoteCollectionKey: Gets or sets the selected note collection key (e.g., "ionian").
    • selectedNoteCollection (read-only): Gets the full data object for the selected note collection.
  • Methods:
    • setRandomNoteCollection(): Programmatically selects a new, random note collection.

Styling and Customization

The component's appearance can be customized in several ways.

Slots (for Icons)

You can replace the default icons for the main button and the close button using HTML slots.

  • Main Button Icon: Provide an element (e.g., <img>, <svg>, <p>Select Scale</p>) directly inside the <note-collection-selector> tag. This will replace the default icon that appears when no collection is selected.

  • Close Button Icon: To replace the 'X' icon in the dialog, add an element with the attribute slot="close-dialog-icon".

<note-collection-selector>
  <!-- This SVG replaces the default main button icon -->
  <svg><!-- your custom svg --></svg>

  <!-- This SVG replaces the default close icon in the dialog -->
  <svg slot="close-dialog-icon"><!-- your custom svg --></svg>
</note-collection-selector>

Styling using ::part()

The internal elements are exposed via shadow parts. This allows you to directly style them from your global stylesheet.

Main Button (main-button)

note-collection-selector::part(main-button) {
  border: 1px solid currentColor;
  border-radius: 0.6em;
  padding: 0.3em 1em;
}

note-collection-selector::part(main-button):hover {
  background-color: color-mix(in srgb, currentColor 20%, transparent 80%);
}

Dialog (dialog)

note-collection-selector::part(dialog) {
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 0.5em;
  padding: 1em;
}

note-collection-selector::part(dialog)::backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

Note Collection Buttons (note-collection-button)

note-collection-selector::part(note-collection-button) {
  border-radius: 0.5em;
  border: 0.1em solid currentColor;
  padding: 0.5em;
  text-align: left;
}

Close Dialog Button (close-dialog-button)

note-collection-selector::part(close-dialog-button) {
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 50%;
  padding: 0.2em;
}

Clear Selection Button (clear-selection-button)

note-collection-selector::part(clear-selection-button) {
  border-radius: 0.5em;
  border: 0.1em solid currentColor;
  padding: 0.5em;
}

CSS Custom Properties

The following CSS custom properties are available for quick customization:

  • --main-icon-size: Size of the icon in the main button (default: 2.5ch).
  • --close-dialog-icon-size: Size of the close icon in the dialog (default: 2ch).
  • --dialog-backdrop-background: Background of the dialog backdrop (default: light-dark(rgb(255 255 255 / 50%), rgb(0 0 0 / 50%))).
  • --default-spacing: General spacing unit used within the dialog (default: 0.5em).