diff --git a/packages/core/src/layout/Breadcrumbs/Breadcrumbs.stories.tsx b/packages/core/src/layout/Breadcrumbs/Breadcrumbs.stories.tsx
index 18569a8dad..f21b5a94e6 100644
--- a/packages/core/src/layout/Breadcrumbs/Breadcrumbs.stories.tsx
+++ b/packages/core/src/layout/Breadcrumbs/Breadcrumbs.stories.tsx
@@ -15,31 +15,21 @@
*/
import React from 'react';
import { Breadcrumbs } from '.';
+import { MemoryRouter } from 'react-router-dom';
+import { Link } from '../../components/Link';
export default {
title: 'Layout/Breadcrumbs',
component: Breadcrumbs,
};
-const pages = [
- {
- href: '/',
- name: 'A',
- },
- {
- href: '/',
- name: 'B',
- },
- {
- href: '/',
- name: 'C',
- },
- {
- href: '/',
- name: 'D',
- },
-];
-
// export const InHeader = () => ;
-export const OutsideOfHeader = () => ;
+export const OutsideOfHeader = () => (
+
+
+ Home
+ Home
+
+
+);
// export const ExampleUsage = () => ;
diff --git a/packages/core/src/layout/Breadcrumbs/Breadcrumbs.tsx b/packages/core/src/layout/Breadcrumbs/Breadcrumbs.tsx
index 78761d9db2..c88b446d8c 100644
--- a/packages/core/src/layout/Breadcrumbs/Breadcrumbs.tsx
+++ b/packages/core/src/layout/Breadcrumbs/Breadcrumbs.tsx
@@ -14,80 +14,75 @@
* limitations under the License.
*/
-import React from 'react';
+import React, { Fragment } from 'react';
import {
- Link,
Typography,
Breadcrumbs as MUIBreadcrumbs,
Popover,
withStyles,
} from '@material-ui/core';
-type BreadcrumbPage = {
- href: string;
- name: string;
-};
-
type BreadcrumbsProps = {
- pages: (BreadcrumbPage | BreadcrumbPage)[];
+ children?: React.ReactNode;
};
const UnderlinedText = withStyles({ root: { textDecoration: 'underline' } })(
Typography,
);
-const Breadcrumb = ({ page }: { page: BreadcrumbPage }) => (
-
- {page.name}
-
-);
+const StyledBreadcrumbs = withStyles({
+ root: {},
+ li: { textDecoration: 'underline' },
+})(MUIBreadcrumbs);
-// Should propbably take Routes instead, to work with the react-router
-export const Breadcrumbs = ({ pages }: BreadcrumbsProps) => {
+export const Breadcrumbs = ({ children }: BreadcrumbsProps) => {
const [anchorEl, setAnchorEl] = React.useState(
null,
);
- const hasHiddenBreadcrumbs = pages.length > 3;
- const [firstPage, secondPage, ...expandablePages] = pages;
- const currentPage = pages[pages.length - 1];
- const handleClick = (event: React.MouseEvent) => {
- setAnchorEl(event.currentTarget);
- };
+ if (children instanceof Array) {
+ const [firstPage, secondPage, ...expandablePages] = children;
+ const currentPage = children[children.length - 1];
+ const hasHiddenBreadcrumbs = children.length > 3;
- const handleClose = () => {
- setAnchorEl(null);
- };
+ const handleClick = (event: React.MouseEvent) => {
+ setAnchorEl(event.currentTarget);
+ };
- const open = Boolean(anchorEl);
+ const handleClose = () => {
+ setAnchorEl(null);
+ };
+ const open = Boolean(anchorEl);
+ return (
+
+
+ {children.length > 1 && firstPage}
+ {children.length > 2 && secondPage}
+ {hasHiddenBreadcrumbs && (
+ ...
+ )}
+ {currentPage}
+
+
+ The content of the Popover.
+
+
+ );
+ }
return (
-
- {firstPage && pages.length > 1 && }
- {secondPage && pages.length > 2 && }
- {hasHiddenBreadcrumbs && (
- ...
- )}
- {currentPage && {currentPage.name}}
-
- The content of the Popover.
-
-
+ {children}
);
};