Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Breadcrumb/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import PropTypes from 'prop-types';
import React from 'react';

const Breadcrumb = ({ children, icon = 'angle-right', addDelimiter = true, ...rest }) => {
// Automatically add delimiter
const kids =
children.length > 0
? children.map((child, index) => [
child,
addDelimiter && index + 1 < children.length && (
<hx-icon class="delimiter" type={icon}></hx-icon>
),
])
: children;

return (
<nav className="hxBreadcrumb" {...rest}>
{kids}
</nav>
);
};

Breadcrumb.propTypes = {
icon: PropTypes.string,
children: PropTypes.func,
};

export default Breadcrumb;
21 changes: 21 additions & 0 deletions src/Breadcrumb/stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react';
import { storiesOf } from '@storybook/react';
import Breadcrumb from './index';

storiesOf('Breadcrumb', module)
.add('Multiple Breadcrumbs', () => {
return (
<Breadcrumb>
<a href="#">Home</a>
<a href="#">Library</a>
<a href="#">Current</a>
</Breadcrumb>
);
})
.add('Single Breadcrumb', () => {
return (
<Breadcrumb>
<a href="#">Home</a>
</Breadcrumb>
);
});
2 changes: 2 additions & 0 deletions src/index.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Export helix-react definition */
import Alert from './Alert';
import Button from './Button';
import Breadcrumb from './Breadcrumb';
import Busy from './Busy';
import Checkbox from './Checkbox';
import ChoiceTile from './ChoiceTile';
Expand All @@ -26,6 +27,7 @@ import Tooltip from './Tooltip';
export {
Alert,
Button,
Breadcrumb,
Busy,
Checkbox,
ChoiceTile,
Expand Down