|
@@ -1,7 +1,7 @@ |
|
|
import { h, Component } from 'preact';
|
|
|
import { h, Component } from 'preact';
|
|
|
|
|
|
|
|
|
class WBBreadcrumbs extends Component {
|
|
|
class WBBreadcrumbs extends Component {
|
|
|
render({ items, onItemClicked }) {
|
|
|
|
|
|
|
|
|
render({ items, onItemClicked, getItemUrl }) {
|
|
|
return (
|
|
|
return (
|
|
|
<nav aria-label="breadcrumb">
|
|
|
<nav aria-label="breadcrumb">
|
|
|
<ol class="breadcrumb">
|
|
|
<ol class="breadcrumb">
|
|
@@ -10,8 +10,11 @@ class WBBreadcrumbs extends Component { |
|
|
(idx == items.length - 1 ? ' active' : '') }>
|
|
|
(idx == items.length - 1 ? ' active' : '') }>
|
|
|
{
|
|
|
{
|
|
|
(idx < items.length - 1) ? (
|
|
|
(idx < items.length - 1) ? (
|
|
|
<a href="#" onclick={ e => { e.preventDefault();
|
|
|
|
|
|
onItemClicked(item); } }>{ typeof(item) === 'string' ? item : item['name'] }</a>
|
|
|
|
|
|
|
|
|
<a href={ getItemUrl ? getItemUrl(item) : '#' }
|
|
|
|
|
|
onclick={ onItemClicked ? ( e => { e.preventDefault();
|
|
|
|
|
|
onItemClicked(item); } ) : null }>
|
|
|
|
|
|
{ typeof(item) === 'string' ? item : item['name'] }
|
|
|
|
|
|
</a>
|
|
|
) : (
|
|
|
) : (
|
|
|
typeof(item) === 'string' ? item : item['name']
|
|
|
typeof(item) === 'string' ? item : item['name']
|
|
|
)
|
|
|
)
|
|
@@ -25,7 +28,8 @@ class WBBreadcrumbs extends Component { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
WBBreadcrumbs.defaultProps = {
|
|
|
WBBreadcrumbs.defaultProps = {
|
|
|
'onItemClicked': () => {}
|
|
|
|
|
|
|
|
|
onItemClicked: null,
|
|
|
|
|
|
getItemUrl: null
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
export default WBBreadcrumbs;
|
|
|
export default WBBreadcrumbs;
|