From 8a6f09b564d5d2f02d0a2605f6b52070a910aaa3 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Mon, 25 Apr 2022 12:57:12 +0200 Subject: chore: add a PageLayout component --- .../molecules/nav/breadcrumb.stories.tsx | 13 +++++++++++++ src/components/molecules/nav/breadcrumb.tsx | 22 ++++++++++++++++++---- 2 files changed, 31 insertions(+), 4 deletions(-) (limited to 'src/components/molecules/nav') diff --git a/src/components/molecules/nav/breadcrumb.stories.tsx b/src/components/molecules/nav/breadcrumb.stories.tsx index 500ae6c..e26b480 100644 --- a/src/components/molecules/nav/breadcrumb.stories.tsx +++ b/src/components/molecules/nav/breadcrumb.stories.tsx @@ -22,6 +22,19 @@ export default { required: false, }, }, + itemClassName: { + control: { + type: 'text', + }, + table: { + category: 'Styles', + }, + description: 'Set additional classnames to the breadcrumb items.', + type: { + name: 'string', + required: false, + }, + }, items: { description: 'The breadcrumb items.', type: { diff --git a/src/components/molecules/nav/breadcrumb.tsx b/src/components/molecules/nav/breadcrumb.tsx index 6dc86a0..d184d65 100644 --- a/src/components/molecules/nav/breadcrumb.tsx +++ b/src/components/molecules/nav/breadcrumb.tsx @@ -26,6 +26,10 @@ export type BreadcrumbProps = { * Set additional classnames to the nav element. */ className?: string; + /** + * Set additional classnames to the breadcrumb items. + */ + itemClassName?: string; /** * The breadcrumb items */ @@ -37,9 +41,19 @@ export type BreadcrumbProps = { * * Render a breadcrumb navigation. */ -const Breadcrumb: FC = ({ items, ...props }) => { +const Breadcrumb: FC = ({ + itemClassName = '', + items, + ...props +}) => { const intl = useIntl(); + const ariaLabel = intl.formatMessage({ + defaultMessage: 'Breadcrumb', + description: 'Breadcrumb: an accessible name for the breadcrumb nav.', + id: '28nnDY', + }); + /** * Retrieve the breadcrumb list items. * @@ -49,12 +63,12 @@ const Breadcrumb: FC = ({ items, ...props }) => { const getListItems = (list: BreadcrumbItem[]): JSX.Element[] => { return list.map((item, index) => { const isLastItem = index === list.length - 1; - const itemClassnames = isLastItem + const itemStyles = isLastItem ? `${styles.item} screen-reader-text` : styles.item; return ( -
  • +
  • {isLastItem ? item.name : {item.name}}
  • ); @@ -96,7 +110,7 @@ const Breadcrumb: FC = ({ items, ...props }) => { type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(schemaJsonLd) }} /> -