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

beautiful-piano

v0.0.6

Published

beautiful visualization of piano keys with pressed keys effect in plain HTML&CSS

Downloads

18

Readme

Beautiful Piano

screenshot

npm version npm dependencies npm dev dependencies

This library provides a JavaScript API to generate HTML markup for a beautiful musical keyboard. It comes with a CSS file which makes it so nice.

Demo

See the demo on rawgit

Setup

Either embed the file from the dist directory via script tag in your HTML:

<script src="beautiful-piano/dist/piano.js"></script>

Then you can access to the global variable piano.

Otherwise install it via npm npm i beautiful-piano

Don't forget to include the CSS file, for instance:

<link rel="stylesheet" href="beautiful-piano/styles.css">

Usage

piano(document.querySelector('body'), {octaves: 3});

piano(parent, options)

Arguments:

  • parent - DOM element where to inject the piano
  • options Options object, octaves and range property can't be used in combination You can also pass a namesMode property.
    • octaves - A positive integer, the amount of octaves to generate, starts always with an A and ends with a C, min: 1, max: 9
    • range - Options object with a custom range
      • startKey - A string, key where the piano should start, A-H
      • startOctave - An integer on which octave the piano should start, min: 0, max: 10
      • endKey - A string, key where the piano should end, A-H
      • endOctave - An integer on which octave the piano should end, min: 0, max: 10
    • namesMode - A string, either sharp or flat when names for the black keys are shown
    • lang - A string, either en or de to swap H and B
    • notation - A string, either scientific or helmholz will be used for octave notation

Selectors

You can toggle the pressed effect of each key with CSS class. For instance: document.querySelector('.C4').classList.add('active')

The selector for the keys use the scientific notatino for the octave. All 12 keys for the fourth octave can be accessed with these selectors:

.C4 .Cs4 or .Db4 .D4 .Ds4 or .Eb4 .E4 .F4 .Fs4 or .Gb4 .G4 .Gs4 or .Ab4 .A4 .As4 or .Bb .B

WTF? I can't hear anything!

This library provides just a visual interface. Playing a sound while pressing a key is comming soon as an extra module.

Credits

All visual credits goes to Taufik Nurrohman

I started with the style sheets from his codepen and modified it for more dynamic use cases.