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

control-panel

v1.3.4

Published

embeddable panel of inputs for parameter setting

Downloads

190

Readme

control-panel

NPM version experimental js-standard-style

Embeddable panel of inputs for adding parameter selection to your app or visualization. Modern and minimalist design. Fully encapsulated module including JS and CSS. Can easily be added to any app or page. Heavily inspired by dat-gui, but streamlined, simplified, and written as a npm module for use with browserify.

LIVE DEMO

themes


Supports the following input types

rangecheckboxtextcolorbuttonintervalselect


Includes the following themes

darklight

Want to contribute a new theme or input type? Submit a PR!

install

Add to your project with

npm install control-panel

example

Create a panel with four elements and add to your page in the top right.

var control = require('control-panel')

var panel = control([
  {type: 'range', label: 'my range', min: 0, max: 100, initial: 20},
  {type: 'range', label: 'log range', min: 0.1, max: 100, initial: 20, scale: 'log'},
  {type: 'text', label: 'my text', initial: 'my cool setting'},
  {type: 'checkbox', label: 'my checkbox', initial: true},
  {type: 'color', label: 'my color', format: 'rgb', initial: 'rgb(10,200,0)'},
  {type: 'button', label: 'gimme an alert', action: function () {alert('hello!');}},
  {type: 'select', label: 'select one', options: ['option 1', 'option 2'], initial: 'option 1'}
  {type: 'multibox', label: 'check many', count: 3, initial: [true, false, true]}
], 
  {theme: 'light', position: 'top-right'}
)

usage

panel = control([input1, input2, ...], [opts])

The first argument is a list of inputs. Each one must have a type and label property, and can have an initial property with an initial value. For example,

{type: 'checkbox', label: 'my checkbox', initial: true}

Each type must be one of rangeinputcheckboxcolorintervalselect. Each label must be unique.

Some types have additional properties:

  • Inputs of type range can specify a min, max, and step (or integer steps). Scale can be either 'linear' (default) or 'log'. If a log scale, the sign of min, max, and initial must be the same and only steps is permitted (since the step size is not constant on a log scale).
  • Inputs of type color can specify a format as either rgbhexarray
  • Inputs of type button can specify an action callback. Button inputs are not reflected in the state and do not trigger an 'input' event.
  • Inputs of type interval obey the same semantics as range inputs, except the input and ouput is a two-element array corresponding to the low/high bounds, e.g. initial: [1, 7.5].
  • Inputs of type select can specify a list of options, either as an Array (in which case the value is the same as the option text) or as an object containing key/value pairs (in which case the key/value pair maps to value value/label pairs).
  • Inputs of type multibox can specify a number of checkboxes, either by providing a count or a list of names from which the number will be inferred, in which case the color of each box and a text name can also be provided as lists colors and names

The following optional parameters can also be passed as opts

  • root root element to which to append the panel
  • theme can specify lightdark or provide an object (see themes.js for format)
  • title a title to add to the top of the panel
  • width width of panel in pixels
  • position where to place the panel as top-lefttop-rightbottom-leftbottom-right, if undefined will just use relative positioning

panel.on('input', cb(data))

This event is emitted every time any one of the inputs change. The callback argument data will contain the state of all inputs keyed by label such as:

{'my checkbox': false, 'my range': 75}

see also