diff --git a/packages/components/Breadcrumb/index.js b/packages/components/Breadcrumb/index.js new file mode 100644 index 0000000..448bc12 --- /dev/null +++ b/packages/components/Breadcrumb/index.js @@ -0,0 +1,45 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import Breadcrumb from 'react-bootstrap/Breadcrumb'; +import { LinkContainer } from 'react-router-bootstrap'; + +const CustomBreadcrumb = (props) => { + + const breadcrumbs = props.items.map((item) => { + if (item.link) { + return ( + + {item.name} + + ); + } else { + return ( + + {item.name} + + ); + } + }); + + return ( +
+ + {breadcrumbs} + +
+ ); +}; + +CustomBreadcrumb.propTypes = { + items: PropTypes.list, +}; + +CustomBreadcrumb.defaultProps = { + items: [ { + name: 'Projects', + link: '/projects', + }, { + name: 'Sample Project Name' + } ] }; + +export default CustomBreadcrumb; diff --git a/packages/components/Breadcrumb/stories/index.stories.js b/packages/components/Breadcrumb/stories/index.stories.js new file mode 100644 index 0000000..449ecab --- /dev/null +++ b/packages/components/Breadcrumb/stories/index.stories.js @@ -0,0 +1,46 @@ +import React from 'react'; +import { storiesOf } from '@storybook/react'; +import StoryRouter from 'storybook-react-router'; +import Breadcrumb from '../index.js'; + +export const breadcrumbItems = { + projects: [ { + name: 'Projects', + link: '/projects', + }, { + name: 'Example project name' + } ], + paperEdits: [ { + name: 'Projects', + link: '/projects' + }, { + name: 'Project: The Sample', + link: '/projects/the-sample' + }, { + name: 'PaperEdits', + }, { + name: 'Example programme title' + } ] +}; + +storiesOf('Breadcrumb', module) + .addDecorator(StoryRouter()) + .add('Projects', () => { + return ( +
+ +
+ ); + }) + .add('Paper Edits', () => { + return ( +
+ +
+ + ); + });