From 18447939ffdbcecc86c07a098c0109c878b4f34b Mon Sep 17 00:00:00 2001 From: Daniel Clifton <110032454+DanielCliftonGuardian@users.noreply.github.com> Date: Fri, 6 Oct 2023 11:13:29 +0100 Subject: [PATCH] Add `CommentLayout` for apps (#9026) * commentlayout for apps * add priority to islands --- .../scripts/gen-stories/get-stories.js | 6 + .../src/layouts/CommentLayout.tsx | 404 ++++++++++-------- dotcom-rendering/src/layouts/DecideLayout.tsx | 18 +- .../stories/generated/Layout.stories.tsx | 13 + 4 files changed, 264 insertions(+), 177 deletions(-) diff --git a/dotcom-rendering/scripts/gen-stories/get-stories.js b/dotcom-rendering/scripts/gen-stories/get-stories.js index 23da4424c2c..b5660e95302 100644 --- a/dotcom-rendering/scripts/gen-stories/get-stories.js +++ b/dotcom-rendering/scripts/gen-stories/get-stories.js @@ -165,6 +165,12 @@ const testLayoutFormats = [ theme: 'OpinionPillar', renderingTarget: 'Web', }, + { + display: 'Standard', + design: 'Comment', + theme: 'NewsPillar', + renderingTarget: 'Apps', + }, ]; const generateLayoutStories = () => { diff --git a/dotcom-rendering/src/layouts/CommentLayout.tsx b/dotcom-rendering/src/layouts/CommentLayout.tsx index e2dcfe8db37..e8b108c8825 100644 --- a/dotcom-rendering/src/layouts/CommentLayout.tsx +++ b/dotcom-rendering/src/layouts/CommentLayout.tsx @@ -10,7 +10,9 @@ import { until, } from '@guardian/source-foundations'; import { StraightLines } from '@guardian/source-react-components-development-kitchen'; +import { AdPortals } from '../components/AdPortals.importable'; import { AdSlot, MobileStickyContainer } from '../components/AdSlot.web'; +import { AppsFooter } from '../components/AppsFooter.importable'; import { ArticleBody } from '../components/ArticleBody'; import { ArticleContainer } from '../components/ArticleContainer'; import { ArticleHeadline } from '../components/ArticleHeadline'; @@ -18,7 +20,6 @@ import { ArticleMeta } from '../components/ArticleMeta'; import { ArticleTitle } from '../components/ArticleTitle'; import { Border } from '../components/Border'; import { Carousel } from '../components/Carousel.importable'; -import { useConfig } from '../components/ConfigContext'; import { ContributorAvatar } from '../components/ContributorAvatar'; import { DiscussionLayout } from '../components/DiscussionLayout'; import { Footer } from '../components/Footer'; @@ -48,6 +49,7 @@ import { decideTrail } from '../lib/decideTrail'; import { parse } from '../lib/slot-machine-flags'; import type { NavType } from '../model/extract-nav'; import type { DCRArticle } from '../types/frontend'; +import type { RenderingTarget } from '../types/renderingTarget'; import { BannerWrapper, SendToBack, Stuck } from './lib/stickiness'; const StandardGrid = ({ @@ -258,13 +260,23 @@ const mainMediaWrapper = css` position: relative; `; -interface Props { +interface CommonProps { article: DCRArticle; - NAV: NavType; format: ArticleFormat; + renderingTarget: RenderingTarget; +} + +interface WebProps extends CommonProps { + NAV: NavType; + renderingTarget: 'Web'; } -export const CommentLayout = ({ article, NAV, format }: Props) => { +interface AppsProps extends CommonProps { + renderingTarget: 'Apps'; +} + +export const CommentLayout = (props: WebProps | AppsProps) => { + const { article, format, renderingTarget } = props; const { config: { isPaidContent, host }, } = article; @@ -290,130 +302,141 @@ export const CommentLayout = ({ article, NAV, format }: Props) => { const contributionsServiceUrl = getContributionsServiceUrl(article); - const renderAds = canRenderAds(article); - - const { renderingTarget } = useConfig(); + const renderAds = renderingTarget === 'Web' && canRenderAds(article); return ( <> -
- {renderAds && ( - -
- -
-
- )} + {renderingTarget === 'Web' && ( +
+ {renderAds && ( + +
+ +
+
+ )} + + + {format.theme !== ArticleSpecial.Labs && ( +
+
+
+ )} - - {format.theme !== ArticleSpecial.Labs && (
-
- )} -
-
+ {props.NAV.subNavSections && ( +
+ + + +
+ )} - {NAV.subNavSections && (
- - - +
- )} - -
- -
-
-
+ +
+ )}
+ {renderingTarget === 'Apps' && ( + + + + )}
{ switches={article.config.switches} isAdFreeUser={article.isAdFreeUser} isSensitive={article.config.isSensitive} - imagesForAppsLightbox={[]} + imagesForAppsLightbox={ + article.imagesForAppsLightbox + } /> @@ -589,7 +614,9 @@ export const CommentLayout = ({ article, NAV, format }: Props) => { isRightToLeftLang={ article.isRightToLeftLang } - imagesForAppsLightbox={[]} + imagesForAppsLightbox={ + article.imagesForAppsLightbox + } /> {showBodyEndSlot && ( {
)} - - - + {renderingTarget === 'Web' && ( + + + + )} {!isPaidContent && showComments && (
{
)} - {!isPaidContent && ( + {renderingTarget === 'Web' && !isPaidContent && (
{ )}
- {NAV.subNavSections && ( + {renderingTarget === 'Web' && props.NAV.subNavSections && (
)} + {renderingTarget === 'Web' && !isPaidContent && ( + <> +
+
-
-
- - - + + + + + + + )} + {renderingTarget === 'Apps' && ( +
- - - - + + + +
+ )} ); }; diff --git a/dotcom-rendering/src/layouts/DecideLayout.tsx b/dotcom-rendering/src/layouts/DecideLayout.tsx index c4c91b04ae1..d5e20de79ff 100644 --- a/dotcom-rendering/src/layouts/DecideLayout.tsx +++ b/dotcom-rendering/src/layouts/DecideLayout.tsx @@ -59,7 +59,13 @@ const DecideLayoutApps = ({ article, format, renderingTarget }: AppProps) => { case ArticleDesign.Editorial: case ArticleDesign.Letter: // Should be CommentLayout once implemented for apps - return notSupported; + return ( + + ); case ArticleDesign.Picture: // Should be PictureLayout once implemented for apps return notSupported; @@ -96,7 +102,13 @@ const DecideLayoutApps = ({ article, format, renderingTarget }: AppProps) => { case ArticleDesign.Editorial: case ArticleDesign.Letter: // Should be CommentLayout once implemented for apps - return notSupported; + return ( + + ); case ArticleDesign.NewsletterSignup: return notSupported; default: @@ -166,6 +178,7 @@ const DecideLayoutWeb = ({ article={article} NAV={NAV} format={format} + renderingTarget={renderingTarget} /> ); case ArticleDesign.Picture: @@ -225,6 +238,7 @@ const DecideLayoutWeb = ({ article={article} NAV={NAV} format={format} + renderingTarget={renderingTarget} /> ); case ArticleDesign.NewsletterSignup: diff --git a/dotcom-rendering/stories/generated/Layout.stories.tsx b/dotcom-rendering/stories/generated/Layout.stories.tsx index 11e0cae3f91..ac313b5f357 100644 --- a/dotcom-rendering/stories/generated/Layout.stories.tsx +++ b/dotcom-rendering/stories/generated/Layout.stories.tsx @@ -68,3 +68,16 @@ export const WebShowcasePictureOpinionPillar = () => { }; WebShowcasePictureOpinionPillar.storyName = 'Web: Display: Showcase, Design: Picture, Theme: OpinionPillar'; WebShowcasePictureOpinionPillar.args = { config: { renderingTarget: 'Web' } }; + +export const AppsStandardCommentNewsPillar = () => { + return ( + + ); +}; +AppsStandardCommentNewsPillar.storyName = 'Apps: Display: Standard, Design: Comment, Theme: NewsPillar'; +AppsStandardCommentNewsPillar.args = { config: { renderingTarget: 'Apps' } };