@@ -15,7 +15,7 @@ import { ArticleTitle } from '../components/ArticleTitle';
15
15
import { Caption } from '../components/Caption' ;
16
16
import { Footer } from '../components/Footer' ;
17
17
import {
18
- GalleryInlineAdSlot ,
18
+ GalleryDesktopAdSlot ,
19
19
MobileAdSlot ,
20
20
} from '../components/GalleryAdSlots' ;
21
21
import { GalleryImage } from '../components/GalleryImage' ;
@@ -27,13 +27,10 @@ import { Section } from '../components/Section';
27
27
import { Standfirst } from '../components/Standfirst' ;
28
28
import { SubMeta } from '../components/SubMeta' ;
29
29
import { grid } from '../grid' ;
30
- import type { ArticleFormat } from '../lib/articleFormat' ;
30
+ import { type ArticleFormat , ArticleSpecial } from '../lib/articleFormat' ;
31
31
import { canRenderAds } from '../lib/canRenderAds' ;
32
32
import { decideMainMediaCaption } from '../lib/decide-caption' ;
33
- import {
34
- getDesktopAdPositions ,
35
- getMobileAdPositions ,
36
- } from '../lib/getGalleryAdPositions' ;
33
+ import { getAdPositions } from '../lib/getGalleryAdPositions' ;
37
34
import type { NavType } from '../model/extract-nav' ;
38
35
import { palette as themePalette } from '../palette' ;
39
36
import type { Gallery } from '../types/article' ;
@@ -81,11 +78,8 @@ const galleryItemAdvertStyles = css`
81
78
` ;
82
79
83
80
const galleryInlineAdContainerStyles = css `
84
- ${ grid . column . all }
85
-
86
- ${ from . tablet } {
87
- ${ grid . column . centre }
88
- }
81
+ ${ grid . column . centre }
82
+ z-index : 1 ;
89
83
90
84
${ from . desktop } {
91
85
padding-bottom : ${ space [ 10 ] } px;
@@ -142,15 +136,11 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
142
136
theme : gallery . theme ,
143
137
} ;
144
138
145
- const renderAds = canRenderAds ( frontendData ) ;
139
+ const isLabs = format . theme === ArticleSpecial . Labs ;
146
140
147
- const desktopAdPositions = renderAds
148
- ? getDesktopAdPositions ( gallery . images )
149
- : [ ] ;
141
+ const renderAds = canRenderAds ( frontendData ) ;
150
142
151
- const mobileAdPositions = renderAds
152
- ? getMobileAdPositions ( gallery . images )
153
- : [ ] ;
143
+ const adPositions = renderAds ? getAdPositions ( gallery . images ) : [ ] ;
154
144
155
145
return (
156
146
< >
@@ -277,12 +267,7 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
277
267
</ header >
278
268
{ gallery . images . map ( ( element , idx ) => {
279
269
const index = idx + 1 ;
280
- const shouldShowDesktopAd =
281
- desktopAdPositions . includes ( index ) ;
282
- const shouldShowMobileAd =
283
- mobileAdPositions . includes ( index ) ;
284
- const shouldShowAnyAd =
285
- shouldShowDesktopAd || shouldShowMobileAd ;
270
+ const shouldShowAds = adPositions . includes ( index ) ;
286
271
287
272
return (
288
273
< Fragment key = { element . elementId } >
@@ -292,7 +277,7 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
292
277
pageId = { frontendData . pageId }
293
278
webTitle = { frontendData . webTitle }
294
279
/>
295
- { isWeb && shouldShowAnyAd && (
280
+ { isWeb && shouldShowAds && (
296
281
< div
297
282
className = { [
298
283
'gallery__item gallery__item--advert' ,
@@ -303,23 +288,19 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
303
288
className = "gallery__img-container"
304
289
css = { galleryInlineAdContainerStyles }
305
290
>
306
- { shouldShowDesktopAd && (
307
- < GalleryInlineAdSlot
308
- renderAds = { renderAds }
309
- adSlotIndex = { desktopAdPositions . indexOf (
310
- index ,
311
- ) }
312
- />
313
- ) }
291
+ < GalleryDesktopAdSlot
292
+ renderAds = { renderAds }
293
+ adSlotIndex = { adPositions . indexOf (
294
+ index ,
295
+ ) }
296
+ />
314
297
315
- { shouldShowMobileAd && (
316
- < MobileAdSlot
317
- renderAds = { renderAds }
318
- adSlotIndex = { mobileAdPositions . indexOf (
319
- index ,
320
- ) }
321
- />
322
- ) }
298
+ < MobileAdSlot
299
+ renderAds = { renderAds }
300
+ adSlotIndex = { adPositions . indexOf (
301
+ index ,
302
+ ) }
303
+ />
323
304
</ div >
324
305
< div css = { galleryBorder } > </ div >
325
306
</ div >
@@ -357,6 +338,18 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
357
338
/>
358
339
</ Section >
359
340
) }
341
+ { isWeb && renderAds && ! isLabs && (
342
+ < Section
343
+ fullWidth = { true }
344
+ padSides = { false }
345
+ showTopBorder = { false }
346
+ showSideBorders = { false }
347
+ backgroundColour = { themePalette ( '--ad-background' ) }
348
+ element = "aside"
349
+ >
350
+ < AdSlot position = "merchandising" display = { format . display } />
351
+ </ Section >
352
+ ) }
360
353
{ isWeb && (
361
354
< Section
362
355
fullWidth = { true }
0 commit comments