JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 31
  • Score
    100M100P100Q52866F
  • License MIT

embeddable panel of inputs for parameter setting

Package Exports

  • control-panel

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (control-panel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

control-panel

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.

darklight


Supports the following input types

rangecheckboxtextcolor


Includes the following themes

darklight

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: 'range slider', min: 0, max: 100, initial: 20},
  {type: 'text', label: 'text', initial: 'my cool setting'},
  {type: 'checkbox', label: 'checkbox', initial: true},
  {type: 'color', label: 'color rgb', format: 'rgb', initial: 'rgb(100,200,100)'}
], 
  {theme: 'light', position: 'top-right'}
)

usage

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

The first argument is a list of items. 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 range, input, checkbox, and color. Each label must be unique.

Some types have additional properties:

  • Inputs of type range can specify a min, max, and step
  • Inputs of type color can specify a format as either rgbhexarray

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 theme.js for format)
  • title a title to add to the top of the panel
  • position where to place the panel as top-lefttop-rightbottom-leftbottom-right
  • width width of panel in pixels

panel.on('input')

Emitted every time any of the inputs change. Returns an object with the state of all inputs by label.