1.0.0 • Published 8 years ago

react-1poll v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

react-1poll component

A simple Doodle-like poll component that makes it easy for contributors to add more options. Star it on npm and on github.

Made with React.js and Material-UI. Thanks to Romain Dardour for his help!

Demo / examples of use

How to install and use

Using npm

First, install it in your project's directory:

npm install react-1poll

Then, integrate it in your javascript project:

var PollForm = require('./PollForm.jsx');
var options = [
  { name: 'Option A', defaultCheck: true },
  { name: 'Option B' },
  { name: 'Option C' }
];
function onValidSubmit(selectedItems) {
  assert.equal(selectedItems, [ 'Option A' ]);
}
ReactDOM.render(<PollForm
  options={options}
  onNewOption={console.log}
  onValidSubmit={onValidSubmit} />, appDiv);

Component API reference

Properties

  • options: an Array of Objects that accept the following fields:
    • name: (String) name of the option, seen as a checkbox.
    • checked: (Boolean) true if the checkbox is checked.
    • defaultChecked: (Boolean) true if the checkbox should be checked initially.
  • allowNewEntries: (optional boolean) set to false to hide the option entry field.
  • onNewOption: (optional) Function({ name: String, defaultChecked: Boolean }) overrides the function that adds the new option to the options state Array.
  • onSelectionChange: (optional) Function( { name: String, checked: true } ) passes an Array of option Objects (as in the options property), which are currently selected (i.e. have their checked field set to true).
  • labelStyle: an optional Object to override the inline-style of the Checkbox labels.
  • autoFocus: (Boolean) if set to true, the option entry field will be focused (ready to type) by default.
1.0.0

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.1

8 years ago

0.1.0

9 years ago

0.0.12

9 years ago

0.0.11

9 years ago

0.0.10

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago