IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

38 lignes
1.1KB

  1. //
  2. // Copyright (C) Stanislaw Adaszewski, 2020
  3. // Contact: s.adaszewski@gmail.com
  4. // Website: https://adared.ch/wba
  5. // License: GNU Affero General Public License, Version 3
  6. //
  7. import { h, Component } from 'preact';
  8. class WBCheckboxes extends Component {
  9. render({ items, checked, onChange, cssClass, title }) {
  10. return (
  11. <div class={ 'btn-group-toggle' + (cssClass ? ' ' + cssClass : '') } data-toggle="buttons">
  12. { title }
  13. {
  14. items.map((name, idx) => (
  15. <label class={ 'btn btn-outline-primary' + (checked[idx] ? ' active' : '') }
  16. onclick={ e => { e.preventDefault();
  17. checked[idx] = !checked[idx];
  18. this.setState({});
  19. onChange(); } }>
  20. <input type="checkbox" checked={ checked[idx] ? 'checked' : null }
  21. autocomplete="off" /> { name }
  22. </label>
  23. ))
  24. }
  25. </div>
  26. );
  27. }
  28. }
  29. WBCheckboxes.defaultProps = {
  30. 'checked': [],
  31. 'onChange': () => {}
  32. }
  33. export default WBCheckboxes;