Skip to content

Commit d465b06

Browse files
authored
Allow merchandising slots to be full-width (#14936)
1 parent 89de902 commit d465b06

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

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

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { Hide } from '@guardian/source/react-components';
1313
import type { FEArticle } from '../frontend/feArticle';
1414
import { labelBoxStyles, labelHeight, labelStyles } from '../lib/adStyles';
1515
import { ArticleDisplay } from '../lib/articleFormat';
16+
import { center as layoutCenterStyles } from '../lib/center';
1617
import { getZIndex } from '../lib/getZIndex';
1718
import { LABS_HEADER_HEIGHT } from '../lib/labs-constants';
1819
import { palette as schemedPalette } from '../palette';
@@ -166,6 +167,16 @@ const merchandisingAdContainerStyles = css`
166167
}
167168
`;
168169

170+
const allowFullWidthAdContainerStyles = css`
171+
&.ad-slot--full-width {
172+
width: 100%;
173+
max-width: 100%;
174+
.ad-slot {
175+
max-width: 100%;
176+
}
177+
}
178+
`;
179+
169180
const merchandisingAdStyles = css`
170181
position: relative;
171182
min-height: ${getMinHeight(adSizes.billboard.height, space[3])}px;
@@ -259,13 +270,6 @@ const frontsBannerAdContainerStyles = css`
259270
260271
/* Native templates require a width (or min-width) to be explicitly set */
261272
width: ${breakpoints['wide']}px;
262-
/* This is similar to fluid ads, except this class is applied using messenger */
263-
&.ad-slot--full-width {
264-
width: 100%;
265-
.ad-slot {
266-
max-width: 100%;
267-
}
268-
}
269273
`;
270274

271275
const frontsBannerCollapseStyles = css`
@@ -673,7 +677,13 @@ export const AdSlot = ({
673677
}
674678
case 'merchandising-high': {
675679
return (
676-
<AdSlotWrapper css={merchandisingAdContainerStyles}>
680+
<AdSlotWrapper
681+
css={[
682+
merchandisingAdContainerStyles,
683+
layoutCenterStyles,
684+
allowFullWidthAdContainerStyles,
685+
]}
686+
>
677687
<div
678688
id="dfp-ad--merchandising-high"
679689
className={[
@@ -693,7 +703,13 @@ export const AdSlot = ({
693703
}
694704
case 'merchandising': {
695705
return (
696-
<AdSlotWrapper css={merchandisingAdContainerStyles}>
706+
<AdSlotWrapper
707+
css={[
708+
merchandisingAdContainerStyles,
709+
layoutCenterStyles,
710+
allowFullWidthAdContainerStyles,
711+
]}
712+
>
697713
<div
698714
id="dfp-ad--merchandising"
699715
className={[
@@ -720,6 +736,7 @@ export const AdSlot = ({
720736
<AdSlotWrapper
721737
css={[
722738
frontsBannerAdContainerStyles,
739+
allowFullWidthAdContainerStyles,
723740
hasPageskin && frontsBannerCollapseStyles,
724741
]}
725742
>

dotcom-rendering/src/components/FrontsAdSlots.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export const MerchandisingSlot = ({
6767
padSides={false}
6868
showTopBorder={false}
6969
showSideBorders={false}
70+
shouldCenter={false}
7071
backgroundColour={themePalette('--article-section-background')}
7172
element="aside"
7273
>

0 commit comments

Comments
 (0)