From 196bc7fae184c5a9177a38893556bbd23b2c3b48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20H=C3=B8egh?= Date: Wed, 28 Feb 2024 09:07:35 +0100 Subject: [PATCH] fix(ProgressIndicator): align label spacing when size is `small` and use span instead of divs to support inline elements (#3344) After: Screenshot 2024-02-27 at 08 27 20 Before: Screenshot 2024-02-27 at 08 27 40 --- .../__snapshots__/Autocomplete.test.tsx.snap | 7 +- .../__snapshots__/Pagination.test.tsx.snap | 7 +- .../progress-indicator/ProgressIndicator.js | 17 +-- .../ProgressIndicatorCircular.js | 4 +- .../ProgressIndicatorLinear.js | 8 +- .../__tests__/ProgressIndicator.test.tsx | 111 +++++++++++++++++- .../ProgressIndicator.test.tsx.snap | 7 +- .../stories/ProgressIndicator.stories.tsx | 9 +- .../style/dnb-progress-indicator.scss | 7 +- 9 files changed, 152 insertions(+), 25 deletions(-) diff --git a/packages/dnb-eufemia/src/components/autocomplete/__tests__/__snapshots__/Autocomplete.test.tsx.snap b/packages/dnb-eufemia/src/components/autocomplete/__tests__/__snapshots__/Autocomplete.test.tsx.snap index f8c47433d4c..f45a7b5a0f2 100644 --- a/packages/dnb-eufemia/src/components/autocomplete/__tests__/__snapshots__/Autocomplete.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/autocomplete/__tests__/__snapshots__/Autocomplete.test.tsx.snap @@ -2373,10 +2373,13 @@ label + .dnb-dropdown[class*=__form-status] .dnb-dropdown__shell { } .dnb-progress-indicator--horizontal .dnb-progress-indicator__label { - margin: 0 1rem; + padding-left: 1rem; +} +.dnb-progress-indicator--horizontal.dnb-progress-indicator--small .dnb-progress-indicator__label { + padding-left: 0.5rem; } .dnb-progress-indicator--vertical .dnb-progress-indicator__label { - margin-top: 0.5rem; + padding-top: 0.5rem; } .dnb-progress-indicator__circular { position: relative; diff --git a/packages/dnb-eufemia/src/components/pagination/__tests__/__snapshots__/Pagination.test.tsx.snap b/packages/dnb-eufemia/src/components/pagination/__tests__/__snapshots__/Pagination.test.tsx.snap index ce6ec4c81f5..7a15739eeb7 100644 --- a/packages/dnb-eufemia/src/components/pagination/__tests__/__snapshots__/Pagination.test.tsx.snap +++ b/packages/dnb-eufemia/src/components/pagination/__tests__/__snapshots__/Pagination.test.tsx.snap @@ -614,10 +614,13 @@ button.dnb-button::-moz-focus-inner { } .dnb-progress-indicator--horizontal .dnb-progress-indicator__label { - margin: 0 1rem; + padding-left: 1rem; +} +.dnb-progress-indicator--horizontal.dnb-progress-indicator--small .dnb-progress-indicator__label { + padding-left: 0.5rem; } .dnb-progress-indicator--vertical .dnb-progress-indicator__label { - margin-top: 0.5rem; + padding-top: 0.5rem; } .dnb-progress-indicator__circular { position: relative; diff --git a/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicator.js b/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicator.js index b870a8b1094..69836f26e7d 100644 --- a/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicator.js +++ b/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicator.js @@ -124,9 +124,9 @@ export default class ProgressIndicator extends React.PureComponent { class: _className, children, title, - progress: _progress, //eslint-disable-line - visible: _visible, //eslint-disable-line - complete: _complete, //eslint-disable-line + progress: _progress, // eslint-disable-line + visible: _visible, // eslint-disable-line + complete: _complete, // eslint-disable-line ...attributes } = props @@ -142,13 +142,14 @@ export default class ProgressIndicator extends React.PureComponent { validateDOMAttributes(this.props, params) return ( -
)} {indicatorLabel && ( -
-

{indicatorLabel}

-
+ + {indicatorLabel} + )} -
+ ) } } diff --git a/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorCircular.js b/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorCircular.js index f7e4782b044..190419de79e 100644 --- a/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorCircular.js +++ b/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorCircular.js @@ -174,7 +174,7 @@ export default class ProgressIndicatorCircular extends React.PureComponent { validateDOMAttributes(this.props, params) return ( -
)} -
+ ) } } diff --git a/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorLinear.js b/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorLinear.js index 133263a46be..41873a08cd3 100644 --- a/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorLinear.js +++ b/packages/dnb-eufemia/src/components/progress-indicator/ProgressIndicatorLinear.js @@ -87,14 +87,14 @@ export default class ProgressIndicatorLinear extends React.PureComponent { validateDOMAttributes(this.props, params) return ( -
-
{!hasProgressValue && ( -
)} -
+ ) } } diff --git a/packages/dnb-eufemia/src/components/progress-indicator/__tests__/ProgressIndicator.test.tsx b/packages/dnb-eufemia/src/components/progress-indicator/__tests__/ProgressIndicator.test.tsx index 7489568a0c5..816d905dd0d 100644 --- a/packages/dnb-eufemia/src/components/progress-indicator/__tests__/ProgressIndicator.test.tsx +++ b/packages/dnb-eufemia/src/components/progress-indicator/__tests__/ProgressIndicator.test.tsx @@ -142,6 +142,54 @@ describe('Circular ProgressIndicator component', () => { const indicator = screen.getByRole('progressbar') expect(indicator.getAttribute('title')).toBe(title) }) + + it('should support spacing props', () => { + render( +