Package Exports
- settings-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 (settings-panel) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
settings-panel 
Simple settings panel for your app, demo or tests.
Usage
var createPanel = require('settings-panel')
var panel = createPanel([
{type: 'range', label: 'my range', min: 0, max: 100, value: 20},
{type: 'range', label: 'log range', min: 0.1, max: 100, value: 20, scale: 'log'},
{type: 'text', label: 'my text', value: 'my cool setting', help: 'why this is cool'},
{type: 'checkbox', label: 'my checkbox', value: true},
{type: 'color', label: 'my color', format: 'rgb', value: 'rgb(10,200,0)', change: value => console.log(value)},
{type: 'button', label: 'gimme an alert', change: () => alert('hello!')},
{type: 'select', label: 'select one', options: ['option 1', 'option 2'], value: 'option 1'}
],
{
title: 'Settings'
}
);API
**`panel = Panel([field1, field2, ...], {title, container, orientation, ..})`**
The first argument is a list of fields. Each one may have following properties:
typeone ofrange•interval•checkbox•color•select•switch•custom•textarea•textor any<input>type.labelused as id and a label for input, must be unique.valuefor initial value.orientationdefines position of a label relative to the input, one oftop,left,right,bottom. Redefinesoptions.orientation.styleappends additinal style to the field, can be an object or a css string.hiddendefines whether field should be visually hidden, but present as a value.inputcallback, invoked if value changed.initinvoked once component is set up.changeinvoked each time field value changed, whether throughinputor API.beforeandafterdefines an html to display before or after the element. That may come handy in displaying help messages, validation, separators, additional buttons etc.
For example,
{type: 'checkbox', name: 'My Checkbox', value: true, input: value => {}}Some types have additional properties:
rangecan specify amin,max, andstep(or integersteps). Scale can be either'linear'(default) or'log'. If a log scale, the sign ofmin,max, andvaluemust be the same and onlystepsis permitted (since the step size is not constant on a log scale).intervalobeys the same semantics asrangeinputs, except the input and ouput is a two-element array corresponding to the low/high bounds, e.g.value: [1, 7.5].colorcan specify aformatas eitherrgb•hex•arrayselectandswitchcan specifyoptions, either as anArray(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).textandtextareacan specifyplaceholder.customcan definecreatemethod, returning HTML string, element or documentFragment.
options
containerelement to which to append the paneltitlea title to add to the top of the panelorientationspecifies label position relative to input:top•left•bottom•rightcssinserts dynamic style for the panel instance, can be a css string or a function returning string. Useful to implement dynamic theme.classNameappends additional className to the panel element.
**`panel.on('input', cb(name, value, data))`**
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}**`panel.get(name?)`**
Get the value of a field defined by name. Or get full list of values, if name is undefined.
**`panel.set(name, value|options)`**
Update specific field, with value or field options. You can also pass an object or array to update multiple fields:
panel.set({ 'my range': { min: -100, value: 200}, 'my color': '#fff' });**`panel.update(opts)`**
Rerender panel with new options.
See also
- prama — wrapper for settings-panel, providing themes, popup, button, state management etc.
- control-panel — original forked settings panel.
- oui
- dat.gui — other oldschool settings panel.

