Skip to content

Commit

Permalink
Use dnb-sr-only to hide the dt
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Nov 21, 2024
1 parent 4a7c8cb commit d606d8a
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,42 +52,6 @@ export const DefinitionListHorizontalExample = () => (
</ComponentBox>
)

export const DefinitionListHorizontalExampleWithoutDtValue = () => (
<ComponentBox
hideCode
data-visual-test="lists-dl-horizontal-without-dt-value"
>
<Dl layout="horizontal">
<Dl.Item>
<Dt></Dt>
<Dd>Description 1</Dd>
</Dl.Item>
<Dl.Item>
<Dt>Term 2</Dt>
<Dd>Description 2</Dd>
</Dl.Item>
<Dl.Item>
<Dt></Dt>
<Dd>Description 3</Dd>
</Dl.Item>
<Dl.Item>
<Dt>
A term with several words lorem dolor sit amet consectetur
adipiscing
</Dt>
<Dd>
Description with several words lorem nulla mi posuere cubilia vel
vulputate
</Dd>
</Dl.Item>
<Dl.Item>
<Dt></Dt>
<Dd>Description 4</Dd>
</Dl.Item>
</Dl>
</ComponentBox>
)

export const DefinitionListGridExample = () => (
<ComponentBox hideCode data-visual-test="lists-dl-grid">
<Dl layout="grid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,3 @@ The term and description are aligned on the bottom.
### Remove list styles

<RemoveListExample />

<VisibleWhenVisualTest>
<DefinitionListHorizontalExampleWithoutDtValue />
</VisibleWhenVisualTest>
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,13 @@ export function InheritLabel() {
</ComponentBox>
)
}

export const HorizontalLayoutWithoutLabel = () => (
<ComponentBox data-visual-test="forms-value-summary-horizontal-empty-label">
<Value.SummaryList layout="horizontal">
<Value.String value="foo" label="Foo" />
<Value.String value="bar" />
<Value.String value="baz" label="Baz" />
</Value.SummaryList>
</ComponentBox>
)
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ Using [Value.Composition](/uilib/extensions/forms/Value/Composition/) to combine
### Inherit label

<Examples.InheritLabel />

<VisibleWhenVisualTest>
<Examples.HorizontalLayoutWithoutLabel />
</VisibleWhenVisualTest>
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,6 @@ describe('List', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match dl horizontal list without dt value', async () => {
const screenshot = await makeScreenshot({
style: { width: '35rem' },
selector:
'[data-visual-test="lists-dl-horizontal-without-dt-value"]',
})
expect(screenshot).toMatchImageSnapshot()
})
})

describe('Lists with skeleton', () => {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,6 @@
margin-top: 0;
margin-right: calc(var(--column-gap) - 0.5rem);
max-width: var(--dt-max-width);

&:empty {
margin-right: 0;
}
}

& dd {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,13 @@ describe('Field.SummaryList', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match without a label', async () => {
const screenshot = await makeScreenshot({
style: { width: '6rem' },
selector:
'[data-visual-test="forms-value-summary-horizontal-empty-label"] ',
})
expect(screenshot).toMatchImageSnapshot()
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,13 @@ function ValueBlock(props: Props) {
value={{ ...summaryListContext, isNested: true }}
>
<Item>
<Dt className="dnb-forms-value-block__label">
{label && <strong>{label}</strong>}
<Dt
className={classnames(
'dnb-forms-value-block__label',
!label && 'dnb-sr-only'
)}
>
<strong>{label}</strong>
</Dt>
<Dd
className={classnames(
Expand Down

0 comments on commit d606d8a

Please sign in to comment.