diff --git a/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases/eufemia/v11-info.mdx b/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases/eufemia/v11-info.mdx index 680df085079..419fa066c23 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases/eufemia/v11-info.mdx +++ b/packages/dnb-design-system-portal/src/docs/uilib/about-the-lib/releases/eufemia/v11-info.mdx @@ -92,4 +92,8 @@ The `InputPassword` component has been moved to `Field.Password`, and is now a p - remove `light` and `medium` as its not supported anymore. - replace `fullscreen` with `breakout`. +## Flex + +- replace `spacing` with `gap` on all Flex components. + _February, 6. 2024_ diff --git a/packages/dnb-design-system-portal/src/docs/uilib/components/fragments/text-counter/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/components/fragments/text-counter/Examples.tsx index 59250a1eb41..715735e4c49 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/components/fragments/text-counter/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/components/fragments/text-counter/Examples.tsx @@ -49,7 +49,7 @@ export function CountCharactersInteractive() { }) return ( - + { > - + { > - + { onSubmit={(data) => console.log('onSubmit', data)} filterSubmitData={filterDataHandler} > - + { required: ['name', 'address'], }} > - + Company information @@ -62,7 +62,7 @@ export const IfRuleSchema = () => { else: { required: ['name'] }, }} > - + Customer information @@ -147,16 +147,16 @@ export const DependantListSchema = () => { ], }} > - + Customer information - + Accounts - + Standard accounts diff --git a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Count/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Count/Examples.tsx index 46419dc8787..7df417de7a0 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Count/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/extensions/forms/Iterate/Count/Examples.tsx @@ -25,7 +25,7 @@ export const Interactive = () => { - + diff --git a/packages/dnb-design-system-portal/src/docs/uilib/layout/flex/container/Examples.tsx b/packages/dnb-design-system-portal/src/docs/uilib/layout/flex/container/Examples.tsx index be4cc0ac039..898d57c43e6 100644 --- a/packages/dnb-design-system-portal/src/docs/uilib/layout/flex/container/Examples.tsx +++ b/packages/dnb-design-system-portal/src/docs/uilib/layout/flex/container/Examples.tsx @@ -214,7 +214,7 @@ export const FramedLineDividers = () => { > {() => { const Item = () => ( - + FlexItem FlexItem diff --git a/packages/dnb-eufemia/src/components/card/Card.tsx b/packages/dnb-eufemia/src/components/card/Card.tsx index 9c942c869c7..22ea7f03d62 100644 --- a/packages/dnb-eufemia/src/components/card/Card.tsx +++ b/packages/dnb-eufemia/src/components/card/Card.tsx @@ -37,6 +37,7 @@ function Card(props: Props) { className, stack, direction, + gap, spacing, innerSpace, alignSelf = 'stretch', @@ -94,7 +95,7 @@ function Card(props: Props) { divider={divider} alignSelf={alignSelf} wrap={!stack} - spacing={stack ? 'medium' : spacing || false} + gap={stack ? 'medium' : (gap ?? spacing) || false} rowGap={rowGap || false} > {title && ( diff --git a/packages/dnb-eufemia/src/components/card/__tests__/Card.test.tsx b/packages/dnb-eufemia/src/components/card/__tests__/Card.test.tsx index 5d3bd8c2dc8..b39a3a3d698 100644 --- a/packages/dnb-eufemia/src/components/card/__tests__/Card.test.tsx +++ b/packages/dnb-eufemia/src/components/card/__tests__/Card.test.tsx @@ -197,7 +197,7 @@ describe('Card', () => { it('should add spacing between elements', () => { const { rerender } = render( - +

Paragraph

Paragraph

Paragraph

