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.

43 lines
1.2KB

  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 WBBreadcrumbs extends Component {
  9. render({ items, onItemClicked, getItemUrl }) {
  10. return (
  11. <nav aria-label="breadcrumb">
  12. <ol class="breadcrumb">
  13. { items.map((item, idx) => (
  14. <li class={ 'breadcrumb-item' +
  15. (idx == items.length - 1 ? ' active' : '') }>
  16. {
  17. (idx < items.length - 1) ? (
  18. <a href={ getItemUrl ? getItemUrl(item) : '#' }
  19. onclick={ onItemClicked ? ( e => { e.preventDefault();
  20. onItemClicked(item); } ) : null }>
  21. { typeof(item) === 'string' ? item : item['name'] }
  22. </a>
  23. ) : (
  24. typeof(item) === 'string' ? item : item['name']
  25. )
  26. }
  27. </li>
  28. )) }
  29. </ol>
  30. </nav>
  31. );
  32. }
  33. }
  34. WBBreadcrumbs.defaultProps = {
  35. onItemClicked: null,
  36. getItemUrl: null
  37. }
  38. export default WBBreadcrumbs;