Skip to content

Commit a60cb1c

Browse files
Update breadcrumb for NHS.UK frontend v10.0.0
1 parent eddbda8 commit a60cb1c

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/components/navigation/breadcrumb/Breadcrumb.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,25 @@ import React, { Children, FC, HTMLProps, ReactNode } from 'react';
22
import classNames from 'classnames';
33
import { AsElementLink } from '@util/types/LinkTypes';
44
import { childIsOfComponentType } from '@util/types/TypeGuards';
5+
import BackLinkComponent from '../back-link';
56

67
type Item = FC<AsElementLink<HTMLAnchorElement>>;
78

89
const Item: Item = ({ className, children, asElement: Element = 'a', ...rest }) => (
9-
<li className="nhsuk-breadcrumb__item">
10+
<li className="nhsuk-breadcrumb__list-item">
1011
<Element className={classNames('nhsuk-breadcrumb__link', className)} {...rest}>
1112
{children}
1213
</Element>
1314
</li>
1415
);
1516

16-
type Back = FC<AsElementLink<HTMLAnchorElement>>;
17+
type Back = typeof BackLinkComponent;
1718

18-
const Back: Back = ({ className, children, asElement: Element = 'a', ...rest }) => (
19-
<p className={classNames('nhsuk-breadcrumb__back', className)}>
20-
<Element className="nhsuk-breadcrumb__backlink" {...rest}>
21-
<span className="nhsuk-u-visually-hidden">Back to &nbsp;</span>
22-
{children}
23-
</Element>
24-
</p>
19+
const Back: Back = ({ children, ...rest }) => (
20+
<BackLinkComponent {...rest}>
21+
<span className="nhsuk-u-visually-hidden">Back to&nbsp;</span>
22+
{children}
23+
</BackLinkComponent>
2524
);
2625

2726
interface BreadcrumbComponent extends FC<HTMLProps<HTMLDivElement>> {

src/components/navigation/breadcrumb/__tests__/Breadcrumb.test.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ describe('Breadcrumb', () => {
3535
expect(breadcrumbListItems.length).toBe(2);
3636

3737
breadcrumbListItems.forEach((child) => {
38-
expect(child.classList).toContain('nhsuk-breadcrumb__item');
38+
expect(child.classList).toContain('nhsuk-breadcrumb__list-item');
3939
});
4040

4141
expect(container.querySelector('#otherElement')?.textContent).toEqual('Test Element');
42-
expect(container.querySelector('.nhsuk-breadcrumb__back')?.textContent).toBe(
43-
'Back to &nbsp;Breadcrumb 2',
44-
);
42+
expect(container.querySelector('.nhsuk-back-link')?.textContent).toBe('Back to Breadcrumb 2');
4543
});
4644

4745
it('passes through other children fine', () => {
@@ -75,11 +73,9 @@ describe('Breadcrumb', () => {
7573
</Breadcrumb>,
7674
);
7775

78-
const hiddenSpan = container.querySelector(
79-
'.nhsuk-breadcrumb__backlink > .nhsuk-u-visually-hidden',
80-
);
76+
const hiddenSpan = container.querySelector('.nhsuk-back-link > .nhsuk-u-visually-hidden');
8177

82-
expect(hiddenSpan?.textContent).toBe('Back to &nbsp;');
78+
expect(hiddenSpan?.textContent).toBe('Back to ');
8379
});
8480

8581
it.each<ElementType | undefined>([undefined, 'button'])(
@@ -93,7 +89,7 @@ describe('Breadcrumb', () => {
9389
</Breadcrumb>,
9490
);
9591

96-
const component = container.querySelector('.nhsuk-breadcrumb__backlink');
92+
const component = container.querySelector('.nhsuk-back-link');
9793

9894
expect(component?.nodeName).toBe(asElement?.toString()?.toUpperCase() ?? 'A');
9995
},

src/components/navigation/breadcrumb/__tests__/__snapshots__/Breadcrumb.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exports[`Breadcrumb renders with children: BreadcrumbWithChildren 1`] = `
2323
class="nhsuk-breadcrumb__list"
2424
>
2525
<li
26-
class="nhsuk-breadcrumb__item"
26+
class="nhsuk-breadcrumb__list-item"
2727
>
2828
<a
2929
class="nhsuk-breadcrumb__link"
@@ -33,7 +33,7 @@ exports[`Breadcrumb renders with children: BreadcrumbWithChildren 1`] = `
3333
</a>
3434
</li>
3535
<li
36-
class="nhsuk-breadcrumb__item"
36+
class="nhsuk-breadcrumb__list-item"
3737
>
3838
<a
3939
class="nhsuk-breadcrumb__link"

0 commit comments

Comments
 (0)