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.

42 lines
1.0KB

  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 WBTable extends Component {
  9. render({ columns, rows, headerClasses, verticalHeader }) {
  10. return (
  11. <table class="table table-striped table-hover">
  12. <thead class="thead-light">
  13. <tr>
  14. { columns.map((c, i) => <th class={ headerClasses[i] }>{ c }</th>) }
  15. </tr>
  16. </thead>
  17. <tbody>
  18. { rows.map(r => (
  19. <tr>
  20. { columns.map((_, idx) => (
  21. (idx == 0 && verticalHeader) ? (
  22. <th scope="row">{ r[idx] }</th>
  23. ) : (
  24. <td>{ r[idx] }</td>
  25. )
  26. )) }
  27. </tr>
  28. )) }
  29. </tbody>
  30. </table>
  31. );
  32. }
  33. }
  34. WBTable.defaultProps = {
  35. 'headerClasses': []
  36. };
  37. export default WBTable;