Skip to content

Commit 1574525

Browse files
committed
In NoBoosts AB test, render boosted non-splash cards as non-boosted in Flexible General
1 parent 52278ca commit 1574525

File tree

3 files changed

+108
-41
lines changed

3 files changed

+108
-41
lines changed

dotcom-rendering/src/components/DecideContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type Props = {
4848
frontId?: string;
4949
collectionId: number;
5050
containerLevel?: DCRContainerLevel;
51+
isInNoBoostsAbTestVariant?: boolean;
5152
};
5253

5354
export const DecideContainer = ({
@@ -63,6 +64,7 @@ export const DecideContainer = ({
6364
frontId,
6465
collectionId,
6566
containerLevel,
67+
isInNoBoostsAbTestVariant,
6668
}: Props) => {
6769
switch (containerType) {
6870
case 'dynamic/fast':
@@ -268,6 +270,7 @@ export const DecideContainer = ({
268270
aspectRatio={aspectRatio}
269271
containerLevel={containerLevel}
270272
collectionId={collectionId}
273+
isInNoBoostsAbTestVariant={isInNoBoostsAbTestVariant}
271274
/>
272275
);
273276
case 'scrollable/small':

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 93 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import type { ResponsiveFontSize } from './CardHeadline';
2121
import type { Loading } from './CardPicture';
2222
import { FeatureCard } from './FeatureCard';
2323
import { FrontCard } from './FrontCard';
24+
import { Hide } from './Hide';
2425
import type { Alignment } from './SupportingContent';
2526

2627
type Props = {
@@ -32,6 +33,7 @@ type Props = {
3233
aspectRatio: AspectRatio;
3334
containerLevel?: DCRContainerLevel;
3435
collectionId: number;
36+
isInNoBoostsAbTestVariant?: boolean;
3537
};
3638

3739
type RowLayout = 'oneCardHalfWidth' | 'oneCardFullWidth' | 'twoCard';
@@ -580,18 +582,27 @@ export const FlexibleGeneral = ({
580582
aspectRatio,
581583
containerLevel = 'Primary',
582584
collectionId,
585+
isInNoBoostsAbTestVariant,
583586
}: Props) => {
584587
const splash = [...groupedTrails.splash].slice(0, 1).map((snap) => ({
585588
...snap,
586589
uniqueId: `collection-${collectionId}-splash-0`,
587590
}));
591+
588592
const cards = [...groupedTrails.standard]
589593
.slice(0, 19)
590594
.map((standard, i) => ({
591595
...standard,
592596
uniqueId: `collection-${collectionId}-standard-${i}`,
593597
}));
598+
599+
const cardsInAbTest = cards.map((card) => ({
600+
...card,
601+
boostLevel: isInNoBoostsAbTestVariant ? 'default' : card.boostLevel,
602+
}));
603+
594604
const groupedCards = decideCardPositions(cards);
605+
const groupedCardsInAbTest = decideCardPositions(cardsInAbTest);
595606

596607
return (
597608
<>
@@ -609,45 +620,88 @@ export const FlexibleGeneral = ({
609620
/>
610621
)}
611622

612-
{groupedCards.map((row, i) => {
613-
switch (row.layout) {
614-
case 'oneCardFullWidth':
615-
return (
616-
<FullWidthCardLayout
617-
key={row.cards[0]?.uniqueId}
618-
cards={row.cards}
619-
containerPalette={containerPalette}
620-
showAge={showAge}
621-
absoluteServerTimes={absoluteServerTimes}
622-
imageLoading={imageLoading}
623-
aspectRatio={aspectRatio}
624-
isFirstRow={!splash.length && i === 0}
625-
isLastRow={i === groupedCards.length - 1}
626-
containerLevel={containerLevel}
627-
collectionId={collectionId}
628-
/>
629-
);
630-
631-
case 'oneCardHalfWidth':
632-
case 'twoCard':
633-
default:
634-
return (
635-
<HalfWidthCardLayout
636-
key={row.cards[0]?.uniqueId}
637-
cards={row.cards}
638-
containerPalette={containerPalette}
639-
showAge={showAge}
640-
absoluteServerTimes={absoluteServerTimes}
641-
imageLoading={imageLoading}
642-
isFirstRow={!splash.length && i === 0}
643-
isFirstStandardRow={i === 0}
644-
aspectRatio={aspectRatio}
645-
isLastRow={i === groupedCards.length - 1}
646-
containerLevel={containerLevel}
647-
/>
648-
);
649-
}
650-
})}
623+
<Hide when="above" breakpoint="tablet">
624+
{groupedCardsInAbTest.map((row, i) => {
625+
switch (row.layout) {
626+
case 'oneCardFullWidth':
627+
return (
628+
<FullWidthCardLayout
629+
key={row.cards[0]?.uniqueId}
630+
cards={row.cards}
631+
containerPalette={containerPalette}
632+
showAge={showAge}
633+
absoluteServerTimes={absoluteServerTimes}
634+
imageLoading={imageLoading}
635+
aspectRatio={aspectRatio}
636+
isFirstRow={!splash.length && i === 0}
637+
isLastRow={i === groupedCards.length - 1}
638+
containerLevel={containerLevel}
639+
collectionId={collectionId}
640+
/>
641+
);
642+
643+
case 'oneCardHalfWidth':
644+
case 'twoCard':
645+
default:
646+
return (
647+
<HalfWidthCardLayout
648+
key={row.cards[0]?.uniqueId}
649+
cards={row.cards}
650+
containerPalette={containerPalette}
651+
showAge={showAge}
652+
absoluteServerTimes={absoluteServerTimes}
653+
imageLoading={imageLoading}
654+
isFirstRow={!splash.length && i === 0}
655+
isFirstStandardRow={i === 0}
656+
aspectRatio={aspectRatio}
657+
isLastRow={i === groupedCards.length - 1}
658+
containerLevel={containerLevel}
659+
/>
660+
);
661+
}
662+
})}
663+
</Hide>
664+
<Hide when="below" breakpoint="tablet">
665+
{groupedCards.map((row, i) => {
666+
switch (row.layout) {
667+
case 'oneCardFullWidth':
668+
return (
669+
<FullWidthCardLayout
670+
key={row.cards[0]?.uniqueId}
671+
cards={row.cards}
672+
containerPalette={containerPalette}
673+
showAge={showAge}
674+
absoluteServerTimes={absoluteServerTimes}
675+
imageLoading={imageLoading}
676+
aspectRatio={aspectRatio}
677+
isFirstRow={!splash.length && i === 0}
678+
isLastRow={i === groupedCards.length - 1}
679+
containerLevel={containerLevel}
680+
collectionId={collectionId}
681+
/>
682+
);
683+
684+
case 'oneCardHalfWidth':
685+
case 'twoCard':
686+
default:
687+
return (
688+
<HalfWidthCardLayout
689+
key={row.cards[0]?.uniqueId}
690+
cards={row.cards}
691+
containerPalette={containerPalette}
692+
showAge={showAge}
693+
absoluteServerTimes={absoluteServerTimes}
694+
imageLoading={imageLoading}
695+
isFirstRow={!splash.length && i === 0}
696+
isFirstStandardRow={i === 0}
697+
aspectRatio={aspectRatio}
698+
isLastRow={i === groupedCards.length - 1}
699+
containerLevel={containerLevel}
700+
/>
701+
);
702+
}
703+
})}
704+
</Hide>
651705
</>
652706
);
653707
};

dotcom-rendering/src/layouts/FrontLayout.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ const decideLeftContent = (front: Front, collection: DCRCollectionType) => {
105105

106106
export const FrontLayout = ({ front, NAV }: Props) => {
107107
const {
108-
config: { isPaidContent, hasPageSkin: hasPageSkinConfig, pageId },
108+
config: {
109+
isPaidContent,
110+
hasPageSkin: hasPageSkinConfig,
111+
pageId,
112+
abTests,
113+
},
109114
editionId,
110115
} = front;
111116

@@ -136,6 +141,8 @@ export const FrontLayout = ({ front, NAV }: Props) => {
136141

137142
const { absoluteServerTimes = false } = front.config.switches;
138143

144+
const isInNoBoostsVariant = abTests.noBoostsVariant === 'variant';
145+
139146
const fallbackAspectRatio = (collectionType: DCRContainerType) => {
140147
switch (collectionType) {
141148
case 'scrollable/feature':
@@ -199,7 +206,7 @@ export const FrontLayout = ({ front, NAV }: Props) => {
199206
'--article-section-background',
200207
)}
201208
>
202-
<HeaderAdSlot abTests={front.config.abTests} />
209+
<HeaderAdSlot abTests={abTests} />
203210
</Section>
204211
</Stuck>
205212
)}
@@ -743,6 +750,9 @@ export const FrontLayout = ({ front, NAV }: Props) => {
743750
sectionId={ophanName}
744751
collectionId={index + 1}
745752
containerLevel={collection.containerLevel}
753+
isInNoBoostsAbTestVariant={
754+
isInNoBoostsVariant
755+
}
746756
/>
747757
</FrontSection>
748758

0 commit comments

Comments
 (0)