diff --git a/packages/dnb-eufemia/src/elements/Dl.tsx b/packages/dnb-eufemia/src/elements/Dl.tsx
index 4e0a1082d67..b1f32b3b034 100644
--- a/packages/dnb-eufemia/src/elements/Dl.tsx
+++ b/packages/dnb-eufemia/src/elements/Dl.tsx
@@ -6,6 +6,7 @@
import React from 'react'
import classnames from 'classnames'
import E, { ElementProps } from './Element'
+import { SpacingProps } from '../shared/types'
export type DlProps = {
/**
@@ -28,18 +29,20 @@ const Dl = ({ direction, ...props }: DlAllProps) => {
return
}
-export type DlItemProps = {
- //
-}
-
Dl.Item = ({
className,
children,
-}: DlItemProps & React.AllHTMLAttributes) => {
+ ...props
+}: React.AllHTMLAttributes & SpacingProps) => {
return (
<>
{children}
-
+
>
)
}
diff --git a/packages/dnb-eufemia/src/elements/Element.tsx b/packages/dnb-eufemia/src/elements/Element.tsx
index cd59a05e4ee..6c679f6fc86 100644
--- a/packages/dnb-eufemia/src/elements/Element.tsx
+++ b/packages/dnb-eufemia/src/elements/Element.tsx
@@ -17,6 +17,7 @@ import {
SkeletonMethods,
} from '../components/skeleton/SkeletonHelper'
import { includeValidProps } from '../components/form-row/FormRowHelpers'
+import { SpacingProps } from '../shared/types'
export type ElementInternalProps = {
is: React.ReactNode
@@ -36,7 +37,7 @@ export type ElementProps = {
/** @deprecated use skeletonMethod instead */
skeleton_method?: SkeletonMethods
-}
+} & SpacingProps
type ElementAllProps = ElementInternalProps & ElementProps
type Attributes = Record
diff --git a/packages/dnb-eufemia/src/elements/__tests__/Element.test.tsx b/packages/dnb-eufemia/src/elements/__tests__/Element.test.tsx
index 91d09c278da..1101775161e 100644
--- a/packages/dnb-eufemia/src/elements/__tests__/Element.test.tsx
+++ b/packages/dnb-eufemia/src/elements/__tests__/Element.test.tsx
@@ -39,6 +39,21 @@ describe('Element', () => {
)
})
+ it('should support spacing props', () => {
+ render(
+
+ text
+
+ )
+
+ const element = document.querySelector('.dnb-p')
+
+ expect(Array.from(element.classList)).toEqual([
+ 'dnb-space__top--medium',
+ 'dnb-p',
+ ])
+ })
+
it('have to support skeleton', () => {
const { container, rerender } = render(
diff --git a/packages/dnb-eufemia/src/elements/__tests__/Lists.test.tsx b/packages/dnb-eufemia/src/elements/__tests__/Lists.test.tsx
index 691b4e1959f..a32e7a0eb59 100644
--- a/packages/dnb-eufemia/src/elements/__tests__/Lists.test.tsx
+++ b/packages/dnb-eufemia/src/elements/__tests__/Lists.test.tsx
@@ -11,6 +11,36 @@ import Dt from '../Dt'
import Dd from '../Dd'
describe('Dl', () => {
+ it('should support spacing props', () => {
+ render(
+
+
+ - Term
+ - Description
+
+
+ )
+
+ const element = document.querySelector('.dnb-dl')
+
+ expect(Array.from(element.classList)).toEqual([
+ 'dnb-dl__direction--horizontal',
+ 'dnb-space__top--medium',
+ 'dnb-dl',
+ ])
+ expect(Array.from(element.querySelector('dt').classList)).toEqual([
+ 'dnb-space__top--medium',
+ 'dnb-dt',
+ ])
+ expect(Array.from(element.querySelector('dd').classList)).toEqual([
+ 'dnb-space__top--medium',
+ 'dnb-dd',
+ ])
+ expect(
+ Array.from(element.querySelector('.dnb-dl__item').classList)
+ ).toEqual(['dnb-dl__item', 'dnb-space__top--medium', 'dnb-dd'])
+ })
+
describe('in horizontal direction', () => {
it('should validate with ARIA rules', async () => {
const Component = render(
@@ -27,6 +57,20 @@ describe('Dl', () => {
)
expect(await axeComponent(Component)).toHaveNoViolations()
})
+
+ it('should have aria-hidden on item', async () => {
+ render(
+
+
+ - Term
+ - Description
+
+
+ )
+ expect(
+ document.querySelector('.dnb-dl__item').getAttribute('aria-hidden')
+ ).toBe('true')
+ })
})
describe('with nested Dls', () => {
diff --git a/packages/dnb-eufemia/src/elements/__tests__/__snapshots__/lists-screenshot-test-js-list-screenshot-have-to-match-dl-list-2-6ae87.snap.png b/packages/dnb-eufemia/src/elements/__tests__/__snapshots__/lists-screenshot-test-js-list-screenshot-have-to-match-dl-list-2-6ae87.snap.png
index 159f48dbbf4..2878c102295 100644
Binary files a/packages/dnb-eufemia/src/elements/__tests__/__snapshots__/lists-screenshot-test-js-list-screenshot-have-to-match-dl-list-2-6ae87.snap.png and b/packages/dnb-eufemia/src/elements/__tests__/__snapshots__/lists-screenshot-test-js-list-screenshot-have-to-match-dl-list-2-6ae87.snap.png differ
diff --git a/packages/dnb-eufemia/src/elements/stories/Lists.stories.tsx b/packages/dnb-eufemia/src/elements/stories/Lists.stories.tsx
index 66a1095c07a..9a0a030e245 100644
--- a/packages/dnb-eufemia/src/elements/stories/Lists.stories.tsx
+++ b/packages/dnb-eufemia/src/elements/stories/Lists.stories.tsx
@@ -22,7 +22,7 @@ export default {
}
export const ListSandbox = () => (
-
+
@@ -127,10 +127,12 @@ export const ListSandbox = () => (
Description 1
Description 2
Description 3
-
- - Sub Term
- - Sub Description
-
+
+
+ - Sub Term
+ - Sub Description
+
+
diff --git a/packages/dnb-eufemia/src/style/elements/__tests__/__snapshots__/Elements.test.js.snap b/packages/dnb-eufemia/src/style/elements/__tests__/__snapshots__/Elements.test.js.snap
index 03a8ef5e4d3..8c116e51171 100644
--- a/packages/dnb-eufemia/src/style/elements/__tests__/__snapshots__/Elements.test.js.snap
+++ b/packages/dnb-eufemia/src/style/elements/__tests__/__snapshots__/Elements.test.js.snap
@@ -711,12 +711,11 @@ a.dnb-button {
content: none; }
.dnb-dl {
+ margin: 0;
padding: 0;
font-size: var(--font-size-basis);
line-height: var(--line-height-basis);
color: var(--theme-color-black-80, currentColor); }
- .dnb-dl:not([class*='dnb-space']) {
- margin: 0; }
.dnb-dl dt {
margin-top: 1rem;
padding: 0;
@@ -733,22 +732,25 @@ a.dnb-button {
@media screen and (min-width: 40em) {
.dnb-dl__direction--horizontal {
display: flex;
- flex-wrap: wrap;
- gap: 0.5rem; }
+ flex-wrap: wrap; }
.dnb-dl__direction--horizontal dt {
- margin-right: 0.5rem;
+ margin-right: 1rem;
max-width: 30%; }
.dnb-dl__direction--horizontal dd {
- width: calc(70% - 1.5rem); }
+ width: calc(70% - 1rem); }
.dnb-dl__direction--horizontal dt,
.dnb-dl__direction--horizontal dd,
.dnb-dl__direction--horizontal dd ~ dt {
- margin-top: 0;
+ margin-top: 0.5rem;
margin-bottom: 0; }
+ .dnb-dl__direction--horizontal dt:first-of-type,
+ .dnb-dl__direction--horizontal dd:first-of-type,
+ .dnb-dl__direction--horizontal dd ~ dt:first-of-type {
+ margin-top: 0; }
.dnb-dl dd.dnb-dl__item {
width: 100%;
height: 0;
- overflow: hidden; } }
+ margin: 0; } }
.dnb-spacing .dnb-ul:not([class*='dnb-space__top']),
.dnb-spacing .dnb-ol:not([class*='dnb-space__top']) {
diff --git a/packages/dnb-eufemia/src/style/elements/lists.scss b/packages/dnb-eufemia/src/style/elements/lists.scss
index 321c0a086a6..27636075a7f 100644
--- a/packages/dnb-eufemia/src/style/elements/lists.scss
+++ b/packages/dnb-eufemia/src/style/elements/lists.scss
@@ -105,9 +105,7 @@
}
}
@mixin dlStyle() {
- &:not([class*='dnb-space']) {
- margin: 0;
- }
+ margin: 0;
padding: 0;
font-size: var(--font-size-basis);
@@ -139,30 +137,34 @@
// Inline
@include allAbove(small) {
&__direction--horizontal {
+ // We can not use gap: 0.5rem because of our wrapper "__item"
display: flex;
flex-wrap: wrap;
- gap: 0.5rem;
& dt {
- margin-right: 0.5rem;
+ margin-right: 1rem;
max-width: 30%;
}
+
& dd {
- // width: calc(70% - 1.5rem); // minus margin-right and the gap
- width: calc(70% - 1.5rem); // minus margin-right and the gap
+ width: calc(70% - 1rem); // minus margin-right and the gap
}
+
& dt,
& dd,
& dd ~ dt {
- margin-top: 0;
+ margin-top: 0.5rem;
margin-bottom: 0;
+ &:first-of-type {
+ margin-top: 0;
+ }
}
}
dd#{&}__item {
width: 100%;
height: 0;
- overflow: hidden;
+ margin: 0;
}
}
}
@@ -232,8 +234,6 @@
@include dlSpacing();
}
}
-// *:not([class^='dnb-']) > {
-// }
// Un-styled list helper
@mixin unstyledList() {