From 699629ceeff3258d2277f1a83c9160c11e4e59b1 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 21 Sep 2022 15:39:30 +0200 Subject: [PATCH] feat(Breadcumb): align spacing and add small, medium and large --- .../uilib/components/breadcrumb/properties.md | 2 +- .../src/components/breadcrumb/Breadcrumb.tsx | 19 +- .../breadcrumb/BreadcrumbMultiple.tsx | 9 +- .../__snapshots__/Breadcrumb.test.tsx.snap | 666 +++++++++++++++++- ...match-breadcrumb-collapse-1-99672.snap.png | Bin 2097 -> 2039 bytes ...readcrumb-collapse-opened-1-2b97c.snap.png | Bin 7622 -> 7577 bytes ...match-breadcrumb-multiple-1-b85aa.snap.png | Bin 7424 -> 7306 bytes ...mb-multiple-with-children-1-dbdd2.snap.png | Bin 4813 -> 4719 bytes .../breadcrumb/stories/Breadcrumb.stories.tsx | 6 +- .../breadcrumb/style/_breadcrumb.scss | 17 +- .../breadcrumb/style/dnb-breadcrumb.scss | 4 + 11 files changed, 698 insertions(+), 25 deletions(-) diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/breadcrumb/properties.md b/packages/dnb-design-system-portal/src/docs/uilib/components/breadcrumb/properties.md index dcb7d6c457c..2a5833752b7 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/breadcrumb/properties.md +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/breadcrumb/properties.md @@ -22,7 +22,7 @@ showTabs: true | `collapsedStyleType` | _(optional)_ Use one of the Section component style types (style_type). Defaults to `pistachio`. | | `className` | _(optional)_ Custom className for the component root. | | `isCollapsed` | _(optional)_ For variant `collapse`, override isCollapsed for the collapsed content by updating this value using the provided property `onClick`. | -| `spacing` | _(optional)_ Include spacing in breadcrumb and collapse content by setting `spacing={true}` prop. Defaults to `false`. | +| `spacing` | _(optional)_ Include spacing properties from [Section](/uilib/components/section/properties) in breadcrumb. If only `true` is given, the spacing will be `small`. Defaults to `false`. | | [Space](/uilib/components/space/properties) | _(optional)_ spacing properties like `top` or `bottom` are supported. | ### `Breadcrumb.Item` properties diff --git a/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx b/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx index 7867bb43be3..cf35e74d2d8 100644 --- a/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx +++ b/packages/dnb-eufemia/src/components/breadcrumb/Breadcrumb.tsx @@ -4,7 +4,10 @@ import classnames from 'classnames' // Components import { createSkeletonClass } from '../skeleton/SkeletonHelper' import { createSpacingClasses } from '../space/SpacingHelper' -import Section, { SectionStyleTypes } from '../section/Section' +import Section, { + SectionSpacing, + SectionStyleTypes, +} from '../section/Section' import Button from '../button/Button' // Shared @@ -17,6 +20,7 @@ import { SkeletonShow } from '../skeleton/Skeleton' import BreadcrumbItem, { BreadcrumbItemProps } from './BreadcrumbItem' import { convertJsxToString, + isTrue, validateDOMAttributes, extendPropsWithContext, } from '../../shared/component-helper' @@ -108,10 +112,10 @@ export interface BreadcrumbProps { collapsedStyleType?: SectionStyleTypes /** - * Spacing around the breadcrumb + * Include spacing properties from the Section component in breadcrumb. If only `true` is given, the spacing will be `small`. * Default: false */ - spacing?: boolean + spacing?: SectionSpacing /** * Will disable the height animation @@ -188,6 +192,8 @@ const Breadcrumb = (localProps: BreadcrumbProps & ISpacingProps) => { validateDOMAttributes(allProps, props) + const innerSpacing = isTrue(spacing) ? 'small' : spacing + return (