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}
+
)}
-
+
)
}
}
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(
+
+ )
+
+ const indicator = document.querySelector('.dnb-progress-indicator')
+ expect(Array.from(indicator.classList)).toEqual([
+ 'dnb-progress-indicator',
+ 'dnb-space__top--large',
+ 'dnb-progress-indicator--visible',
+ 'dnb-progress-indicator--horizontal',
+ 'dnb-progress-indicator--default',
+ ])
+ })
+
+ it('should support custom attributes', () => {
+ render(
+
+ )
+
+ const indicator = document.querySelector('.dnb-progress-indicator')
+ const attributes = Array.from(indicator.attributes).map(
+ (attr) => attr.name
+ )
+ expect(attributes).toEqual(['class', 'hidden'])
+ })
+
+ it('should use span elements', () => {
+ const { container } = render(
+
+ )
+
+ expect(container.querySelectorAll('div')).toHaveLength(0)
+ expect(container.querySelectorAll('span')).toHaveLength(3)
+ })
+
+ it('should use span for label element', () => {
+ // Because it does not have any advantages over a label element (VoiceOver does not read it as a label)
+
+ const { container } = render(
+
+ )
+
+ expect(
+ container.querySelector('.dnb-progress-indicator__label').tagName
+ ).toBe('SPAN')
+ })
})
describe('Linear ProgressIndicator component', () => {
@@ -282,19 +330,78 @@ describe('Linear ProgressIndicator component', () => {
const indicator = screen.getByRole('progressbar')
expect(indicator.getAttribute('title')).toBe(title)
})
+
+ it('should support spacing props', () => {
+ render(
+
+ )
+
+ const indicator = document.querySelector('.dnb-progress-indicator')
+ expect(Array.from(indicator.classList)).toEqual([
+ 'dnb-progress-indicator',
+ 'dnb-space__top--large',
+ 'dnb-progress-indicator--visible',
+ 'dnb-progress-indicator--horizontal',
+ 'dnb-progress-indicator--default',
+ 'dnb-progress-indicator--full-width',
+ ])
+ })
+
+ it('should support custom attributes', () => {
+ render(
+
+ )
+
+ const indicator = document.querySelector('.dnb-progress-indicator')
+ const attributes = Array.from(indicator.attributes).map(
+ (attr) => attr.name
+ )
+ expect(attributes).toEqual(['class', 'hidden'])
+ })
+
+ it('should use span elements', () => {
+ const { container } = render(
+
+ )
+
+ expect(container.querySelectorAll('div')).toHaveLength(0)
+ expect(container.querySelectorAll('span')).toHaveLength(4)
+ })
+
+ it('should use span for label element', () => {
+ // Because it does not have any advantages over a label element (VoiceOver does not read it as a label)
+
+ const { container } = render(
+
+ )
+
+ expect(
+ container.querySelector('.dnb-progress-indicator__label').tagName
+ ).toBe('SPAN')
+ })
})
describe('ProgressIndicator ARIA', () => {
it('should validate with ARIA rules on type circular', async () => {
const Comp = render(
-
+
)
expect(await axeComponent(Comp)).toHaveNoViolations()
})
it('should validate with ARIA rules on type linear', async () => {
const Comp = render(
-
+
)
expect(await axeComponent(Comp)).toHaveNoViolations()
})
diff --git a/packages/dnb-eufemia/src/components/progress-indicator/__tests__/__snapshots__/ProgressIndicator.test.tsx.snap b/packages/dnb-eufemia/src/components/progress-indicator/__tests__/__snapshots__/ProgressIndicator.test.tsx.snap
index 052175dc70e..564225bc124 100644
--- a/packages/dnb-eufemia/src/components/progress-indicator/__tests__/__snapshots__/ProgressIndicator.test.tsx.snap
+++ b/packages/dnb-eufemia/src/components/progress-indicator/__tests__/__snapshots__/ProgressIndicator.test.tsx.snap
@@ -46,10 +46,13 @@ exports[`ProgressIndicator scss has to match style dependencies css 1`] = `
}
.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/stories/ProgressIndicator.stories.tsx b/packages/dnb-eufemia/src/components/progress-indicator/stories/ProgressIndicator.stories.tsx
index 7a3abf591bb..70b540033a3 100644
--- a/packages/dnb-eufemia/src/components/progress-indicator/stories/ProgressIndicator.stories.tsx
+++ b/packages/dnb-eufemia/src/components/progress-indicator/stories/ProgressIndicator.stories.tsx
@@ -6,7 +6,7 @@
import React from 'react'
import { Wrapper, Box } from 'storybook-utils/helpers'
-import { ProgressIndicator } from '../..'
+import { Button, ProgressIndicator } from '../..'
export default {
title: 'Eufemia/Components/ProgressIndicator',
@@ -38,6 +38,13 @@ export const ProgressIndicatorSandbox = () => (
)
+export const ProgressIndicatorLabel = () => (
+ <>
+
+
+ >
+)
+
const ProgressIndicatorCircular = () => {
const [visible, setVisible] = React.useState(true)
React.useEffect(() => {
diff --git a/packages/dnb-eufemia/src/components/progress-indicator/style/dnb-progress-indicator.scss b/packages/dnb-eufemia/src/components/progress-indicator/style/dnb-progress-indicator.scss
index 10224a67ea3..d69b4ca763f 100644
--- a/packages/dnb-eufemia/src/components/progress-indicator/style/dnb-progress-indicator.scss
+++ b/packages/dnb-eufemia/src/components/progress-indicator/style/dnb-progress-indicator.scss
@@ -44,11 +44,14 @@
}
&--horizontal &__label {
- margin: 0 1rem;
+ padding-left: 1rem;
+ }
+ &--horizontal#{&}--small &__label {
+ padding-left: 0.5rem;
}
&--vertical &__label {
- margin-top: 0.5rem;
+ padding-top: 0.5rem;
}
// circular variant