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!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.6KB

  1. import { h, Component } from 'preact';
  2. class WBDialog extends Component {
  3. constructor(...args) {
  4. super(...args);
  5. this.state.id = uuid.v4();
  6. }
  7. show() {
  8. const { id } = this.state;
  9. $('#' + id).modal();
  10. }
  11. hide() {
  12. const { id } = this.state;
  13. $('#' + id).modal('hide');
  14. }
  15. render({ title, children, accept, reject }, { id }) {
  16. return (
  17. <form class="m-0">
  18. <div class="modal" id={ id } tabindex="-1" role="dialog">
  19. <div class="modal-dialog modal-lg" role="document">
  20. <div class="modal-content">
  21. <div class="modal-header">
  22. <h5 class="modal-title">{ title }</h5>
  23. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  24. <span aria-hidden="true">&times;</span>
  25. </button>
  26. </div>
  27. <div class="modal-body">
  28. { children[0] }
  29. </div>
  30. <div class="modal-footer">
  31. { children[1] ? children[1] : [
  32. <input type="submit" class="btn btn-primary" value="Accept"
  33. onclick={ e => { e.preventDefault(); this.hide(); accept(); } } />,
  34. <button type="button" class="btn btn-secondary"
  35. onclick={ () => { this.hide(); reject(); } }>Cancel</button>
  36. ] }
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41. </form>
  42. );
  43. }
  44. }
  45. WBDialog.defaultProps = {
  46. 'title': 'Dialog',
  47. 'accept': () => {},
  48. 'reject': () => {}
  49. };
  50. export default WBDialog;