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.

36 line
1.0KB

  1. import { h, Component } from 'preact';
  2. class WBBreadcrumbs extends Component {
  3. render({ items, onItemClicked, getItemUrl }) {
  4. return (
  5. <nav aria-label="breadcrumb">
  6. <ol class="breadcrumb">
  7. { items.map((item, idx) => (
  8. <li class={ 'breadcrumb-item' +
  9. (idx == items.length - 1 ? ' active' : '') }>
  10. {
  11. (idx < items.length - 1) ? (
  12. <a href={ getItemUrl ? getItemUrl(item) : '#' }
  13. onclick={ onItemClicked ? ( e => { e.preventDefault();
  14. onItemClicked(item); } ) : null }>
  15. { typeof(item) === 'string' ? item : item['name'] }
  16. </a>
  17. ) : (
  18. typeof(item) === 'string' ? item : item['name']
  19. )
  20. }
  21. </li>
  22. )) }
  23. </ol>
  24. </nav>
  25. );
  26. }
  27. }
  28. WBBreadcrumbs.defaultProps = {
  29. onItemClicked: null,
  30. getItemUrl: null
  31. }
  32. export default WBBreadcrumbs;