@@ -2,7 +2,6 @@ import React, { Fragment, useEffect, useState } from 'react'
22import useIe11Status from '../../utils/hooks/useIe11Status'
33import useMobileStatus from '../../utils/hooks/useMobileStatus'
44import presets from '../../data/headerPresets'
5- import { menu as defaultMenu , links as defaultLinks } from '../../data/headerLinks'
65import { HeaderProps as Props } from './types'
76import styled from '@emotion/styled'
87import cn from 'classnames'
@@ -31,8 +30,8 @@ const Header: React.FC<Props> = ({
3130 pathname,
3231 isMobile : isMobileValueFromProps ,
3332 isIe11 : isIe11ValueFromProps ,
34- menu,
35- links,
33+ menu : menuFromProps ,
34+ links : linksFromProps ,
3635 actionButton,
3736 logo,
3837 preset,
@@ -68,37 +67,31 @@ const Header: React.FC<Props> = ({
6867
6968 const Icon = isDropdownOpened ? Cross : Burger
7069 const LinkComponent = logo . linkComponent || 'a'
70+ const menu = menuFromProps || presets [ preset ] ?. menu
71+ const links = linksFromProps || presets [ preset ] ?. links
7172 const CommonHeaderContent = ( ) => (
7273 < Fragment >
73- { menu && (
74- < Menu
75- isMobile = { isMobile }
76- isIe11 = { isIe11 }
77- pathname = { pathname }
78- links = { presets [ preset ] ?. menu . links || menu . links }
79- backButtonText = { presets [ preset ] ?. menu . backButtonText || menu . backButtonText }
80- />
81- ) }
82- { links && < Links links = { presets [ preset ] ?. links || links } pathname = { pathname } /> }
83- { ( presets [ preset ] ?. actionButton . isVisible || actionButton . isVisible ) &&
84- ( isIe11 || presets [ preset ] ?. actionButton . href || actionButton . href ? (
74+ { menu && < Menu isMobile = { isMobile } isIe11 = { isIe11 } pathname = { pathname } menu = { menu } /> }
75+ { links && < Links links = { links } pathname = { pathname } /> }
76+ { ( actionButton ?. isVisible || presets [ preset ] ?. actionButton ?. isVisible ) &&
77+ ( isIe11 || actionButton . href || presets [ preset ] ?. actionButton . href ? (
8578 < ButtonLink
8679 kind = "primary"
8780 className = "button_action"
88- data-testid = { presets [ preset ] ?. actionButton . testId || actionButton . testId }
89- href = { presets [ preset ] ?. actionButton . href || actionButton . href }
81+ data-testid = { actionButton . testId || presets [ preset ] ?. actionButton . testId }
82+ href = { actionButton . href || presets [ preset ] ?. actionButton . href }
9083 dangerouslySetInnerHTML = { {
91- __html : presets [ preset ] ?. actionButton . text || actionButton . text ,
84+ __html : actionButton . text || presets [ preset ] ?. actionButton . text ,
9285 } }
9386 />
9487 ) : (
9588 < Button
9689 kind = "primary"
9790 className = "button_action"
98- data-testid = { presets [ preset ] ?. actionButton . testId || actionButton . testId }
91+ data-testid = { actionButton . testId || presets [ preset ] ?. actionButton . testId }
9992 onClick = { actionButton . onClick }
10093 dangerouslySetInnerHTML = { {
101- __html : presets [ preset ] ?. actionButton . text || actionButton . text ,
94+ __html : actionButton . text || presets [ preset ] ?. actionButton . text ,
10295 } }
10396 />
10497 ) ) }
@@ -108,11 +101,11 @@ const Header: React.FC<Props> = ({
108101 return (
109102 < header data-testid = "Header:block" className = { className } >
110103 < LinkComponent
111- href = { presets [ preset ] ?. logo . href || logo . href }
104+ href = { logo . href || presets [ preset ] ?. logo . href }
112105 className = "logo-wrapper"
113- data-testid = { presets [ preset ] ?. logo . testId || logo . testId }
106+ data-testid = { logo . testId || presets [ preset ] ?. logo . testId }
114107 >
115- { logoHashMap [ presets [ preset ] ?. logo . type ] || logoHashMap [ logo . type ] }
108+ { logoHashMap [ logo . type ] || logoHashMap [ presets [ preset ] ?. logo . type ] }
116109 </ LinkComponent >
117110
118111 { isReady && isMobile && (
@@ -138,19 +131,7 @@ const Header: React.FC<Props> = ({
138131}
139132
140133Header . defaultProps = {
141- logo : {
142- testId : 'Header:link.logo' ,
143- href : 'https://csssr.com/en' ,
144- } ,
145- actionButton : {
146- isVisible : true ,
147- text : 'Default text' ,
148- testId : 'Header:button.contactUs' ,
149- } ,
150- menu : { links : defaultMenu , backButtonText : 'Our services' } ,
151- links : defaultLinks ,
152- pathname : '' ,
153- preset : '' ,
134+ preset : 'defaultEn' ,
154135}
155136
156137export default styled ( Header ) `
0 commit comments