Skip to content

Commit 5e8d9b2

Browse files
authored
Test reserving 250px for top-above-nav (#14198)
1 parent 27f3c3b commit 5e8d9b2

16 files changed

+111
-31
lines changed

dotcom-rendering/src/components/AdSlot.web.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type DefaultProps = {
4747
display?: ArticleDisplay;
4848
isPaidContent?: boolean;
4949
hasPageskin?: boolean;
50+
isIn250ReservationVariant?: boolean;
5051
};
5152

5253
// for dark ad labels
@@ -106,12 +107,29 @@ const hideBelowDesktop = css`
106107
}
107108
`;
108109

110+
const containerMinHeight = getMinHeight(250, space[5]);
111+
109112
const topAboveNavContainerStyles = css`
110-
padding-bottom: 18px;
113+
padding-bottom: ${space[5]}px;
114+
position: relative;
115+
margin: 0 auto;
116+
text-align: left;
117+
display: block;
118+
`;
119+
120+
const topAboveNavContainerVaraintStyles = css`
121+
padding-bottom: ${space[5]}px;
111122
position: relative;
112123
margin: 0 auto;
113124
text-align: left;
114125
display: block;
126+
width: 100%;
127+
min-height: ${containerMinHeight}px;
128+
129+
/* Remove the min-height when the ad has rendered, so that the container can shrink if the ad is smaller */
130+
&[top-above-nav-ad-rendered='true'] {
131+
min-height: auto;
132+
}
115133
`;
116134

117135
/**
@@ -412,6 +430,7 @@ export const AdSlot = ({
412430
index,
413431
hasPageskin = false,
414432
shouldHideReaderRevenue = false,
433+
isIn250ReservationVariant,
415434
}: Props) => {
416435
switch (position) {
417436
case 'right':
@@ -590,7 +609,13 @@ export const AdSlot = ({
590609
}
591610
case 'top-above-nav': {
592611
return (
593-
<AdSlotWrapper css={topAboveNavContainerStyles}>
612+
<AdSlotWrapper
613+
css={
614+
isIn250ReservationVariant
615+
? topAboveNavContainerVaraintStyles
616+
: topAboveNavContainerStyles
617+
}
618+
>
594619
<div
595620
id="dfp-ad--top-above-nav"
596621
className={[

dotcom-rendering/src/components/HeaderAdSlot.tsx

Lines changed: 66 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { css, Global } from '@emotion/react';
22
import { adSizes, constants } from '@guardian/commercial';
33
import { space } from '@guardian/source/foundations';
44
import { palette } from '../palette';
5+
import type { ServerSideTests } from '../types/config';
56
import { AdBlockAsk } from './AdBlockAsk.importable';
67
import { AdSlot } from './AdSlot.web';
78
import { Hide } from './Hide';
@@ -18,12 +19,26 @@ const borderBottomHeight = 1;
1819
const headerMinHeight =
1920
TOP_ABOVE_NAV_HEIGHT + padding + AD_LABEL_HEIGHT + borderBottomHeight;
2021

21-
const headerAdWrapper = css`
22+
const headerAdWrapperStylesVariant = css`
23+
z-index: 1080;
24+
width: 100%;
25+
background-color: ${palette('--ad-background')};
26+
border-bottom: 1px solid ${palette('--ad-border')};
27+
28+
display: flex;
29+
flex-direction: column;
30+
justify-content: center;
31+
32+
position: sticky;
33+
top: 0;
34+
`;
35+
36+
const headerAdWrapperStylesControl = css`
2237
z-index: 1080;
2338
width: 100%;
2439
background-color: ${palette('--ad-background')};
2540
min-height: ${headerMinHeight}px;
26-
border-bottom: ${borderBottomHeight}px solid ${palette('--ad-border')};
41+
border-bottom: 1px solid ${palette('--ad-border')};
2742
2843
display: flex;
2944
flex-direction: column;
@@ -44,38 +59,60 @@ const headerMinSizeStyles = css`
4459
export const HeaderAdSlot = ({
4560
shouldHideReaderRevenue,
4661
isPaidContent,
62+
abTests,
4763
}: {
4864
shouldHideReaderRevenue: boolean;
4965
isPaidContent: boolean;
50-
}) => (
51-
<div css={headerWrapper}>
52-
<Global
53-
styles={css`
54-
/**
66+
abTests: ServerSideTests;
67+
}) => {
68+
const isIn250ReservationVariant =
69+
abTests.topAboveNav250ReservationVariant === 'variant';
70+
return (
71+
<div css={headerWrapper}>
72+
<Global
73+
styles={css`
74+
/**
5575
* Hides the top-above-nav ad-slot container when a
5676
* Bonzai TrueSkin (Australian 3rd Party page skin) is shown
5777
*/
58-
.bz-custom-container
59-
~ #bannerandheader
60-
.top-banner-ad-container {
61-
display: none;
62-
}
63-
`}
64-
/>
65-
<Hide when="below" breakpoint="tablet">
66-
<div css={[headerAdWrapper]} className="top-banner-ad-container">
67-
<div css={headerMinSizeStyles}>
68-
<Island priority="feature" defer={{ until: 'visible' }}>
69-
<AdBlockAsk
70-
size="leaderboard"
71-
slotId="dfp-ad--top-above-nav"
72-
shouldHideReaderRevenue={shouldHideReaderRevenue}
73-
isPaidContent={isPaidContent}
78+
.bz-custom-container
79+
~ #bannerandheader
80+
.top-banner-ad-container {
81+
display: none;
82+
}
83+
`}
84+
/>
85+
<Hide when="below" breakpoint="tablet">
86+
<div
87+
css={[
88+
isIn250ReservationVariant
89+
? headerAdWrapperStylesVariant
90+
: headerAdWrapperStylesControl,
91+
]}
92+
className="top-banner-ad-container"
93+
>
94+
<div
95+
css={!isIn250ReservationVariant && headerMinSizeStyles}
96+
>
97+
<Island priority="feature" defer={{ until: 'visible' }}>
98+
<AdBlockAsk
99+
size="leaderboard"
100+
slotId="dfp-ad--top-above-nav"
101+
shouldHideReaderRevenue={
102+
shouldHideReaderRevenue
103+
}
104+
isPaidContent={isPaidContent}
105+
/>
106+
</Island>
107+
<AdSlot
108+
position="top-above-nav"
109+
isIn250ReservationVariant={
110+
isIn250ReservationVariant
111+
}
74112
/>
75-
</Island>
76-
<AdSlot position="top-above-nav" />
113+
</div>
77114
</div>
78-
</div>
79-
</Hide>
80-
</div>
81-
);
115+
</Hide>
116+
</div>
117+
);
118+
};

dotcom-rendering/src/layouts/AudioLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ export const AudioLayout = (props: WebProps) => {
173173
shouldHideReaderRevenue={
174174
!!article.config.shouldHideReaderRevenue
175175
}
176+
abTests={article.config.abTests}
176177
/>
177178
</Section>
178179
</Stuck>

dotcom-rendering/src/layouts/CommentLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,7 @@ export const CommentLayout = (props: WebProps | AppsProps) => {
325325
shouldHideReaderRevenue={
326326
!!article.config.shouldHideReaderRevenue
327327
}
328+
abTests={article.config.abTests}
328329
/>
329330
</Section>
330331
</Stuck>

dotcom-rendering/src/layouts/CrosswordLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const CrosswordLayout = (props: Props) => {
145145
shouldHideReaderRevenue={
146146
!!article.config.shouldHideReaderRevenue
147147
}
148+
abTests={article.config.abTests}
148149
/>
149150
</Section>
150151
</div>

dotcom-rendering/src/layouts/FrontLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export const FrontLayout = ({ front, NAV }: Props) => {
202202
<HeaderAdSlot
203203
isPaidContent={!!front.config.isPaidContent}
204204
shouldHideReaderRevenue={false}
205+
abTests={front.config.abTests}
205206
/>
206207
</Section>
207208
</Stuck>

dotcom-rendering/src/layouts/FullPageInteractiveLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ const NavHeader = ({ article, NAV, format, renderAds }: HeaderProps) => {
174174
shouldHideReaderRevenue={
175175
!!article.config.shouldHideReaderRevenue
176176
}
177+
abTests={article.config.abTests}
177178
/>
178179
</Section>
179180
</div>

dotcom-rendering/src/layouts/InteractiveLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ export const InteractiveLayout = (props: WebProps | AppsProps) => {
280280
!!article.config
281281
.shouldHideReaderRevenue
282282
}
283+
abTests={article.config.abTests}
283284
/>
284285
</Section>
285286
</div>

dotcom-rendering/src/layouts/LiveLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
316316
shouldHideReaderRevenue={
317317
!!article.config.shouldHideReaderRevenue
318318
}
319+
abTests={article.config.abTests}
319320
/>
320321
</Section>
321322
</Stuck>

dotcom-rendering/src/layouts/NewsletterSignupLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ export const NewsletterSignupLayout = ({
232232
shouldHideReaderRevenue={
233233
!!article.config.shouldHideReaderRevenue
234234
}
235+
abTests={article.config.abTests}
235236
/>
236237
</Section>
237238
</Stuck>

0 commit comments

Comments
 (0)