From 5fdbe02ac4d7831d00879c032e690fac44200082 Mon Sep 17 00:00:00 2001 From: Allison Shultes Date: Mon, 2 Sep 2019 17:01:17 +0100 Subject: [PATCH 1/3] Adds custom breadcrumb component --- packages/components/Breadcrumb/index.js | 45 +++++++++++++++++ .../Breadcrumb/stories/index.stories.js | 49 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 packages/components/Breadcrumb/index.js create mode 100644 packages/components/Breadcrumb/stories/index.stories.js 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..4baf820 --- /dev/null +++ b/packages/components/Breadcrumb/stories/index.stories.js @@ -0,0 +1,49 @@ +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 ( +
+ +
+ + ); + }); From 79e603bb6bf9cfc4d4bee5abfd4e492408997d7c Mon Sep 17 00:00:00 2001 From: Alli Shultes Date: Fri, 6 Sep 2019 17:34:20 +0100 Subject: [PATCH 2/3] Update packages/components/Breadcrumb/stories/index.stories.js Co-Authored-By: Eimi Okuno --- packages/components/Breadcrumb/stories/index.stories.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/Breadcrumb/stories/index.stories.js b/packages/components/Breadcrumb/stories/index.stories.js index 4baf820..69b6a4e 100644 --- a/packages/components/Breadcrumb/stories/index.stories.js +++ b/packages/components/Breadcrumb/stories/index.stories.js @@ -9,7 +9,8 @@ export const breadcrumbItems = { link: '/projects', }, { name: 'Example project name' - } ], paperEdits: [ { + } ], +paperEdits: [ { name: 'Projects', link: '/projects' }, From 44083e95517858ec9811e0bc20be9999fe49eb1c Mon Sep 17 00:00:00 2001 From: Allison Shultes Date: Fri, 6 Sep 2019 17:38:43 +0100 Subject: [PATCH 3/3] Tweaks to closed brackets and braces --- .../components/Breadcrumb/stories/index.stories.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/components/Breadcrumb/stories/index.stories.js b/packages/components/Breadcrumb/stories/index.stories.js index 69b6a4e..449ecab 100644 --- a/packages/components/Breadcrumb/stories/index.stories.js +++ b/packages/components/Breadcrumb/stories/index.stories.js @@ -10,21 +10,17 @@ export const breadcrumbItems = { }, { name: 'Example project name' } ], -paperEdits: [ { + paperEdits: [ { name: 'Projects', link: '/projects' - }, - { + }, { name: 'Project: The Sample', link: '/projects/the-sample' - }, - { + }, { name: 'PaperEdits', - }, - { + }, { name: 'Example programme title' - } - ] + } ] }; storiesOf('Breadcrumb', module)