Skip to content

Commit 8be0d14

Browse files
authored
Merge pull request #119 from HelixDesignSystem/Breadcrumb
Breadcrumb
2 parents aed60b4 + 7a7e7af commit 8be0d14

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

src/Breadcrumb/index.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import PropTypes from 'prop-types';
2+
import React from 'react';
3+
4+
const Breadcrumb = ({ children, icon = 'angle-right', addDelimiter = true, ...rest }) => {
5+
// Automatically add delimiter
6+
const kids =
7+
children.length > 0
8+
? children.map((child, index) => [
9+
child,
10+
addDelimiter && index + 1 < children.length && (
11+
<hx-icon class="delimiter" type={icon}></hx-icon>
12+
),
13+
])
14+
: children;
15+
16+
return (
17+
<nav className="hxBreadcrumb" {...rest}>
18+
{kids}
19+
</nav>
20+
);
21+
};
22+
23+
Breadcrumb.propTypes = {
24+
icon: PropTypes.string,
25+
children: PropTypes.func,
26+
};
27+
28+
export default Breadcrumb;

src/Breadcrumb/stories.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import React from 'react';
2+
import { storiesOf } from '@storybook/react';
3+
import Breadcrumb from './index';
4+
5+
storiesOf('Breadcrumb', module)
6+
.add('Multiple Breadcrumbs', () => {
7+
return (
8+
<Breadcrumb>
9+
<a href="#">Home</a>
10+
<a href="#">Library</a>
11+
<a href="#">Current</a>
12+
</Breadcrumb>
13+
);
14+
})
15+
.add('Single Breadcrumb', () => {
16+
return (
17+
<Breadcrumb>
18+
<a href="#">Home</a>
19+
</Breadcrumb>
20+
);
21+
});

src/index.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Export helix-react definition */
22
import Alert from './Alert';
33
import Button from './Button';
4+
import Breadcrumb from './Breadcrumb';
45
import Busy from './Busy';
56
import Checkbox from './Checkbox';
67
import ChoiceTile from './ChoiceTile';
@@ -27,6 +28,7 @@ import Tooltip from './Tooltip';
2728
export {
2829
Alert,
2930
Button,
31+
Breadcrumb,
3032
Busy,
3133
Checkbox,
3234
ChoiceTile,

0 commit comments

Comments
 (0)