From 52b07599cd3c665d1be3652307c26973f520b196 Mon Sep 17 00:00:00 2001 From: HichamELBSI Date: Mon, 26 Sep 2022 11:54:37 +0200 Subject: [PATCH] Fix Breadcrumb with one Crumb --- .../src/v2/Breadcrumbs/Breadcrumbs.js | 4 +- .../v2/Breadcrumbs/Breadcrumbs.stories.mdx | 12 ++ .../__snapshots__/storyshots.spec.js.snap | 125 ++++++++++++++++++ 3 files changed, 139 insertions(+), 2 deletions(-) diff --git a/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.js b/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.js index 0623d031c..7c3d3c65b 100644 --- a/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.js +++ b/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.js @@ -21,12 +21,12 @@ export const Breadcrumbs = ({ label, children, ...props }) => { {Children.map(children, (child, index) => { - const isLast = index + 1 === children.length; + const shouldDisplayDivider = children.length > 1 && index + 1 < children.length; return ( {child} - {!isLast && } + {shouldDisplayDivider && } ); })} diff --git a/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.stories.mdx b/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.stories.mdx index 05397fbb8..878bd656f 100644 --- a/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.stories.mdx +++ b/packages/strapi-design-system/src/v2/Breadcrumbs/Breadcrumbs.stories.mdx @@ -81,6 +81,18 @@ Breadcrumbs with Crumb are visual information only and cannot be navigated. They +## Single link + + + + + + Category + + + + + ### Usage with other routing libraries To use the Link component with a routing library (e.g. react-router-dom), you'll need to pass the `NavLink` component to the `as` prop in order to replace the default HTML anchor ``. diff --git a/packages/strapi-design-system/tests/__snapshots__/storyshots.spec.js.snap b/packages/strapi-design-system/tests/__snapshots__/storyshots.spec.js.snap index c63d1fc3a..a94d84018 100644 --- a/packages/strapi-design-system/tests/__snapshots__/storyshots.spec.js.snap +++ b/packages/strapi-design-system/tests/__snapshots__/storyshots.spec.js.snap @@ -51981,6 +51981,131 @@ exports[`Storyshots Design System/Components/v2/Breadcrumbs base 1`] = ` `; +exports[`Storyshots Design System/Components/v2/Breadcrumbs single-link 1`] = ` +.c1 { + border: 0; + -webkit-clip: rect(0 0 0 0); + clip: rect(0 0 0 0); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; +} + +.c0 { + background: #ffffff; + padding: 8px; +} + +.c2 { + padding: 8px; + height: 100%; +} + +.c7 { + padding-top: 4px; + padding-right: 8px; + padding-bottom: 4px; + padding-left: 8px; +} + +.c8 { + color: #32324d; + font-size: 0.75rem; + line-height: 1.33; +} + +.c3 { + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; +} + +.c6 { + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + -webkit-flex-direction: row; + -ms-flex-direction: row; + flex-direction: row; +} + +.c4 > * { + margin-left: 0; + margin-right: 0; +} + +.c4 > * + * { + margin-left: 12px; +} + +.c5:first-child { + margin-left: calc(-1*8px); +} + +
+
+
+

+ Storybook story +

+
+
+
+
+
    +
  1. +
    + + Category + +
    +
  2. +
+
+
+
+
+
+`; + exports[`Storyshots Design System/Components/v2/Breadcrumbs with-menu 1`] = ` .c2 { border: 0;