Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add visually hidden text to summary list examples #233

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading