Skip to content

Commit 56497b1

Browse files
committed
tidy
1 parent e2f5c91 commit 56497b1

File tree

8 files changed

+72
-141
lines changed

8 files changed

+72
-141
lines changed

dotcom-rendering/src/components/Card/Card.tsx

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -522,20 +522,27 @@ export const Card = ({
522522
`}
523523
`}
524524
>
525-
{/* We add this card footer here because ordinarily, it's either the pill or the footer, but
526-
we need to display the date on these cards if they appear in the storylines section */}
525+
{/* Ordinarily, it's either the pill or the footer, but we want to display the date on these cards if they appear in the storylines section on tag pages.
526+
Bit of padding to align with the start of the pill type.
527+
*/}
527528
{storylinesStyle && (
528-
<CardFooter
529-
format={format}
530-
age={decideAge()}
531-
commentCount={<CommentCount />}
532-
cardBranding={
533-
isOnwardContent || !showLabsRedesign ? (
534-
<LabsBranding />
535-
) : undefined
536-
}
537-
showLivePlayable={showLivePlayable}
538-
/>
529+
<div
530+
css={css`
531+
padding-left: ${space[2]}px;
532+
`}
533+
>
534+
<CardFooter
535+
format={format}
536+
age={decideAge()}
537+
commentCount={<CommentCount />}
538+
cardBranding={
539+
isOnwardContent || !showLabsRedesign ? (
540+
<LabsBranding />
541+
) : undefined
542+
}
543+
showLivePlayable={showLivePlayable}
544+
/>
545+
</div>
539546
)}
540547

541548
{mainMedia?.type === 'YoutubeVideo' && isVideoArticle && (
@@ -1245,7 +1252,11 @@ export const Card = ({
12451252
flex-grow: 1;
12461253
`}
12471254
>
1248-
{/* why is this needed, to hide the headline if we're in the splash? */}
1255+
{/* In the storylines section on tag pages, the flex splash is used to display key stories.
1256+
This is shown as a large image taken from the first article in the group, and the headlines of the first four key articles (include that of the first article).
1257+
Therefore, we don't display an article headline in the conventional sense, these are displayed as "supporting content".
1258+
However, simply passing an empty string as the article headline still reserves space, so this check enables us to avoid rendering that space at all.
1259+
*/}
12491260
{storylinesStyle && isFlexSplash
12501261
? null
12511262
: headlinePosition === 'inner' && (

dotcom-rendering/src/components/FlexibleGeneral.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Props = {
3636
/** Feature flag for the labs redesign work */
3737
showLabsRedesign?: boolean;
3838
enableHls?: boolean;
39+
/** Passed through to cards to enable tag page storyline section specific rendering */
3940
storylinesStyle?: boolean;
4041
};
4142

dotcom-rendering/src/components/StorylineSection.tsx

Lines changed: 17 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -278,22 +278,6 @@ const sectionHeadlineUntilLeftCol = (isOpinion: boolean) => css`
278278
}
279279
`;
280280

281-
// const sectionHeadlineFromLeftCol = (borderColour: string) => css`
282-
// ${from.leftCol} {
283-
// position: relative;
284-
// ::after {
285-
// content: '';
286-
// display: block;
287-
// width: 1px;
288-
// top: 0;
289-
// height: 1.875rem;
290-
// right: -10px;
291-
// position: absolute;
292-
// background-color: ${borderColour};
293-
// }
294-
// }
295-
// `;
296-
297281
const topPadding = css`
298282
padding-top: ${space[2]}px;
299283
`;
@@ -424,6 +408,8 @@ const carouselNavigationPlaceholder = css`
424408
}
425409
`;
426410

411+
/// todo: finish mobile and tablet representation
412+
427413
/**
428414
* # Front Container
429415
*
@@ -468,42 +454,37 @@ const carouselNavigationPlaceholder = css`
468454
* 1 2 3 4 5 6 7 8 9 a b c d e (14)
469455
* ┌───┬───────────────────┬─┐
470456
* │Tit│ │X│
471-
* │Dat├───────────────────┴─┤
457+
* │AI├───────────────────┴─┤
472458
* ├───┤▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
473459
* │ │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
474-
* │Tre│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
475-
* │ats│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
460+
* │Foo│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
461+
* │ter│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
476462
* ├───┼─────────────────────┤
477-
* │ │Show More │
478-
* └───┴─────────────────────┘
479463
*
480464
* on `leftCol` (1140) if component is not toggleable
481465
*
482466
* 1 2 3 4 5 6 7 8 9 a b c d e (14)
483467
* ┌───┬──────────────────────┐
484468
* │Tit│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
485-
* │Dat│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
469+
* │AI │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
486470
* ├───┤▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
487471
* │ │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
488-
* │Tre│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
489-
* │ats│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
472+
* │Foo│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│
473+
* │ter │Content context line
490474
* ├───┼──────────────────────┤
491-
* │ │Show More │
492-
* └───┴──────────────────────┘
493475
*
494476
* on `wide` (1300)
495477
*
496478
* 1 2 3 4 5 6 7 8 9 a b c d e f g (16)
497-
* ┌─────┬───────────────────────┬─┐
498-
* │Title│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│X│
499-
* │Date │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒└─┤
500-
* ├─────┤▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
501-
* │ │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
502-
* │ │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
503-
* │Treat│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
504-
* ├─────┼─────────────────────────┤
505-
* │ │Show More │
506-
* └─────┴─────────────────────────┘
479+
* ┌──────┬───────────────────────┬─┐
480+
* │Title │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒│X│
481+
* │AI │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒└─┤
482+
* │Notice│▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
483+
* ├─────-┤▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
484+
* │ │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
485+
* │ │▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ │
486+
* │Footer│Content context line │
487+
* ├────────────────────────────────┤
507488
*
508489
*/
509490

@@ -539,11 +520,6 @@ export const StorylineSection = ({
539520
const isToggleable = toggleable && !!sectionId;
540521
const isBetaContainer = !!containerLevel;
541522

542-
// These are for beta containers only
543-
// const useLargeSpacingMobile = !!isNextCollectionPrimary || isAboveMobileAd;
544-
// const useLargeSpacingDesktop =
545-
// !!isNextCollectionPrimary || isAboveDesktopAd;
546-
547523
const showSectionColours = isNetworkFront(pageId ?? '');
548524

549525
/**
@@ -595,9 +571,6 @@ export const StorylineSection = ({
595571
<div
596572
css={[
597573
sectionHeadlineUntilLeftCol(
598-
// TODO FIXME:
599-
// This relies on sections called "opinion"
600-
// only ever having <CPScott> as the leftContent
601574
title?.toLowerCase() === 'opinion',
602575
),
603576
]}
@@ -665,7 +638,6 @@ export const StorylineSection = ({
665638
sectionContentHorizontalMargins,
666639
sectionContentRow(toggleable),
667640
topPadding,
668-
// showVerticalRule &&
669641
isBetaContainer && sectionContentBorderFromLeftCol,
670642
]}
671643
id={`container-${sectionId}`}

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

Lines changed: 14 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
} from '@guardian/source/foundations';
1212
import { useState } from 'react';
1313
import type { EditionId } from '../lib/edition';
14-
import { parseStorylinesContentToStorylines } from '../model/enhanceAITagPageContent';
14+
import { parseStorylinesContentToStorylines } from '../model/enhanceTagPageStorylinesContent';
1515
import { palette } from '../palette';
1616
import type { StorylinesContent } from '../types/storylinesContent';
1717
import { FlexibleGeneral } from './FlexibleGeneral';
@@ -51,10 +51,10 @@ const tabsContainerStyles = css`
5151
width: 100%;
5252
${from.wide} {
5353
width: 110%;
54-
} /* bit hacky, but looks a touch better on wide. Maybe there's a better way though */
54+
} /* bit hacky, but looks a touch better on wide. */
5555
align-items: stretch; /* Makes all tabs the same height */
5656
margin-bottom: ${space[6]}px;
57-
margin-left: -${space[2]}px; /* on mobile at least */
57+
margin-left: -${space[2]}px;
5858
`;
5959

6060
const tabStyles = (isActive: boolean, isFirst: boolean) => css`
@@ -78,8 +78,6 @@ const contentStyles = css`
7878
padding-top: ${space[0]}px 0;
7979
`;
8080

81-
// ${textSans17};
82-
// font-weight: 700;
8381
const selectedTitleStyles = css`
8482
${textSansBold34}
8583
color: ${sourcePalette.news[400]};
@@ -147,33 +145,9 @@ export const StorylinesSection = ({
147145
storylinesContent,
148146
editionId,
149147
}: StorylinesSectionProps) => {
150-
console.log('has StorylinesContent', !!storylinesContent);
151-
// console.log('StorylinesContent', StorylinesContent);
152-
// const [storylines, SetStorylines] = useState<StorylinesContent>();
153-
const storylines = storylinesContent;
154-
155-
// useEffect(() => {
156-
// fetch(
157-
// `http://localhost:9000/api/tag-page-rendering/${tagPage.pageId}`,
158-
// {
159-
// headers: {
160-
// 'Content-Type': 'application/json',
161-
// },
162-
// credentials: 'include',
163-
// },
164-
// )
165-
// .then((response) => {
166-
// console.log('response', response);
167-
// return response.json();
168-
// })
169-
// .then((data) => SetStorylines(data))
170-
// .catch((error) => {
171-
// console.error('Error fetching storylines data:', error);
172-
// });
173-
// }, []);
174-
175148
const parsedStorylines =
176-
storylines && parseStorylinesContentToStorylines(storylines);
149+
storylinesContent &&
150+
parseStorylinesContentToStorylines(storylinesContent);
177151

178152
const [activeStorylineId, setActiveStorylineId] = useState<string>(
179153
parsedStorylines?.[0]?.id ?? '',
@@ -187,14 +161,6 @@ export const StorylinesSection = ({
187161
(s) => s.id === activeStorylineId,
188162
);
189163

190-
/** frontsection with background, title, AI warning on the left,
191-
*
192-
* section - mostly a copy of frontsection - done?
193-
* tabs - tweak style
194-
* tab content
195-
* -> container wrapper (category title or not)
196-
* ---> decide container
197-
*/
198164
return (
199165
<>
200166
<StorylineSection
@@ -206,8 +172,6 @@ export const StorylinesSection = ({
206172
ophanComponentLink={`container-${index} | ${containerId}`}
207173
ophanComponentName={containerId}
208174
sectionId={containerId}
209-
toggleable={false} //maybe set to true if this still works?
210-
// pageId={tagPage.pageId}
211175
editionId={editionId}
212176
>
213177
{/* Tab selector */}
@@ -227,13 +191,9 @@ export const StorylinesSection = ({
227191
activeStorylineId === storyline.id,
228192
i === 0,
229193
)}
230-
onClick={() => {
231-
console.log(
232-
'clicked storyline',
233-
storyline.id,
234-
);
235-
setActiveStorylineId(storyline.id);
236-
}}
194+
onClick={() =>
195+
setActiveStorylineId(storyline.id)
196+
}
237197
type="button"
238198
>
239199
{activeStorylineId === storyline.id ? (
@@ -268,11 +228,11 @@ export const StorylinesSection = ({
268228
))}
269229
</ScrollableCarousel>
270230
</div>
271-
{/* Selected title */}
231+
{/* Storyline title */}
272232
{activeStoryline && (
273233
<div css={selectedTitleStyles}>{activeStoryline.title}</div>
274234
)}
275-
{/* Tabs content */}
235+
{/* Content by categories */}
276236
<div css={contentStyles}>
277237
{activeStoryline?.categories.map((category, idx) => (
278238
<div key={idx} css={contentCss}>
@@ -290,12 +250,13 @@ export const StorylinesSection = ({
290250
</div>
291251
))}
292252
</div>
253+
{/* Context on article date range */}
293254
<div css={articleCountAndDateRangeStyle}>
294255
{`These storylines were curated from articles published ${formatDateRangeText(
295-
storylines.earliestArticleTime,
296-
storylines.latestArticleTime,
256+
storylinesContent.earliestArticleTime,
257+
storylinesContent.latestArticleTime,
297258
)}. Some articles may be older to provide further context.`}
298-
</div>{' '}
259+
</div>
299260
</StorylineSection>
300261
</>
301262
);

dotcom-rendering/src/components/SupportingContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export const SupportingContent = ({
209209
}}
210210
/>
211211
{/* {subLink.kickerText}
212-
card age below obviously istag page is a lie, I'll tweak that in a bit
212+
todo: card age below obviously istag page is a lie, I'll tweak that in a bit
213213
*/}
214214
<CardAge
215215
webPublication={{

dotcom-rendering/src/layouts/TagPageLayout.tsx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,22 +66,6 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
6666
const isAccessibilityPage =
6767
tagPage.config.pageId === 'help/accessibility-help';
6868

69-
// const isSCTagPage = process.env.NODE_ENV === 'development';
70-
71-
// console.log(
72-
// 'isSCTagPage:',
73-
// isSCTagPage,
74-
// 'tagPage.webURL:',
75-
// tagPage.webURL,
76-
// 'isDev:', //isDev doesn't actually work?
77-
// tagPage.config.isDev,
78-
// 'is node env',
79-
// process.env.NODE_ENV,
80-
// );
81-
82-
console.log('has tagPage.StorylinesContent:', !!tagPage.storylinesContent);
83-
console.log('tagPage.StorylinesContent:', tagPage.storylinesContent);
84-
8569
return (
8670
<>
8771
<div data-print-layout="hide" id="bannerandheader">
@@ -126,7 +110,6 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
126110
image={tagPage.header.image}
127111
/>
128112
{tagPage.groupedTrails.map((groupedTrails, index) => {
129-
// console.log("groupedTrails in TagPageLayout:", groupedTrails);
130113
const imageLoading = index > 0 ? 'lazy' : 'eager';
131114

132115
const title = isUndefined(groupedTrails.day)
@@ -154,7 +137,6 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
154137

155138
const insertSCSection =
156139
tagPage.storylinesContent &&
157-
// isSCTagPage &&
158140
index == 1 &&
159141
(!tagPage.pagination ||
160142
tagPage.pagination.currentPage === 1);

0 commit comments

Comments
 (0)