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!
The gh-pages
branch of this repository contains:
- The project's landing page, as seen on adrienjoly.com/1poll;
- The
1poll
react component, as defined in the component subdirectory; - A demo page to demonstrate the use of the
1poll
component.
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);