|
123456789101112131415161718192021222324252627282930 |
- import { h, Component } from 'preact';
-
- class WBCheckboxes extends Component {
- render({ items, checked, onChange, cssClass, title }) {
- return (
- <div class={ 'btn-group-toggle' + (cssClass ? ' ' + cssClass : '') } data-toggle="buttons">
- { title }
- {
- items.map((name, idx) => (
- <label class={ 'btn btn-outline-primary' + (checked[idx] ? ' active' : '') }
- onclick={ e => { e.preventDefault();
- checked[idx] = !checked[idx];
- this.setState({});
- onChange(); } }>
- <input type="checkbox" checked={ checked[idx] ? 'checked' : null }
- autocomplete="off" /> { name }
- </label>
- ))
- }
- </div>
- );
- }
- }
-
- WBCheckboxes.defaultProps = {
- 'checked': [],
- 'onChange': () => {}
- }
-
- export default WBCheckboxes;
|