Skip to content

Commit 2186384

Browse files
authored
Merge pull request #13505 from guardian/dh-ds/reduce-slot1-grey-space
Reduce grey space in first slot to be the same as the other slots
2 parents b92eb50 + 477045d commit 2186384

File tree

3 files changed

+14
-54
lines changed

3 files changed

+14
-54
lines changed

dotcom-rendering/src/components/AdPortals.importable.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ const positionsEqual = (a: BridgetRect, b: BridgetRect): boolean =>
4444

4545
const calculateAdPositions = (adSlots: HTMLDivElement[]): BridgetAdSlot[] =>
4646
adSlots.map(
47-
(slot, index) =>
47+
(slot) =>
4848
new BridgetAdSlot({
4949
rect: calculateAdPosition(slot),
50-
isSquare: index === 0,
50+
isSquare: false,
5151
}),
5252
);
5353

@@ -217,10 +217,9 @@ export const AdPortals = ({
217217
return () => resizeObserver?.disconnect();
218218
}, [adPlaceholders, rightAdPlaceholder, tryRightAligned]);
219219

220-
const renderAdSlot = (id: string, index: number) => (
220+
const renderAdSlot = (id: string) => (
221221
<AdSlot
222222
key={id}
223-
isFirstAdSlot={index === 0}
224223
ref={(node) => {
225224
if (node !== null) {
226225
adSlots.current = [...adSlots.current, node];
@@ -231,18 +230,12 @@ export const AdPortals = ({
231230

232231
if (tryRightAligned && rightAdPlaceholder) {
233232
return createPortal(
234-
<>
235-
{adPlaceholders.map((ad, index) => renderAdSlot(ad.id, index))}
236-
</>,
233+
<>{adPlaceholders.map((ad) => renderAdSlot(ad.id))}</>,
237234
rightAdPlaceholder,
238235
);
239236
}
240237

241238
return (
242-
<>
243-
{adPlaceholders.map((ad, index) =>
244-
createPortal(renderAdSlot(ad.id, index), ad),
245-
)}
246-
</>
239+
<>{adPlaceholders.map((ad) => createPortal(renderAdSlot(ad.id), ad))}</>
247240
);
248241
};

dotcom-rendering/src/components/AdSlot.apps.stories.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,4 @@ export default meta;
2424

2525
type Story = StoryObj<typeof meta>;
2626

27-
export const FirstSlot = {
28-
args: {
29-
isFirstAdSlot: true,
30-
},
31-
} satisfies Story;
32-
33-
export const OtherSlots = {
34-
args: {
35-
isFirstAdSlot: false,
36-
},
37-
} satisfies Story;
27+
export const Slots = {} satisfies Story;

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

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ import { remSpace, textSans14, until } from '@guardian/source/foundations';
33
import { forwardRef } from 'react';
44
import { palette } from '../palette';
55

6-
// Exported for Storybook use
7-
export interface Props {
8-
isFirstAdSlot: boolean;
9-
}
10-
116
const adHeightPx = 250;
127

138
const styles = css`
@@ -42,19 +37,6 @@ const adSlotStyles = css`
4237
width: 100%;
4338
`;
4439

45-
const adSlotSquareStyles = css`
46-
${adSlotStyles}
47-
${until.phablet} {
48-
width: 320px;
49-
margin-left: 10px;
50-
margin-right: 10px;
51-
}
52-
53-
height: 344px;
54-
width: 300px;
55-
padding-bottom: 0;
56-
`;
57-
5840
/**
5941
* AdSlot component for in-article ads **on apps only**
6042
*
@@ -63,16 +45,11 @@ const adSlotSquareStyles = css`
6345
* The ref is important so that we can provide the location of the slot to
6446
* the native layer, for it to "paint" an advert over the top of it.
6547
*/
66-
export const AdSlot = forwardRef<HTMLDivElement, Props>(
67-
({ isFirstAdSlot }, ref) => (
68-
<aside css={styles}>
69-
<div css={adLabelsStyles}>
70-
<p>Advertisement</p>
71-
</div>
72-
<div
73-
css={isFirstAdSlot ? adSlotSquareStyles : adSlotStyles}
74-
ref={ref}
75-
></div>
76-
</aside>
77-
),
78-
);
48+
export const AdSlot = forwardRef<HTMLDivElement>((_, ref) => (
49+
<aside css={styles}>
50+
<div css={adLabelsStyles}>
51+
<p>Advertisement</p>
52+
</div>
53+
<div css={adSlotStyles} ref={ref}></div>
54+
</aside>
55+
));

0 commit comments

Comments
 (0)