diff --git a/dotcom-rendering/src/components/TagFrontFastMpu.stories.tsx b/dotcom-rendering/src/components/TagFrontFastMpu.stories.tsx deleted file mode 100644 index 5870e508040..00000000000 --- a/dotcom-rendering/src/components/TagFrontFastMpu.stories.tsx +++ /dev/null @@ -1,124 +0,0 @@ -import { breakpoints } from '@guardian/source-foundations'; -import { discussionApiUrl } from '../../fixtures/manual/discussionApiUrl'; -import { trails } from '../../fixtures/manual/trails'; -import { FrontSection } from './FrontSection'; -import { TagFrontFastMpu } from './TagFrontFastMpu'; - -export default { - component: TagFrontFastMpu, - title: 'Components/TagFrontFastMpu', - parameters: { - chromatic: { - viewports: [ - breakpoints.mobile, - breakpoints.tablet, - breakpoints.wide, - ], - }, - }, -}; - -export const WithTwoCards = () => { - return ( - - - - ); -}; -WithTwoCards.storyName = 'With two cards'; - -export const WithFourCards = () => { - return ( - - - - ); -}; -WithFourCards.storyName = 'With four cards'; - -export const WithSixCards = () => { - return ( - - - - ); -}; -WithSixCards.storyName = 'With six cards'; - -export const WithNineCards = () => { - return ( - - - - ); -}; -WithNineCards.storyName = 'With nine cards'; diff --git a/dotcom-rendering/src/components/TagFrontFastMpu.tsx b/dotcom-rendering/src/components/TagFrontFastMpu.tsx deleted file mode 100644 index 66296608c1d..00000000000 --- a/dotcom-rendering/src/components/TagFrontFastMpu.tsx +++ /dev/null @@ -1,234 +0,0 @@ -import { Hide } from '@guardian/source-react-components'; -import { Card33Media33, CardDefault } from '../lib/cardWrappers'; -import { type Tuple } from '../lib/tuple'; -import type { DCRFrontCard } from '../types/front'; -import type { GroupedTrailsFastMpu } from '../types/tagFront'; -import { AdSlot } from './AdSlot.web'; -import { LI } from './Card/components/LI'; -import { UL } from './Card/components/UL'; -import type { Loading } from './CardPicture'; - -const TwoCard = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( - - ); -}; - -const FourCard = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( - - ); -}; - -const SixCard = ({ - trails, - adIndex, -}: { - trails: Tuple; - adIndex: number; -}) => { - return ( -
    -
  • -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
  • -
  • -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
  • -
  • - - - -
  • -
- ); -}; - -const NineCard = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( - <> -
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
    -
  • -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
  • -
  • -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
  • -
  • - - - -
  • -
- - ); -}; - -type Props = GroupedTrailsFastMpu & { - adIndex: number; - imageLoading: Loading; -}; - -export const TagFrontFastMpu = ({ trails, adIndex, imageLoading }: Props) => { - switch (trails.length) { - case 2: - return ( - - ); - case 4: - return ( - - ); - case 6: - return ; - case 9: - return ( - - ); - } -}; diff --git a/dotcom-rendering/src/components/TagFrontSlowMpu.stories.tsx b/dotcom-rendering/src/components/TagFrontSlowMpu.stories.tsx deleted file mode 100644 index a57e16fffe8..00000000000 --- a/dotcom-rendering/src/components/TagFrontSlowMpu.stories.tsx +++ /dev/null @@ -1,115 +0,0 @@ -import { breakpoints } from '@guardian/source-foundations'; -import { discussionApiUrl } from '../../fixtures/manual/discussionApiUrl'; -import { trails } from '../../fixtures/manual/trails'; -import { FrontSection } from './FrontSection'; -import { TagFrontSlowMpu } from './TagFrontSlowMpu'; - -export default { - component: TagFrontSlowMpu, - title: 'Components/TagFrontSlowMpu', - parameters: { - chromatic: { - viewports: [ - breakpoints.mobile, - breakpoints.tablet, - breakpoints.wide, - ], - }, - }, -}; - -export const WithTwoCards = () => { - return ( - - - - ); -}; -WithTwoCards.storyName = 'With two cards'; - -export const WithFourCards = () => { - return ( - - - - ); -}; -WithFourCards.storyName = 'With four cards'; - -export const WithFiveCards = () => { - return ( - - - - ); -}; -WithFiveCards.storyName = 'With five cards'; - -export const WithSevenCards = () => { - return ( - - - - ); -}; -WithSevenCards.storyName = 'With seven cards'; diff --git a/dotcom-rendering/src/components/TagFrontSlowMpu.tsx b/dotcom-rendering/src/components/TagFrontSlowMpu.tsx deleted file mode 100644 index 2b4e1532c07..00000000000 --- a/dotcom-rendering/src/components/TagFrontSlowMpu.tsx +++ /dev/null @@ -1,259 +0,0 @@ -import { Hide } from '@guardian/source-react-components'; -import { Card33Media33, Card50Media50, CardDefault } from '../lib/cardWrappers'; -import { type Tuple } from '../lib/tuple'; -import type { DCRFrontCard } from '../types/front'; -import type { GroupedTrailsSlowMpu } from '../types/tagFront'; -import { AdSlot } from './AdSlot.web'; -import { LI } from './Card/components/LI'; -import { UL } from './Card/components/UL'; -import type { Loading } from './CardPicture'; - -const TwoCard = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( -
    -
  • - -
  • -
  • - -
  • -
  • - - - -
  • -
- ); -}; - -const FourCard = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( -
    -
  • - -
  • -
  • -
      -
    • - -
    • -
    • - -
    • -
    • - -
    • -
    -
  • -
  • - - - -
  • -
- ); -}; - -const FiveCard = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( - <> -
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
    -
  • - -
  • -
  • - -
  • -
  • - - - -
  • -
- - ); -}; - -const SevenCards = ({ - trails, - adIndex, - imageLoading, -}: { - trails: Tuple; - adIndex: number; - imageLoading: Loading; -}) => { - return ( - <> -
    -
  • - -
  • -
  • - -
  • -
-
    -
  • - -
  • -
  • - -
  • -
  • - -
  • -
-
    -
  • - -
  • -
  • - -
  • -
  • - - - -
  • -
- - ); -}; - -type Props = GroupedTrailsSlowMpu & { - adIndex: number; - imageLoading: Loading; -}; - -export const TagFrontSlowMpu = ({ trails, adIndex, imageLoading }: Props) => { - switch (trails.length) { - case 2: - return ( - - ); - case 4: - return ( - - ); - case 5: - return ( - - ); - case 7: - return ( - - ); - } -}; diff --git a/dotcom-rendering/src/layouts/TagFrontLayout.tsx b/dotcom-rendering/src/layouts/TagFrontLayout.tsx index b7e49d6218c..8a9eeb8ac73 100644 --- a/dotcom-rendering/src/layouts/TagFrontLayout.tsx +++ b/dotcom-rendering/src/layouts/TagFrontLayout.tsx @@ -19,9 +19,7 @@ import { Island } from '../components/Island'; import { Nav } from '../components/Nav/Nav'; import { Section } from '../components/Section'; import { SubNav } from '../components/SubNav.importable'; -import { TagFrontFastMpu } from '../components/TagFrontFastMpu'; import { TagFrontHeader } from '../components/TagFrontHeader'; -import { TagFrontSlowMpu } from '../components/TagFrontSlowMpu'; import { TrendingTopics } from '../components/TrendingTopics'; import { canRenderAds } from '../lib/canRenderAds'; import { decidePalette } from '../lib/decidePalette'; @@ -216,38 +214,6 @@ export const TagFrontLayout = ({ tagFront, NAV }: Props) => { const imageLoading = index > 0 ? 'lazy' : 'eager'; - const ContainerComponent = () => { - if ( - 'injected' in groupedTrails && - 'speed' in groupedTrails - ) { - if (groupedTrails.speed === 'fast') { - return ( - - ); - } else { - return ( - - ); - } - } - return ( - - ); - }; - const url = groupedTrails.day !== undefined ? `/${tagFront.pageId}/${groupedTrails.year}/${date @@ -302,7 +268,11 @@ export const TagFrontLayout = ({ tagFront, NAV }: Props) => { tagFront.config.discussionApiUrl } > - + {decideMerchHighAndMobileAdSlots( renderAds, diff --git a/dotcom-rendering/src/model/injectMpuIntoGroupedTrails.ts b/dotcom-rendering/src/model/injectMpuIntoGroupedTrails.ts deleted file mode 100644 index 7c16ed7ba2d..00000000000 --- a/dotcom-rendering/src/model/injectMpuIntoGroupedTrails.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { takeFirst } from '../lib/tuple'; -import type { - GroupedTrails, - GroupedTrailsFastMpu, - GroupedTrailsSlowMpu, -} from '../types/tagFront'; - -/** - * Injects an MPU container into a list of grouped trails - * - * For both slow & fast tag fronts, containers of certain lengths can receive an MPU slot. - * The code looks for the first container of the right length and injects the ad slot - * object (GroupedTrailsSlowMpu / GroupedTrailsFastMpu). - */ -export const injectMpuIntoGroupedTrails = ( - groupedTrails: GroupedTrails[], - speed: 'slow' | 'fast', -): Array => { - let injected = false; - - return groupedTrails.map((grouped) => { - if (injected) { - return grouped; - } - - if (speed === 'fast') { - // When we have a container with > 9 trails for fast, - // we 'cap' the number of trails at 9 in order to fit an MPU in. - // Containers that don't get an MPU injected will of course still be - // able to show more than 9 trails. - const fastTrails = takeFirst(grouped.trails, 9); - switch (fastTrails.length) { - case 2: - case 4: - case 6: - case 9: - injected = true; - return { - day: grouped.day, - month: grouped.month, - year: grouped.year, - trails: fastTrails, - injected: true, - speed: 'fast', - }; - default: - return grouped; - } - } else { - // By taking the first 12, we get the benefit of being able to use - // a switch statement here, without 'capping' the number of trails in the - // same way we do when 'fast' - const slowTrails = takeFirst(grouped.trails, 12); - switch (slowTrails.length) { - case 2: - case 4: - case 5: - case 7: - injected = true; - return { - day: grouped.day, - month: grouped.month, - year: grouped.year, - trails: slowTrails, - injected: true, - speed: 'slow', - }; - default: - return grouped; - } - } - }); -}; diff --git a/dotcom-rendering/src/server/index.front.web.ts b/dotcom-rendering/src/server/index.front.web.ts index 2b10ddd7231..cdb1941feb4 100644 --- a/dotcom-rendering/src/server/index.front.web.ts +++ b/dotcom-rendering/src/server/index.front.web.ts @@ -8,7 +8,6 @@ import { extractTrendingTopicsFomFront, } from '../model/extractTrendingTopics'; import { groupTrailsByDates } from '../model/groupTrailsByDates'; -import { injectMpuIntoGroupedTrails } from '../model/injectMpuIntoGroupedTrails'; import { getSpeedFromTrails } from '../model/slowOrFastByTrails'; import { validateAsFrontType, validateAsTagFrontType } from '../model/validate'; import { recordTypeAndPlatform } from '../server/lib/logging-store'; @@ -73,9 +72,7 @@ const enhanceTagFront = (body: unknown): DCRTagFrontType => { return { ...data, tags: data.tags.tags, - groupedTrails: data.isAdFreeUser - ? groupedTrails - : injectMpuIntoGroupedTrails(groupedTrails, speed), + groupedTrails, speed, // Pagination information comes from the first tag pagination: