Skip to content

Commit bf4f96f

Browse files
authored
Create GalleryLabsHeader sub-component (#14619)
Refactoring the `GalleryLayout` into sub-components, to make it easier to read.
1 parent 62b1db9 commit bf4f96f

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

dotcom-rendering/src/layouts/GalleryLayout.tsx

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ import { Standfirst } from '../components/Standfirst';
3434
import { StickyBottomBanner } from '../components/StickyBottomBanner.importable';
3535
import { SubMeta } from '../components/SubMeta';
3636
import { grid } from '../grid';
37-
import { type ArticleFormat, ArticleSpecial } from '../lib/articleFormat';
37+
import {
38+
type ArticleFormat,
39+
ArticleSpecial,
40+
type ArticleTheme,
41+
} from '../lib/articleFormat';
3842
import { canRenderAds } from '../lib/canRenderAds';
3943
import { getContributionsServiceUrl } from '../lib/contributions';
4044
import { decideMainMediaCaption } from '../lib/decide-caption';
@@ -154,7 +158,6 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
154158
section,
155159
switches,
156160
},
157-
editionId,
158161
} = gallery.frontendData;
159162

160163
const frontendData = gallery.frontendData;
@@ -194,21 +197,10 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
194197
pageId={frontendData.pageId}
195198
/>
196199
) : null}
197-
198-
{format.theme === ArticleSpecial.Labs && (
199-
<Stuck zIndex="subNavBanner">
200-
<Section
201-
fullWidth={true}
202-
showTopBorder={false}
203-
backgroundColour={sourcePalette.labs[400]}
204-
borderColour={sourcePalette.neutral[60]}
205-
sectionId="labs-header"
206-
element="aside"
207-
>
208-
<LabsHeader editionId={editionId} />
209-
</Section>
210-
</Stuck>
211-
)}
200+
<GalleryLabsHeader
201+
theme={format.theme}
202+
editionId={frontendData.editionId}
203+
/>
212204

213205
<main
214206
css={{
@@ -577,6 +569,25 @@ const BannerAndMasthead = (props: {
577569
</div>
578570
);
579571

572+
const GalleryLabsHeader = (props: {
573+
theme: ArticleTheme;
574+
editionId: EditionId;
575+
}) =>
576+
props.theme === ArticleSpecial.Labs ? (
577+
<Stuck>
578+
<Section
579+
fullWidth={true}
580+
showTopBorder={false}
581+
backgroundColour={sourcePalette.labs[400]}
582+
borderColour={sourcePalette.neutral[60]}
583+
sectionId="labs-header"
584+
element="aside"
585+
>
586+
<LabsHeader editionId={props.editionId} />
587+
</Section>
588+
</Stuck>
589+
) : null;
590+
580591
const StoryPackage = ({
581592
storyPackage,
582593
format,

0 commit comments

Comments
 (0)