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__/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/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..9c9540272d8 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
@@ -733,22 +733,24 @@ 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; } }
+ height: 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..39d5a500edd 100644
--- a/packages/dnb-eufemia/src/style/elements/lists.scss
+++ b/packages/dnb-eufemia/src/style/elements/lists.scss
@@ -139,30 +139,33 @@
// 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;
}
}
}