Skip to content

Commit ddcf84b

Browse files
authored
Create BannerAndMasthead sub-component (#14618)
Refactoring the `GalleryLayout` into sub-components, to make it easier to read.
1 parent 63601fe commit ddcf84b

File tree

1 file changed

+52
-36
lines changed

1 file changed

+52
-36
lines changed

dotcom-rendering/src/layouts/GalleryLayout.tsx

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ import { type ArticleFormat, ArticleSpecial } from '../lib/articleFormat';
3838
import { canRenderAds } from '../lib/canRenderAds';
3939
import { getContributionsServiceUrl } from '../lib/contributions';
4040
import { decideMainMediaCaption } from '../lib/decide-caption';
41+
import type { EditionId } from '../lib/edition';
4142
import type { NavType } from '../model/extract-nav';
4243
import { palette } from '../palette';
4344
import type { Gallery } from '../types/article';
45+
import type { ConfigType } from '../types/config';
4446
import type { RenderingTarget } from '../types/renderingTarget';
4547
import { BannerWrapper, Stuck } from './lib/stickiness';
4648

@@ -144,8 +146,6 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
144146

145147
const {
146148
config: {
147-
idUrl,
148-
mmaUrl,
149149
discussionApiUrl,
150150
idApiUrl,
151151
shortUrlId,
@@ -184,40 +184,16 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
184184

185185
return (
186186
<>
187-
{isWeb && (
188-
<div data-print-layout="hide" id="bannerandheader">
189-
{renderAds && (
190-
<Stuck>
191-
<Section
192-
fullWidth={true}
193-
showTopBorder={false}
194-
showSideBorders={false}
195-
padSides={false}
196-
shouldCenter={false}
197-
>
198-
<HeaderAdSlot />
199-
</Section>
200-
</Stuck>
201-
)}
202-
<Masthead
203-
nav={props.NAV}
204-
editionId={editionId}
205-
idUrl={idUrl}
206-
mmaUrl={mmaUrl}
207-
discussionApiUrl={discussionApiUrl}
208-
idApiUrl={idApiUrl}
209-
contributionsServiceUrl={
210-
frontendData.contributionsServiceUrl
211-
}
212-
showSubNav={false}
213-
showSlimNav={true}
214-
hasPageSkin={false}
215-
hasPageSkinContentSelfConstrain={false}
216-
pageId={frontendData.pageId}
217-
wholePictureLogoSwitch={switches.wholePictureLogo}
218-
/>
219-
</div>
220-
)}
187+
{isWeb ? (
188+
<BannerAndMasthead
189+
renderAds={renderAds}
190+
nav={props.NAV}
191+
editionId={frontendData.editionId}
192+
config={frontendData.config}
193+
contributionsServiceUrl={contributionsServiceUrl}
194+
pageId={frontendData.pageId}
195+
/>
196+
) : null}
221197

222198
{format.theme === ArticleSpecial.Labs && (
223199
<Stuck zIndex="subNavBanner">
@@ -561,6 +537,46 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
561537
);
562538
};
563539

540+
const BannerAndMasthead = (props: {
541+
renderAds: boolean;
542+
nav: NavType;
543+
editionId: EditionId;
544+
config: ConfigType;
545+
contributionsServiceUrl: string;
546+
pageId: string | undefined;
547+
}) => (
548+
<div data-print-layout="hide" id="bannerandheader">
549+
{props.renderAds ? (
550+
<Stuck>
551+
<Section
552+
fullWidth={true}
553+
showTopBorder={false}
554+
showSideBorders={false}
555+
padSides={false}
556+
shouldCenter={false}
557+
>
558+
<HeaderAdSlot />
559+
</Section>
560+
</Stuck>
561+
) : null}
562+
<Masthead
563+
nav={props.nav}
564+
editionId={props.editionId}
565+
idUrl={props.config.idUrl}
566+
mmaUrl={props.config.mmaUrl}
567+
discussionApiUrl={props.config.discussionApiUrl}
568+
idApiUrl={props.config.idApiUrl}
569+
contributionsServiceUrl={props.contributionsServiceUrl}
570+
showSubNav={false}
571+
showSlimNav={true}
572+
hasPageSkin={false}
573+
hasPageSkinContentSelfConstrain={false}
574+
pageId={props.pageId}
575+
wholePictureLogoSwitch={props.config.switches.wholePictureLogo}
576+
/>
577+
</div>
578+
);
579+
564580
const StoryPackage = ({
565581
storyPackage,
566582
format,

0 commit comments

Comments
 (0)