@@ -222,7 +222,7 @@ describe('Card', () => { expect(children[2]).toHaveClass('dnb-space__bottom--zero') rerender( - +

Paragraph

Paragraph

Paragraph

diff --git a/packages/dnb-eufemia/src/components/flex/Container.tsx b/packages/dnb-eufemia/src/components/flex/Container.tsx index b974a9ec3ff..008c61390e5 100644 --- a/packages/dnb-eufemia/src/components/flex/Container.tsx +++ b/packages/dnb-eufemia/src/components/flex/Container.tsx @@ -17,6 +17,16 @@ import type { UseMediaQueries } from '../../shared/useMedia' import type { End, Start } from './types' import Item from './Item' +type Gap = + | false + | 'xx-small' + | 'x-small' + | 'small' + | 'medium' + | 'large' + | 'x-large' + | 'xx-large' + export type BasicProps = { direction?: 'horizontal' | 'vertical' wrap?: boolean @@ -35,15 +45,9 @@ export type BasicProps = { /** When "line-framed" is used, a line will be shown between items and above the first and below the last item */ divider?: 'space' | 'line' | 'line-framed' /** Spacing between items inside */ - spacing?: - | false - | 'xx-small' - | 'x-small' - | 'small' - | 'medium' - | 'large' - | 'x-large' - | 'xx-large' + gap?: Gap + /** @deprecated Use `gap` instead */ + spacing?: Gap breakpoints?: MediaQueryBreakpoints queries?: UseMediaQueries } @@ -62,6 +66,7 @@ const propNames: Array = [ 'align', 'divider', 'spacing', + 'gap', ] export function pickFlexContainerProps( @@ -95,6 +100,7 @@ function FlexContainer(props: Props) { align = 'flex-start', alignSelf, divider = 'space', + gap = 'small', spacing = 'small', breakpoints, queries, @@ -181,8 +187,11 @@ function FlexContainer(props: Props) { !isHeading && ((divider === 'line' && !isFirst) || divider === 'line-framed') ) { - const spaceAboveLine = getSpaceValue(end, previousChild) ?? spacing - startSpacing = (getSpaceValue(start, child) ?? spacing) as SpaceType + const spaceAboveLine = + getSpaceValue(end, previousChild) ?? gap ?? spacing + startSpacing = (getSpaceValue(start, child) ?? + gap ?? + spacing) as SpaceType return ( @@ -211,8 +220,9 @@ function FlexContainer(props: Props) { if (hasSizeProp) { // When we have a size prop, we don't expect the layout to wrap, // so we add space to the start of each item to mimic CSS gap. - startSpacing = isRowStart || isFirst ? 0 : sumTypes(spacing) / 2 - endSpacing = isRowEnd || isLast ? 0 : sumTypes(spacing) / 2 + startSpacing = + isRowStart || isFirst ? 0 : sumTypes(gap ?? spacing) / 2 + endSpacing = isRowEnd || isLast ? 0 : sumTypes(gap ?? spacing) / 2 } else { // Since we expect the layout to wrap, we add space only to the end of each item, // except for the last item. This will make the items align as long as not wrapped. @@ -221,6 +231,7 @@ function FlexContainer(props: Props) { ? 0 : getSpaceValue(start, child) ?? getSpaceValue(end, previousChild) ?? + gap ?? spacing } } else { @@ -232,6 +243,7 @@ function FlexContainer(props: Props) { startSpacing = getSpaceValue(start, child) ?? getSpaceValue(end, previousChild) ?? + gap ?? spacing } } @@ -277,14 +289,14 @@ function FlexContainer(props: Props) { return `${n}--row-gap-small` } - if (hasSizeProp && spacing) { - return `${n}--row-gap-${spacing}` + if (hasSizeProp && (gap ?? spacing)) { + return `${n}--row-gap-${gap ?? spacing}` } if (rowGap) { return `${n}--row-gap-${rowGap}` } - }, [direction, hasSizeProp, rowGap, spacing, wrap]) + }, [direction, hasSizeProp, rowGap, gap, spacing, wrap]) const cn = classnames( 'dnb-flex-container', @@ -292,7 +304,7 @@ function FlexContainer(props: Props) { justify && `${n}--justify-${justify}`, align && `${n}--align-${align}`, alignSelf && `${n}--align-self-${alignSelf}`, - spacing && `${n}--spacing-${spacing}`, + (gap ?? spacing) && `${n}--spacing-${gap ?? spacing}`, wrap && `${n}--wrap`, getRowGapClass(), hasSizeProp && `${n}--has-size`, diff --git a/packages/dnb-eufemia/src/components/flex/Stack.tsx b/packages/dnb-eufemia/src/components/flex/Stack.tsx index 559d7eb6eff..2a120253408 100644 --- a/packages/dnb-eufemia/src/components/flex/Stack.tsx +++ b/packages/dnb-eufemia/src/components/flex/Stack.tsx @@ -11,7 +11,7 @@ function Stack(props: Props) { direction = 'vertical', alignSelf = 'stretch', align = 'stretch', - spacing = props.divider !== 'line' && props.divider !== 'line-framed' + gap = props.divider !== 'line' && props.divider !== 'line-framed' ? 'medium' : 'small', children, @@ -25,7 +25,7 @@ function Stack(props: Props) { direction={direction} alignSelf={alignSelf} align={align} - spacing={spacing} + gap={gap} {...rest} > {children} diff --git a/packages/dnb-eufemia/src/components/flex/__tests__/Container.test.tsx b/packages/dnb-eufemia/src/components/flex/__tests__/Container.test.tsx index 321c73fa098..05e4003a878 100644 --- a/packages/dnb-eufemia/src/components/flex/__tests__/Container.test.tsx +++ b/packages/dnb-eufemia/src/components/flex/__tests__/Container.test.tsx @@ -364,7 +364,7 @@ describe('Flex.Container', () => { expect(children[2]).toHaveClass('dnb-space__right--zero') rerender( - + Flex Flex Flex @@ -381,7 +381,7 @@ describe('Flex.Container', () => { expect(children[2]).toHaveClass('dnb-space__right--zero') rerender( - + Flex Flex Flex @@ -400,7 +400,7 @@ describe('Flex.Container', () => { it('should not apply spacing if set to false', () => { render( - + Flex Flex Flex diff --git a/packages/dnb-eufemia/src/components/flex/__tests__/Item.test.tsx b/packages/dnb-eufemia/src/components/flex/__tests__/Item.test.tsx index 42a62fe68ca..f4ddcb95eae 100644 --- a/packages/dnb-eufemia/src/components/flex/__tests__/Item.test.tsx +++ b/packages/dnb-eufemia/src/components/flex/__tests__/Item.test.tsx @@ -395,7 +395,7 @@ describe('Flex.Item', () => { it('should use given "spacing" size from FlexContainer', () => { const { rerender } = render( - + FlexItem FlexItem diff --git a/packages/dnb-eufemia/src/components/flex/__tests__/Stack.test.tsx b/packages/dnb-eufemia/src/components/flex/__tests__/Stack.test.tsx index 26cacbbbb80..13ae6408ba4 100644 --- a/packages/dnb-eufemia/src/components/flex/__tests__/Stack.test.tsx +++ b/packages/dnb-eufemia/src/components/flex/__tests__/Stack.test.tsx @@ -50,7 +50,7 @@ describe('Flex.Stack', () => { }) it('should support "spacing" property', () => { - render(content) + render(content) const element = document.querySelector('.dnb-flex-stack') @@ -63,7 +63,7 @@ describe('Flex.Stack', () => { }) it('should omit spacing when "spacing" is false', () => { - render(content) + render(content) const element = document.querySelector('.dnb-flex-stack') diff --git a/packages/dnb-eufemia/src/components/flex/stories/Flex.stories.tsx b/packages/dnb-eufemia/src/components/flex/stories/Flex.stories.tsx index fcc1e2c520b..b6af93fbcae 100644 --- a/packages/dnb-eufemia/src/components/flex/stories/Flex.stories.tsx +++ b/packages/dnb-eufemia/src/components/flex/stories/Flex.stories.tsx @@ -63,7 +63,7 @@ export function FlexWithChildren() { } const Item = () => ( - + FlexItem FlexItem diff --git a/packages/dnb-eufemia/src/extensions/forms/DataContext/Provider/stories/Provider.stories.tsx b/packages/dnb-eufemia/src/extensions/forms/DataContext/Provider/stories/Provider.stories.tsx index dbbc6385a10..5a16a733132 100644 --- a/packages/dnb-eufemia/src/extensions/forms/DataContext/Provider/stories/Provider.stories.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/DataContext/Provider/stories/Provider.stories.tsx @@ -112,7 +112,7 @@ export const FilterData = () => { onSubmit={(data) => console.log('onSubmit', data)} filterSubmitData={filterDataHandler} > - + +