@@ -15,7 +15,7 @@ import { ArticleTitle } from '../components/ArticleTitle';
1515import { Caption } from '../components/Caption' ;
1616import { Footer } from '../components/Footer' ;
1717import {
18- GalleryInlineAdSlot ,
18+ GalleryDesktopAdSlot ,
1919 MobileAdSlot ,
2020} from '../components/GalleryAdSlots' ;
2121import { GalleryImage } from '../components/GalleryImage' ;
@@ -27,13 +27,10 @@ import { Section } from '../components/Section';
2727import { Standfirst } from '../components/Standfirst' ;
2828import { SubMeta } from '../components/SubMeta' ;
2929import { grid } from '../grid' ;
30- import type { ArticleFormat } from '../lib/articleFormat' ;
30+ import { type ArticleFormat , ArticleSpecial } from '../lib/articleFormat' ;
3131import { canRenderAds } from '../lib/canRenderAds' ;
3232import { decideMainMediaCaption } from '../lib/decide-caption' ;
33- import {
34- getDesktopAdPositions ,
35- getMobileAdPositions ,
36- } from '../lib/getGalleryAdPositions' ;
33+ import { getAdPositions } from '../lib/getGalleryAdPositions' ;
3734import type { NavType } from '../model/extract-nav' ;
3835import { palette as themePalette } from '../palette' ;
3936import type { Gallery } from '../types/article' ;
@@ -81,11 +78,8 @@ const galleryItemAdvertStyles = css`
8178` ;
8279
8380const galleryInlineAdContainerStyles = css `
84- ${ grid . column . all }
85-
86- ${ from . tablet } {
87- ${ grid . column . centre }
88- }
81+ ${ grid . column . centre }
82+ z-index : 1 ;
8983
9084 ${ from . desktop } {
9185 padding-bottom : ${ space [ 10 ] } px;
@@ -142,15 +136,11 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
142136 theme : gallery . theme ,
143137 } ;
144138
145- const renderAds = canRenderAds ( frontendData ) ;
139+ const isLabs = format . theme === ArticleSpecial . Labs ;
146140
147- const desktopAdPositions = renderAds
148- ? getDesktopAdPositions ( gallery . images )
149- : [ ] ;
141+ const renderAds = canRenderAds ( frontendData ) ;
150142
151- const mobileAdPositions = renderAds
152- ? getMobileAdPositions ( gallery . images )
153- : [ ] ;
143+ const adPositions = renderAds ? getAdPositions ( gallery . images ) : [ ] ;
154144
155145 return (
156146 < >
@@ -277,12 +267,7 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
277267 </ header >
278268 { gallery . images . map ( ( element , idx ) => {
279269 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 ) ;
286271
287272 return (
288273 < Fragment key = { element . elementId } >
@@ -292,7 +277,7 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
292277 pageId = { frontendData . pageId }
293278 webTitle = { frontendData . webTitle }
294279 />
295- { isWeb && shouldShowAnyAd && (
280+ { isWeb && shouldShowAds && (
296281 < div
297282 className = { [
298283 'gallery__item gallery__item--advert' ,
@@ -303,23 +288,19 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
303288 className = "gallery__img-container"
304289 css = { galleryInlineAdContainerStyles }
305290 >
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+ />
314297
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+ />
323304 </ div >
324305 < div css = { galleryBorder } > </ div >
325306 </ div >
@@ -357,6 +338,18 @@ export const GalleryLayout = (props: WebProps | AppProps) => {
357338 />
358339 </ Section >
359340 ) }
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+ ) }
360353 { isWeb && (
361354 < Section
362355 fullWidth = { true }
0 commit comments