Skip to content

Commit 2ed3592

Browse files
Remove support for care card optional visually hidden text
1 parent 2170c6e commit 2ed3592

File tree

3 files changed

+4
-70
lines changed

3 files changed

+4
-70
lines changed

src/components/navigation/card/__tests__/Card.test.tsx

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -225,28 +225,6 @@ describe('Card', () => {
225225
);
226226
});
227227
});
228-
229-
describe('hidden text', () => {
230-
it('renders without hidden text', () => {
231-
const { container } = render(
232-
<Card cardType="urgent">
233-
<Card.Heading visuallyHiddenText={false}>Heading</Card.Heading>
234-
</Card>,
235-
);
236-
237-
expect(container.querySelector('.nhsuk-u-visually-hidden')).toBeFalsy();
238-
});
239-
240-
it('renders with hidden text', () => {
241-
const { container } = render(
242-
<Card cardType="urgent">
243-
<Card.Heading visuallyHiddenText="Custom">Heading</Card.Heading>
244-
</Card>,
245-
);
246-
247-
expect(container.querySelector('.nhsuk-u-visually-hidden')?.textContent).toEqual('Custom');
248-
});
249-
});
250228
});
251229

252230
describe('Card.Group', () => {

src/components/navigation/card/components/CardHeading.tsx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,22 @@ import { cardTypeIsCareCard } from '@util/types/TypeGuards';
88

99
export interface CardHeadingProps extends HTMLProps<HTMLHeadingElement> {
1010
headingLevel?: HeadingLevelType;
11-
visuallyHiddenText?: false | string;
1211
}
1312

1413
const genHiddenText = (cardType: CareCardType): string => {
1514
switch (cardType) {
16-
case 'non-urgent':
17-
return 'Non-urgent advice: ';
18-
case 'urgent':
19-
return 'Urgent advice: ';
2015
case 'emergency':
2116
return 'Immediate action required: ';
17+
case 'urgent':
18+
return 'Urgent advice: ';
2219
default:
23-
return '';
20+
return 'Non-urgent advice: ';
2421
}
2522
};
2623

2724
const CareHeading: FC<CardHeadingProps & { careType: CareCardType }> = ({
2825
className,
2926
children,
30-
visuallyHiddenText,
3127
careType,
3228
headingLevel = 'h2',
3329
role = 'text',
@@ -41,11 +37,7 @@ const CareHeading: FC<CardHeadingProps & { careType: CareCardType }> = ({
4137
{...rest}
4238
>
4339
<span role={role}>
44-
{visuallyHiddenText !== false ? (
45-
<span className="nhsuk-u-visually-hidden">
46-
{visuallyHiddenText || genHiddenText(careType)}
47-
</span>
48-
) : null}
40+
<span className="nhsuk-u-visually-hidden">{genHiddenText(careType)}</span>
4941
{children}
5042
</span>
5143
</HeadingLevel>

stories/Navigation/Card.stories.tsx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -236,39 +236,3 @@ export const EmergencyCareCard: Story = {
236236
</Card>
237237
),
238238
};
239-
240-
/**
241-
* By default, CareCard components prepend hidden text before the title. These are:
242-
*
243-
* - ("non-urgent") Non-urgent advice:
244-
* - ("urgent") Urgent advice:
245-
* - ("immediate") Immediate action required:
246-
*
247-
* If you wish to disable this behaviour, pass the prop `visuallyHiddenText={false}` to the `CareCard.Heading` component or specify your own visually hidden text by using `visuallyHiddenText="Custom"`.
248-
*
249-
* You can change the heading type (i.e. `h1`, `h2` and so on) of the title by passing the prop `headingLevel="<headingLevel>"` to the `CareCard.Heading`.
250-
*/
251-
export const WithCustomVisuallyHiddenText: Story = {
252-
args: { cardType: 'non-urgent' },
253-
render: (args) => (
254-
<Card cardType={args.cardType}>
255-
<Card.Heading visuallyHiddenText="Custom visually hidden text">
256-
Speak to a GP if:
257-
</Card.Heading>
258-
<Card.Content>
259-
<ul>
260-
<li>you&apos;re not sure it&apos;s chickenpox</li>
261-
<li>the skin around the blisters is red, hot or painful (signs of infection)</li>
262-
<li>
263-
your child is <a href="">dehydrated</a>
264-
</li>
265-
<li>you&apos;re concerned about your child or they get worse</li>
266-
</ul>
267-
<p>
268-
Tell the receptionist you think it&apos;s chickenpox before going in. They may recommend a
269-
special appointment time if other patients are at risk.
270-
</p>
271-
</Card.Content>
272-
</Card>
273-
),
274-
};

0 commit comments

Comments
 (0)