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

@navelpluisje/np-knob

v2.0.3

Published

A pure javascript library for creating rotating knobs in your application.

Downloads

3

Readme

NpKnob

npm (scoped) npm (scoped) npm (scoped) npm (scoped) npm (scoped)

About

A small pure javascript library for creating rotating knobs. It was created while I had the idea to rebuild my BeatMachine.

NPM

Usage

Install by npm: npm i --save @navelpluisje/np-knob.

There is also an np-knob-package, but that will be depricated soon

You can import it in your project the next ways:

  • the ES6 way: import NpKnob from 'np-knob';
  • the node way: const NpKnob = require('np-knob');
  • the old-skool way using the script tag

In you project create an element with an id. Then add the next code:

const knob1 = new NpKnob('your-id', options);

...and thats it. Now you can listen to the events it's fyering:

knob1.knob.addEventListener('knob-rotate', (evt) => {
    /**
     * Print the value of the button
     */
    console.log(evt.default.value);
});

Documentation

Option

  • id: The id of the DOM-element
  • options: Set of default options. This is an object with the following aatributes:
    • min: the minimum value of the knob
    • max: the maximum value of the knob
    • step: the step size in decimals.
      • step -1 is in 0.1 step-size
      • step 0 is in 1 step-size
      • step 1 is in 10 step-size
    • value: the start value of the knob

Methods

  • obj: Returns the DOM-element of the corresponding knob
  • getValue: Get the current value of the knob
  • setValue: Set a new value to the knob

Events

When rotating the knob or clicking it to set the value an event is fired.

  • knob-rotate: Parses the value of the knob

Also the created input can be used for eventlistening. You can do it like:

const knob1 = new NpKnob('your-id', options);
knob1.input.addEventlistener(event, callback);

Styling

NpKnob can easily be styled with css. Here's an example.

.npknob + input[type="number"] {
  display: none;
}

.npknob-wrapper {
  display: inline-block;
  height: 120px;
  margin: 1rem auto;
  position: relative;
  width: 120px;
}

.npknob {
  transition: transform .5s ease;
  background: transparent;
  border-color: #92c5c8;
  border-style: solid;
  border-radius: 50%;
  border-width: 6px;
  box-sizing: border-box;
  display: block;
  position: relative;
  width: 120px;
  height: 120px;
}

.npknob::after {
  content: '';
  background-color: #92c5c8;
  display: block;
  height: 40%;
  left: 50%;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 6px;
}

.npknob.active {
  transition: none;
  border-color: #a3dde0;
  box-shadow: 0 0 5px 0 #a3dde0, inset 0 0 5px 0 #a3dde0;
}

.npknob.active::after {
  background-color: #a3dde0;
  box-shadow: 0 0 5px 0 #a3dde0, inset 0 0 5px 0 #a3dde0;
}