From 5a28032653ba16af0c06a969aabde53c870ef41e Mon Sep 17 00:00:00 2001 From: Cal Mitchell Date: Wed, 2 Jul 2025 13:20:26 +0000 Subject: [PATCH 1/3] NCRS-3732 MAde the warning icon be able to be monochrome and transparent and added aria-label --- src/components/icons/WarningIcon.tsx | 45 +++++++++++++++------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/src/components/icons/WarningIcon.tsx b/src/components/icons/WarningIcon.tsx index f3a673f..bef66b1 100644 --- a/src/components/icons/WarningIcon.tsx +++ b/src/components/icons/WarningIcon.tsx @@ -3,30 +3,33 @@ import React, { HTMLProps } from 'react'; interface WarningIconProps extends HTMLProps { crossOrigin?: '' | 'anonymous' | 'use-credentials' | undefined; + inColour?: Boolean; } -const WarningIcon: React.FC = props => ( - - - - +const WarningIcon: React.FC = props => { + const inColour = props.inColour ?? true; + return ( + + { + inColour === false ? ( - - - - - -); - -WarningIcon.defaultProps = { - height: 84, - width: 94, -}; + ) : ( + + + + + ) + } + +)}; export default WarningIcon; From 775adf6f40edd3741dc5dedff83b95a0e2544b8a Mon Sep 17 00:00:00 2001 From: Cal Mitchell Date: Tue, 8 Jul 2025 08:57:02 +0000 Subject: [PATCH 2/3] NCRS-3732 Updated snapshots tests and storybook --- src/components/icons/WarningIcon.tsx | 2 +- src/components/icons/__tests__/Icons.test.tsx | 8 ++ .../__snapshots__/Icons.test.tsx.snap | 74 +++++++++++++------ stories/Icons.stories.tsx | 3 +- 4 files changed, 62 insertions(+), 25 deletions(-) diff --git a/src/components/icons/WarningIcon.tsx b/src/components/icons/WarningIcon.tsx index bef66b1..6156e45 100644 --- a/src/components/icons/WarningIcon.tsx +++ b/src/components/icons/WarningIcon.tsx @@ -9,7 +9,7 @@ interface WarningIconProps extends HTMLProps { const WarningIcon: React.FC = props => { const inColour = props.inColour ?? true; return ( - + { inColour === false ? ( { const component = render(); expect(component.container).toMatchSnapshot(); }); + it('matches snapshot when solid', () => { + const component = render(); + expect(component.container).toMatchSnapshot(); + }); + it('matches snapshot when transparent', () => { + const component = render(); + expect(component.container).toMatchSnapshot(); + }); }); diff --git a/src/components/icons/__tests__/__snapshots__/Icons.test.tsx.snap b/src/components/icons/__tests__/__snapshots__/Icons.test.tsx.snap index 7d5dc54..795f4ef 100644 --- a/src/components/icons/__tests__/__snapshots__/Icons.test.tsx.snap +++ b/src/components/icons/__tests__/__snapshots__/Icons.test.tsx.snap @@ -3,34 +3,62 @@ exports[`WarningIcon matches snapshot 1`] = `
- - - - - - - + + +
`; + +exports[`WarningIcon matches snapshot when solid 1`] = ` +
+ + + + + + +
+`; + +exports[`WarningIcon matches snapshot when transparent 1`] = ` +
+ + + +
+`; diff --git a/stories/Icons.stories.tsx b/stories/Icons.stories.tsx index 0b44e57..f7edbe6 100644 --- a/stories/Icons.stories.tsx +++ b/stories/Icons.stories.tsx @@ -5,4 +5,5 @@ import { WarningIcon } from '../src'; const stories = storiesOf('Icons', module); -stories.add('WarningIcon', () => ); +stories.add('WarningIcon solid', () => ); +stories.add('WarningIcon transparent', () => ); From 7831c60c848e049e591730cf46bf714ea9fb4a5e Mon Sep 17 00:00:00 2001 From: Cal Mitchell Date: Tue, 8 Jul 2025 11:52:57 +0000 Subject: [PATCH 3/3] NCRS-3732 Version bump --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7125d8f..498c317 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nhsuk-react-components-extensions", - "version": "2.2.0-beta", + "version": "2.3.0-beta", "author": { "email": "thomas.judd-cooper1@nhs.net", "name": "Thomas Judd-Cooper",