1- import React , { useContext , HTMLProps , SVGProps } from 'react' ;
1+ import React , { useContext , SVGProps } from 'react' ;
22import classNames from 'classnames' ;
33import HeaderContext , { IHeaderContext } from '../HeaderContext' ;
4+ import type { AsElementLink } from '../../../util/types/LinkTypes' ;
45
56interface SVGImageWithSrc extends SVGProps < SVGImageElement > {
67 src : string ;
78}
89
10+ export interface NHSLogoNavProps extends AsElementLink < HTMLAnchorElement > { }
11+
912const SVGImageWithSrc : React . FC < SVGImageWithSrc > = props => < image { ...props } /> ;
1013
11- const NHSLogo : React . FC < HTMLProps < HTMLAnchorElement > > = ( { className, alt, ...rest } ) => {
14+ const NHSLogo : React . FC < NHSLogoNavProps > = ( { className, alt, asElement : Component = 'a' , ...rest } ) => {
1215 const { serviceName, hasMenuToggle, hasSearch } = useContext < IHeaderContext > ( HeaderContext ) ;
1316 return (
1417 < div
1518 className = { classNames ( 'nhsuk-header__logo' , {
1619 'nhsuk-header__logo--only' : ! hasMenuToggle && ! hasSearch ,
1720 } ) }
1821 >
19- < a
22+ < Component
2023 className = { classNames (
2124 'nhsuk-header__link' ,
2225 { 'nhsuk-header__link--service' : serviceName } ,
@@ -41,7 +44,7 @@ const NHSLogo: React.FC<HTMLProps<HTMLAnchorElement>> = ({ className, alt, ...re
4144 < SVGImageWithSrc src = "https://assets.nhs.uk/images/nhs-logo.png" xlinkHref = "" />
4245 </ svg >
4346 { serviceName ? < span className = "nhsuk-header__service-name" > { serviceName } </ span > : null }
44- </ a >
47+ </ Component >
4548 </ div >
4649 ) ;
4750} ;
0 commit comments