Skip to content

Commit 7302751

Browse files
TomdangoVladJavhrom1KaiSpencerdependabot[bot]
authored
Merge: NHS.UK Frontend v5 Changes (#167)
* remove png from NHS Logo (#141) Co-authored-by: hrom1 <[email protected]> Co-authored-by: Thomas Judd-Cooper <[email protected]> * Remove footer three column variant (#151) * Remove footer three column prop and test * Remove story with columns * Update branch with latest changes * Remove TransactionalServiceName long variant (#152) * Remove TransactionalServiceName.tsx long variant * Update branch with latest changes * [nhsuk-frontend-v5] Move review date component into pattern (#138) * Move ReviewDate into patterns directory * Provide custom ordering to stories * Revert change to ReviewDate.test.tsx import * Adds migration docs for v3 * Update branch with latest changes from target * Callout for v3 as wip release * Add SVG Icon Attributes (#163) * Add SVG Icon fixes from NHSUK Frontend * Update snapshots * Add `do not` prefix to DoDontList (#153) * DoDontList don't item includes text `do not`, tests to cover * add prefixText prop and tests for DoDontList * Better documentation for DoDontList * Header Menu aria-expanded fix (#164) * Add dev warnings for v5 breaking changes (#150) * Add deprecation warning to footer columns prop * Shared warning object for v5 * Dev warning for DoDontList.tsx * Dev warning for TransactionalServiceName.tsx * Dev warning for ReviewDate.tsx * Lint --------- Co-authored-by: Thomas Judd-Cooper <[email protected]> * Fix Readme CI Build status tag (#149) Co-authored-by: Thomas Judd-Cooper <[email protected]> * Only run CI on main and PR's (#148) Currently ci build will run on any push and any pull_request. Pushing to a feature branch kicks off CI unintentionally. Co-authored-by: Thomas Judd-Cooper <[email protected]> * Bump ansi-regex from 4.1.0 to 4.1.1 (#156) Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](chalk/ansi-regex@v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Thomas Judd-Cooper <[email protected]> * Bump minimatch from 3.0.4 to 3.1.2 (#155) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Thomas Judd-Cooper <[email protected]> * Update ErrorSummary component to forward refs (#135) This allows for things like programmatic keyboard focus in order to fulfil accessibility requirements. Co-authored-by: Phil Meier <[email protected]> Co-authored-by: Thomas Judd-Cooper <[email protected]> * bug/Checkbox declaration file inconsistency (#133) * Add "strictNullChecks", fix two cases where typing needs updating in line with checks. * Revert to .defaultProps * Throw error on default HeadingLevel.tsx case * Warn on invalid prop, test to cover * Better dev warning for heading level --------- Co-authored-by: Thomas Judd-Cooper <[email protected]> * Add aria-controls * Fix tests from main merge * Remove Dev Warnings * Final test cleanups * Remove unused import --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Kai Spencer <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Phil Meier <[email protected]> Co-authored-by: Phil Meier <[email protected]> * Add dev warnings for v5 breaking changes (#150) * Add deprecation warning to footer columns prop * Shared warning object for v5 * Dev warning for DoDontList.tsx * Dev warning for TransactionalServiceName.tsx * Dev warning for ReviewDate.tsx * Lint --------- Co-authored-by: Thomas Judd-Cooper <[email protected]> * Header Menu aria-expanded fix (#164) * Add dev warnings for v5 breaking changes (#150) * Add deprecation warning to footer columns prop * Shared warning object for v5 * Dev warning for DoDontList.tsx * Dev warning for TransactionalServiceName.tsx * Dev warning for ReviewDate.tsx * Lint --------- Co-authored-by: Thomas Judd-Cooper <[email protected]> * Fix Readme CI Build status tag (#149) Co-authored-by: Thomas Judd-Cooper <[email protected]> * Only run CI on main and PR's (#148) Currently ci build will run on any push and any pull_request. Pushing to a feature branch kicks off CI unintentionally. Co-authored-by: Thomas Judd-Cooper <[email protected]> * Bump ansi-regex from 4.1.0 to 4.1.1 (#156) Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 4.1.0 to 4.1.1. - [Release notes](https://github.com/chalk/ansi-regex/releases) - [Commits](chalk/ansi-regex@v4.1.0...v4.1.1) --- updated-dependencies: - dependency-name: ansi-regex dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Thomas Judd-Cooper <[email protected]> * Bump minimatch from 3.0.4 to 3.1.2 (#155) Bumps [minimatch](https://github.com/isaacs/minimatch) from 3.0.4 to 3.1.2. - [Release notes](https://github.com/isaacs/minimatch/releases) - [Changelog](https://github.com/isaacs/minimatch/blob/main/changelog.md) - [Commits](isaacs/minimatch@v3.0.4...v3.1.2) --- updated-dependencies: - dependency-name: minimatch dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Thomas Judd-Cooper <[email protected]> * Update ErrorSummary component to forward refs (#135) This allows for things like programmatic keyboard focus in order to fulfil accessibility requirements. Co-authored-by: Phil Meier <[email protected]> Co-authored-by: Thomas Judd-Cooper <[email protected]> * bug/Checkbox declaration file inconsistency (#133) * Add "strictNullChecks", fix two cases where typing needs updating in line with checks. * Revert to .defaultProps * Throw error on default HeadingLevel.tsx case * Warn on invalid prop, test to cover * Better dev warning for heading level --------- Co-authored-by: Thomas Judd-Cooper <[email protected]> * Add aria-controls * Fix tests from main merge * Remove Dev Warnings * Final test cleanups * Remove unused import --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Kai Spencer <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Phil Meier <[email protected]> Co-authored-by: Phil Meier <[email protected]> * Add additional changelog * Bump version * Remove Dev Warning Tests * Fix linting issues * Fix circular dependency --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: VladJav <[email protected]> Co-authored-by: hrom1 <[email protected]> Co-authored-by: Kai Spencer <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Phil Meier <[email protected]> Co-authored-by: Phil Meier <[email protected]>
1 parent 14ae393 commit 7302751

File tree

37 files changed

+296
-309
lines changed

37 files changed

+296
-309
lines changed

.storybook/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const preview: Preview = {
66
actions: { argTypesRegex: '^on[A-Z].*' },
77
options: {
88
storySort: {
9-
order: ['Welcome', 'Migration Guides', 'Components', 'FormBehaviour', 'Deprecated'],
9+
order: ['Welcome', 'Migration Guides', 'Components', 'Patterns', 'FormBehaviour', 'Deprecated'],
1010
},
1111
},
1212
},

docs/upgrade-to-3.0.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Upgrading to 3.0
2+
3+
> v3.0 is an upcoming release, this page is a work in progress.
4+
5+
There are some breaking changes you'll need to be aware of when upgrading to v3. These are mostly related to us upgrading our dependency on [nhsuk-frontend to v5](https://github.com/nhsuk/nhsuk-frontend/blob/main/CHANGELOG.md#500---16-march-2021) which also includes some breaking changes.
6+
7+
## Review Date component is now a pattern
8+
9+
The `ReviewDate` component has been removed from nhsuk-frontend in version 5.0.0. This component is now a `pattern` in the nhsuk-frontend library.
10+
11+
The only change is that the Default import has a new path.
12+
13+
Instead of importing the component from `nhsuk-react-components/lib/components/review-date`, you will now import it from `nhsuk-react-components/lib/patterns/review-date`.
14+
15+
There are no functional changes to the component, and it works exactly as it did before.
16+
17+
```tsx
18+
// Old Import
19+
import { ReviewDate } from "nhsuk-react-components";
20+
import ReviewDate from "nhsuk-react-components/lib/components/review-date";
21+
22+
// New Import
23+
import { ReviewDate } from "nhsuk-react-components";
24+
import ReviewDate from "nhsuk-react-components/lib/patterns/review-date";
25+
```
26+
27+
## NHS Logo PNG Fallback Removed
28+
29+
The .png fallback for the NHS Logo in the header has been removed. This was to support older versions of Internet Explorer, and is no longer required.
30+
31+
## The "Three Columns" option for the Footer component has been removed
32+
33+
This has been removed due to causing accessibility issues in Safari (see the [upstream issue](https://github.com/nhsuk/nhsuk-frontend/issues/575)).
34+
35+
## The `long` variant of the Transactional Service Name component has been removed
36+
37+
In NHS.UK Frontend v5 and above, the header text now defaults to wrapping underneath the logo without the need for a modifier. It is safe to remove the `long` prop from the `<Header.ServiceName>` component.
38+
39+
## The `prefixText` prop has been added to the `DoDontList.Item` component
40+
41+
You can now add prefixed text to each `DoDontList.Item` component by supplying the `prefixText` prop. Items with a `type` of `dont` will automatically have a 'do not' prefix text added in the next major release to align with the NHS.UK frontend library v5.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nhsuk-react-components",
3-
"version": "2.2.1",
3+
"version": "3.0.0",
44
"author": {
55
"email": "[email protected]",
66
"name": "Thomas Judd-Cooper",
@@ -47,7 +47,7 @@
4747
"eslint-plugin-react-hooks": "^4.2.0",
4848
"jest": "^26.6.3",
4949
"jest-axe": "^4.1.0",
50-
"nhsuk-frontend": "4.1.0",
50+
"nhsuk-frontend": "5.0.0",
5151
"nhsuk-frontend-legacy": "npm:[email protected]",
5252
"prettier": "^2.3.0",
5353
"react": "^16.14.0",
@@ -64,7 +64,7 @@
6464
"vite": "^4.2.1"
6565
},
6666
"peerDependencies": {
67-
"nhsuk-frontend": ">=4.0.0",
67+
"nhsuk-frontend": ">=5.0.0",
6868
"react": ">=16.8.0",
6969
"react-dom": ">=16.8.0"
7070
},

src/components/action-link/ActionLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const ActionLink: React.FC<AsElementLink<HTMLAnchorElement>> = ({
1111
}) => (
1212
<div className="nhsuk-action-link">
1313
<Component className={classNames('nhsuk-action-link__link', className)} {...rest}>
14-
<ArrowRightCircle />
14+
<ArrowRightCircle width={36} height={36} />
1515
<span className="nhsuk-action-link__text">{children}</span>
1616
</Component>
1717
</div>

src/components/action-link/__tests__/__snapshots__/ActionLink.test.tsx.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ exports[`ActionLink matches snapshot: ActionLink 1`] = `
88
className="nhsuk-action-link__link"
99
href="/test"
1010
>
11-
<ArrowRightCircle />
11+
<ArrowRightCircle
12+
height={36}
13+
width={36}
14+
/>
1215
<span
1316
className="nhsuk-action-link__text"
1417
>

src/components/back-link/BackLink.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const BackLink: React.FC<AsElementLink<HTMLAnchorElement>> = ({
1111
}) => (
1212
<div className="nhsuk-back-link">
1313
<Component className={classNames('nhsuk-back-link__link', className)} {...rest}>
14-
<ChevronLeft />
14+
<ChevronLeft height={24} width={24} />
1515
{children}
1616
</Component>
1717
</div>

src/components/back-link/__tests__/__snapshots__/BackLink.test.tsx.snap

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ exports[`BackLink matches snapshot: BackLink 1`] = `
88
className="nhsuk-back-link__link"
99
href="/back"
1010
>
11-
<ChevronLeft />
11+
<ChevronLeft
12+
height={24}
13+
width={24}
14+
/>
1215
Back
1316
</a>
1417
</div>

src/components/do-dont-list/DoDontList.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import React, { HTMLProps, createContext, useContext } from 'react';
1+
import React, { HTMLProps, createContext, useContext, ReactNode } from 'react';
22
import classNames from 'classnames';
33
import { Tick, Cross } from '../icons';
44
import HeadingLevel, { HeadingLevelType } from '../../util/HeadingLevel';
5-
import useDevWarning from '../../util/hooks/UseDevWarning';
6-
import { NHSUKFrontendV5UpgradeWarnings } from '../../deprecated/warnings';
75

86
type ListType = 'do' | 'dont';
97

@@ -27,7 +25,6 @@ const DoDontList: DoDontList = ({
2725
headingLevel,
2826
...rest
2927
}) => {
30-
useDevWarning(NHSUKFrontendV5UpgradeWarnings.DoDontListPrefix, () => listType === 'dont');
3128
return (
3229
<div className={classNames('nhsuk-do-dont-list', className)} {...rest}>
3330
<HeadingLevel className="nhsuk-do-dont-list__label" headingLevel={headingLevel}>
@@ -48,13 +45,26 @@ const DoDontList: DoDontList = ({
4845

4946
interface DoDontItemProps extends HTMLProps<HTMLLIElement> {
5047
listItemType?: ListType;
48+
prefixText?: ReactNode;
5149
}
5250

53-
const DoDontItem: React.FC<DoDontItemProps> = ({ children, listItemType, ...rest }) => {
51+
const DoDontItem: React.FC<DoDontItemProps> = ({ prefixText, listItemType, children, ...rest }) => {
5452
const listItem = useContext(DoDontListContext);
53+
const defaultPrefix = (listItemType || listItem) === 'do' ? null : 'do not ';
54+
const actualPrefix = prefixText === undefined ? defaultPrefix : prefixText;
5555
return (
5656
<li {...rest}>
57-
{(listItemType || listItem) === 'do' ? <Tick /> : <Cross />}
57+
{(listItemType || listItem) === 'do' ? (
58+
<>
59+
<Tick />
60+
{actualPrefix}
61+
</>
62+
) : (
63+
<>
64+
<Cross />
65+
{actualPrefix}
66+
</>
67+
)}
5868
{children}
5969
</li>
6070
);

src/components/do-dont-list/__tests__/DoDontList.test.tsx

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from 'react';
22
import { shallow, mount } from 'enzyme';
33
import DoDontList from '..';
4-
import { NHSUKFrontendV5UpgradeWarnings } from '../../../deprecated/warnings';
54

65
describe('DoDontList', () => {
76
it('matches snapshot', () => {
@@ -64,6 +63,59 @@ describe('DoDontList', () => {
6463
doList.unmount();
6564
dontList.unmount();
6665
});
66+
67+
it("dont item includes 'do not' by default", () => {
68+
const dontList = mount(
69+
<DoDontList listType="dont">
70+
<DoDontList.Item>do something bad</DoDontList.Item>
71+
</DoDontList>,
72+
);
73+
expect(dontList.find('.nhsuk-list--cross').text()).toEqual('do not do something bad');
74+
dontList.unmount();
75+
});
76+
77+
it('items render custom prefix text', () => {
78+
const doList = mount(
79+
<DoDontList listType="do">
80+
<DoDontList.Item prefixText="do ">something good 1</DoDontList.Item>
81+
<DoDontList.Item>something good 2</DoDontList.Item>
82+
<DoDontList.Item prefixText={<span>also do </span>}>something good 3</DoDontList.Item>
83+
<DoDontList.Item prefixText={undefined}>something good 4</DoDontList.Item>
84+
<DoDontList.Item prefixText={null}>something good 5</DoDontList.Item>
85+
</DoDontList>,
86+
);
87+
const dontList = mount(
88+
<DoDontList listType="dont">
89+
<DoDontList.Item prefixText="do not ">do something bad 1</DoDontList.Item>
90+
<DoDontList.Item>do something bad 2</DoDontList.Item>
91+
<DoDontList.Item prefixText={<span>don&apos;t do </span>}>
92+
something bad 3
93+
</DoDontList.Item>
94+
<DoDontList.Item prefixText={undefined}>something bad 4</DoDontList.Item>
95+
<DoDontList.Item prefixText={null}>something bad 5</DoDontList.Item>
96+
</DoDontList>,
97+
);
98+
expect(doList.find('.nhsuk-list--tick').childAt(0).text()).toBe('do something good 1');
99+
expect(doList.find('.nhsuk-list--tick').childAt(1).text()).toBe('something good 2');
100+
expect(doList.find('.nhsuk-list--tick').childAt(2).text()).toBe('also do something good 3');
101+
expect(doList.find('.nhsuk-list--tick').childAt(3).text()).toBe('something good 4');
102+
expect(doList.find('.nhsuk-list--tick').childAt(4).text()).toBe('something good 5');
103+
104+
expect(dontList.find('.nhsuk-list--cross').childAt(0).text()).toBe(
105+
'do not do something bad 1',
106+
);
107+
expect(dontList.find('.nhsuk-list--cross').childAt(1).text()).toBe(
108+
'do not do something bad 2',
109+
);
110+
expect(dontList.find('.nhsuk-list--cross').childAt(2).text()).toBe(
111+
"don't do something bad 3",
112+
);
113+
expect(dontList.find('.nhsuk-list--cross').childAt(3).text()).toBe('do not something bad 4');
114+
expect(dontList.find('.nhsuk-list--cross').childAt(4).text()).toBe('something bad 5');
115+
116+
doList.unmount();
117+
dontList.unmount();
118+
});
67119
});
68120
});
69121

@@ -73,14 +125,6 @@ describe('dont list dev warning', () => {
73125
jest.clearAllMocks();
74126
});
75127

76-
it('should warn when using dont list', () => {
77-
const element = mount(<DoDontList listType="dont" />);
78-
expect(console.warn).toHaveBeenCalled();
79-
expect((console.warn as jest.Mock).mock.calls[0][0]).toBe(
80-
NHSUKFrontendV5UpgradeWarnings.DoDontListPrefix,
81-
);
82-
element.unmount();
83-
});
84128
it('should not warn when using do list', () => {
85129
const element = mount(<DoDontList listType="do" />);
86130
expect(console.warn).not.toHaveBeenCalled();

src/components/footer/Footer.tsx

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
11
import React, { HTMLProps } from 'react';
22
import classNames from 'classnames';
33
import { Container } from '../layout';
4-
import useDevWarning from '../../util/hooks/UseDevWarning';
5-
import { NHSUKFrontendV5UpgradeWarnings } from '../../deprecated/warnings';
64

7-
interface FooterListProps extends HTMLProps<HTMLOListElement> {
8-
columns?: boolean;
9-
}
5+
type FooterListProps = HTMLProps<HTMLOListElement>;
106

11-
const FooterList: React.FC<FooterListProps> = ({ className, columns, ...rest }) => {
12-
useDevWarning(NHSUKFrontendV5UpgradeWarnings.FooterColumns, () => columns);
13-
return (
14-
<ul
15-
className={classNames(
16-
'nhsuk-footer__list',
17-
{ 'nhsuk-footer__list--three-columns': columns },
18-
className,
19-
)}
20-
{...rest}
21-
/>
22-
);
23-
};
7+
const FooterList: React.FC<FooterListProps> = ({ className, ...rest }) => (
8+
<ul className={classNames('nhsuk-footer__list', className)} {...rest} />
9+
);
2410

2511
const FooterListItem: React.FC<HTMLProps<HTMLAnchorElement>> = ({ className, ...rest }) => (
2612
<li className="nhsuk-footer__list-item">

0 commit comments

Comments
 (0)