Skip to content

Commit

Permalink
Add visually hidden text to summary list examples (#233)
Browse files Browse the repository at this point in the history
* Add visually hidden text to summary list examples

* Add implimentation notes

* Fix className
  • Loading branch information
edwardhorsford authored Jun 11, 2024
1 parent 0c2c115 commit 4cdd2f5
Showing 1 changed file with 42 additions and 4 deletions.
46 changes: 42 additions & 4 deletions stories/Content Presentation/SummaryList.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ import React from 'react';
import { SummaryList, BodyText } from '../../src';
import { Meta, StoryObj } from '@storybook/react';


/**
* ## Implementation notes
*
* When providing action links, you must include visually hidden text. This means a screen reader user will hear a meaningful action, like "Change name" or "Change date of birth".'
*
* Example of an action link:
*
* ```jsx
* <a href="#">
* Change
* <span className="nhsuk-u-visually-hidden">
* {' '}name
* </span>
* </a>
* ```
*/


const meta: Meta<typeof SummaryList> = {
title: 'Content Presentation/SummaryList',
component: SummaryList,
Expand All @@ -15,6 +34,8 @@ SummaryList.Key.displayName = 'SummaryList.Key';
SummaryList.Value.displayName = 'SummaryList.Value';
SummaryList.Actions.displayName = 'SummaryList.Actions';



export const Standard: Story = {
argTypes: {
noBorder: {
Expand All @@ -29,14 +50,18 @@ export const Standard: Story = {
<SummaryList.Key>Name</SummaryList.Key>
<SummaryList.Value>Sarah Philips</SummaryList.Value>
<SummaryList.Actions>
<a href="stories#">Change</a>
<a href="#">
Change<span className="nhsuk-u-visually-hidden"> name</span>
</a>
</SummaryList.Actions>
</SummaryList.Row>
<SummaryList.Row>
<SummaryList.Key>Date of birth</SummaryList.Key>
<SummaryList.Value>5 January 1978</SummaryList.Value>
<SummaryList.Actions>
<a href="stories#">Change</a>
<a href="#">
Change<span className="nhsuk-u-visually-hidden"> date of birth</span>
</a>
</SummaryList.Actions>
</SummaryList.Row>
<SummaryList.Row>
Expand All @@ -49,7 +74,9 @@ export const Standard: Story = {
SE23 6FH
</SummaryList.Value>
<SummaryList.Actions>
<a href="stories#">Change</a>
<a href="#">
Change<span className="nhsuk-u-visually-hidden"> contact information</span>
</a>
</SummaryList.Actions>
</SummaryList.Row>
<SummaryList.Row>
Expand All @@ -59,13 +86,24 @@ export const Standard: Story = {
<BodyText>[email protected]</BodyText>
</SummaryList.Value>
<SummaryList.Actions>
<a href="stories#">Change</a>
<a href="#">
Change<span className="nhsuk-u-visually-hidden"> contact details</span>
</a>
</SummaryList.Actions>
</SummaryList.Row>
</SummaryList>
),
parameters: {
docs: {
description: {
story: 'Change links must include visually hidden text. This means a screen reader user will hear a meaningful action, like "Change name" or "Change date of birth".'
}
}
}
};



export const SummaryListWithoutActions: Story = {
args: { noBorder: false },
render: ({ noBorder }) => (
Expand Down

0 comments on commit 4cdd2f5

Please sign in to comment.