diff --git a/src/Breadcrumb/index.js b/src/Breadcrumb/index.js new file mode 100644 index 0000000..aab8349 --- /dev/null +++ b/src/Breadcrumb/index.js @@ -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 && ( + + ), + ]) + : children; + + return ( + + ); +}; + +Breadcrumb.propTypes = { + icon: PropTypes.string, + children: PropTypes.func, +}; + +export default Breadcrumb; diff --git a/src/Breadcrumb/stories.js b/src/Breadcrumb/stories.js new file mode 100644 index 0000000..56dfd0f --- /dev/null +++ b/src/Breadcrumb/stories.js @@ -0,0 +1,21 @@ +import React from 'react'; +import { storiesOf } from '@storybook/react'; +import Breadcrumb from './index'; + +storiesOf('Breadcrumb', module) + .add('Multiple Breadcrumbs', () => { + return ( + + Home + Library + Current + + ); + }) + .add('Single Breadcrumb', () => { + return ( + + Home + + ); + }); diff --git a/src/index.mjs b/src/index.mjs index c00e075..bf47a80 100644 --- a/src/index.mjs +++ b/src/index.mjs @@ -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'; @@ -26,6 +27,7 @@ import Tooltip from './Tooltip'; export { Alert, Button, + Breadcrumb, Busy, Checkbox, ChoiceTile,