Skip to content

Commit b937c45

Browse files
committed
conditional require Navis
1 parent 27a08a9 commit b937c45

File tree

1 file changed

+62
-65
lines changed
  • src/shared/containers/Contentful/MenuLoader

1 file changed

+62
-65
lines changed

src/shared/containers/Contentful/MenuLoader/index.jsx

Lines changed: 62 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,6 @@ class MenuLoaderContainer extends React.Component {
7878
return <LoadingIndicator />;
7979
}
8080
if (isomorphy.isClientSide()) {
81-
// eslint-disable-next-line global-require
82-
const { TopNav, LoginNav } = require('navigation-component');
83-
// eslint-disable-next-line global-require
84-
const { TopNav: TopNavTCO, LoginNav: LoginNavTCO } = require('navigation-component-tco');
8581
const logoToUse = !_.isEmpty(menuLogo) ? <img src={menuLogo.fields.file.url} alt="menu logo" /> : <Logo />;
8682
const menuTheme = fields.theme.split('- ');
8783
let normalizedProfile = auth.profile && _.clone(auth.profile);
@@ -91,70 +87,71 @@ class MenuLoaderContainer extends React.Component {
9187
} else {
9288
normalizedProfile = null;
9389
}
94-
return (
95-
<div>
96-
{
97-
fields.theme.indexOf('TCO22') !== -1 ? (
98-
<TopNavTCO
99-
menu={menu}
100-
rightMenu={(
101-
<LoginNavTCO
102-
loggedIn={!_.isEmpty(auth.profile)}
103-
notificationButtonState="none"
104-
notifications={[]}
105-
accountMenu={config.ACCOUNT_MENU}
106-
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
107-
onSwitch={this.handleSwitchMenu}
108-
onMenuOpen={this.handleCloseOpenMore}
109-
profile={normalizedProfile}
110-
auth={auth}
111-
authURLs={config.HEADER_AUTH_URLS}
112-
/>
113-
)}
114-
logo={logoToUse}
115-
theme={menuTheme[1]}
116-
currentLevel1Id={activeLevel1Id}
117-
onChangeLevel1Id={this.handleChangeLevel1Id}
118-
path={path}
119-
openMore={openMore}
120-
setOpenMore={this.handleChangeOpenMore}
90+
if (fields.theme.indexOf('TCO22') !== -1) {
91+
// eslint-disable-next-line global-require
92+
const { TopNav: TopNavTCO, LoginNav: LoginNavTCO } = require('navigation-component-tco');
93+
return (
94+
<TopNavTCO
95+
menu={menu}
96+
rightMenu={(
97+
<LoginNavTCO
12198
loggedIn={!_.isEmpty(auth.profile)}
122-
profileHandle={auth.profile ? auth.profile.handle : ''}
123-
logoLink={fields.logoLink}
124-
backToTcUrl={fields.backToTcUrl}
125-
backToTcUrlText={fields.backToTcUrlText}
99+
notificationButtonState="none"
100+
notifications={[]}
101+
accountMenu={config.ACCOUNT_MENU}
102+
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
103+
onSwitch={this.handleSwitchMenu}
104+
onMenuOpen={this.handleCloseOpenMore}
105+
profile={normalizedProfile}
106+
auth={auth}
107+
authURLs={config.HEADER_AUTH_URLS}
126108
/>
127-
) : (
128-
<TopNav
129-
menu={menu}
130-
rightMenu={(
131-
<LoginNav
132-
loggedIn={!_.isEmpty(auth.profile)}
133-
notificationButtonState="none"
134-
notifications={[]}
135-
accountMenu={config.ACCOUNT_MENU}
136-
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
137-
onSwitch={this.handleSwitchMenu}
138-
onMenuOpen={this.handleCloseOpenMore}
139-
profile={normalizedProfile}
140-
auth={auth}
141-
authURLs={config.HEADER_AUTH_URLS}
142-
/>
143109
)}
144-
logo={logoToUse}
145-
theme={menuTheme[1]}
146-
currentLevel1Id={activeLevel1Id}
147-
onChangeLevel1Id={this.handleChangeLevel1Id}
148-
path={path}
149-
openMore={openMore}
150-
setOpenMore={this.handleChangeOpenMore}
151-
loggedIn={!_.isEmpty(auth.profile)}
152-
profileHandle={auth.profile ? auth.profile.handle : ''}
153-
logoLink={fields.logoLink}
154-
/>
155-
)
156-
}
157-
</div>
110+
logo={logoToUse}
111+
theme={menuTheme[1]}
112+
currentLevel1Id={activeLevel1Id}
113+
onChangeLevel1Id={this.handleChangeLevel1Id}
114+
path={path}
115+
openMore={openMore}
116+
setOpenMore={this.handleChangeOpenMore}
117+
loggedIn={!_.isEmpty(auth.profile)}
118+
profileHandle={auth.profile ? auth.profile.handle : ''}
119+
logoLink={fields.logoLink}
120+
backToTcUrl={fields.backToTcUrl}
121+
backToTcUrlText={fields.backToTcUrlText}
122+
/>
123+
);
124+
}
125+
// eslint-disable-next-line global-require
126+
const { TopNav, LoginNav } = require('navigation-component');
127+
return (
128+
<TopNav
129+
menu={menu}
130+
rightMenu={(
131+
<LoginNav
132+
loggedIn={!_.isEmpty(auth.profile)}
133+
notificationButtonState="none"
134+
notifications={[]}
135+
accountMenu={config.ACCOUNT_MENU}
136+
switchText={config.ACCOUNT_MENU_SWITCH_TEXT}
137+
onSwitch={this.handleSwitchMenu}
138+
onMenuOpen={this.handleCloseOpenMore}
139+
profile={normalizedProfile}
140+
auth={auth}
141+
authURLs={config.HEADER_AUTH_URLS}
142+
/>
143+
)}
144+
logo={logoToUse}
145+
theme={menuTheme[1]}
146+
currentLevel1Id={activeLevel1Id}
147+
onChangeLevel1Id={this.handleChangeLevel1Id}
148+
path={path}
149+
openMore={openMore}
150+
setOpenMore={this.handleChangeOpenMore}
151+
loggedIn={!_.isEmpty(auth.profile)}
152+
profileHandle={auth.profile ? auth.profile.handle : ''}
153+
logoLink={fields.logoLink}
154+
/>
158155
);
159156
}
160157
// no SSR for navi component yet

0 commit comments

Comments
 (0)