Skip to content

Commit 53c049a

Browse files
committed
Further tweaks, inc: adding a beta label svg, tightening the spacing in the selected title, and removing the pillar colours to instead just use the main brand colour
1 parent 7522dca commit 53c049a

4 files changed

Lines changed: 156 additions & 88 deletions

File tree

dotcom-rendering/src/components/StorylinesSection.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import { css } from '@emotion/react';
2-
import {
3-
between,
4-
from,
5-
space,
6-
textSans14,
7-
until,
8-
} from '@guardian/source/foundations';
2+
import { between, from, space, textSans14 } from '@guardian/source/foundations';
93
import { Hide } from '@guardian/source/react-components';
104
import { submitComponentEvent } from '../client/ophan/ophan';
115
import { type EditionId, isNetworkFront } from '../lib/edition';
@@ -18,6 +12,7 @@ import { Footer } from './ExpandableAtom/Footer';
1812
import { FrontPagination } from './FrontPagination';
1913
import { FrontSectionTitle } from './FrontSectionTitle';
2014
import { ShowHideButton } from './ShowHideButton';
15+
import { SvgBetaLabel } from './SvgBetaLabel';
2116

2217
type Props = {
2318
/** This text will be used as the h2 shown in the left column for the section */
@@ -265,22 +260,16 @@ const flexRowStyles = css`
265260
justify-content: space-between;
266261
`;
267262

268-
const sectionHeadlineUntilLeftCol = (isOpinion: boolean) => css`
263+
const sectionHeadlineUntilLeftCol = css`
269264
grid-row: headline;
270265
grid-column: title;
271266
display: flex;
272-
flex-direction: column;
267+
flex-direction: row;
268+
justify-content: space-between;
273269
274270
${between.tablet.and.leftCol} {
275271
${flexRowStyles}
276272
}
277-
278-
${isOpinion && until.mobileLandscape} {
279-
flex-direction: column;
280-
}
281-
${isOpinion && between.mobileLandscape.and.tablet} {
282-
${flexRowStyles}
283-
}
284273
`;
285274

286275
const topPadding = css`
@@ -580,13 +569,7 @@ export const StorylinesSection = ({
580569
}}
581570
/>
582571

583-
<div
584-
css={[
585-
sectionHeadlineUntilLeftCol(
586-
title?.toLowerCase() === 'opinion',
587-
),
588-
]}
589-
>
572+
<div css={[sectionHeadlineUntilLeftCol]}>
590573
<FrontSectionTitle
591574
title={
592575
<>
@@ -668,13 +651,34 @@ export const StorylinesSection = ({
668651
}
669652
storylinesStyle={true}
670653
></Footer>
654+
<div
655+
css={css`
656+
display: inline-block;
657+
vertical-align: middle;
658+
width: 75px;
659+
`}
660+
>
661+
<SvgBetaLabel />
662+
</div>
671663
</div>
672664
</Hide>
673665
</div>
674666
</>
675667
}
676668
collectionBranding={undefined}
677669
/>
670+
<Hide from="leftCol">
671+
<div
672+
css={css`
673+
display: flex;
674+
align-items: center;
675+
height: 100%;
676+
width: 48px;
677+
`}
678+
>
679+
<SvgBetaLabel />
680+
</div>
681+
</Hide>
678682
</div>
679683

680684
{(isToggleable || hasNavigationButtons) && (

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

Lines changed: 19 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
textSans17,
99
textSans20,
1010
textSansBold34,
11+
until,
1112
} from '@guardian/source/foundations';
1213
import { Hide } from '@guardian/source/react-components';
1314
import { useState } from 'react';
@@ -28,59 +29,29 @@ type StorylinesSectionProps = {
2829
containerId?: string;
2930
editionId: EditionId;
3031
storylinesContent: StorylinesContent;
31-
pillar?: string;
3232
pagination?: TagPagePagination;
3333
likeHandler?: () => void;
3434
dislikeHandler?: () => void;
3535
};
3636

37-
// AIStorylines: this would be better handled in paletteDeclarations by creating a new css variable if we keep this feature.
38-
const setSelectedStorylineColour = (pillar?: string) => {
39-
switch (pillar?.toLowerCase()) {
40-
case 'news':
41-
return sourcePalette.news[400];
42-
case 'opinion':
43-
return sourcePalette.opinion[400];
44-
case 'sport':
45-
return sourcePalette.sport[400];
46-
case 'culture':
47-
return sourcePalette.culture[400];
48-
case 'lifestyle':
49-
return sourcePalette.lifestyle[400];
50-
default:
51-
return sourcePalette.news[400];
52-
}
53-
};
54-
55-
const selectedTitleStyles = (selectedStorylineColour: string) => css`
37+
const selectedTitleStyles = css`
5638
${textSansBold34}
57-
color: ${selectedStorylineColour};
58-
margin-bottom: ${space[4]}px;
59-
margin-top: ${space[2]}px;
60-
padding-left: 10px; /* aligns with the headlines of the stories below */
61-
`;
62-
63-
const setCategoryColour = (pillar?: string) => {
64-
switch (pillar?.toLowerCase()) {
65-
case 'news':
66-
return sourcePalette.news[300];
67-
case 'opinion':
68-
return sourcePalette.opinion[400];
69-
case 'sport':
70-
return sourcePalette.sport[300];
71-
case 'culture':
72-
return sourcePalette.culture[300];
73-
case 'lifestyle':
74-
return sourcePalette.lifestyle[300];
75-
default:
76-
return sourcePalette.news[300];
39+
color: ${sourcePalette.brand[400]};
40+
margin-bottom: ${space[2]}px;
41+
${until.tablet} {
42+
line-height: 1.2;
43+
padding-left: 0px;
7744
}
78-
};
45+
${from.tablet} {
46+
line-height: 1.3;
47+
padding-left: 10px; /* aligns with the headlines of the stories below */
48+
}
49+
`;
7950

80-
const categoryTitleCss = (pillarColour: string) => css`
51+
const categoryTitleCss = css`
8152
${textSans20};
8253
font-weight: 700;
83-
color: ${pillarColour};
54+
color: ${sourcePalette.brand[400]};
8455
margin: ${space[2]}px 0;
8556
padding: ${space[1]}px 0;
8657
${from.tablet} {
@@ -101,10 +72,10 @@ const tabsContainerStyles = css`
10172
display: flex;
10273
width: 100%;
10374
${from.wide} {
104-
width: 110%;
105-
} /* bit hacky, but looks a touch better on wide. */
75+
width: 110%; /* bit hacky, but looks a touch better on wide. */
76+
margin-bottom: ${space[2]}px;
77+
}
10678
align-items: stretch; /* Makes all tabs the same height */
107-
margin-bottom: ${space[6]}px;
10879
margin-left: -${space[2]}px;
10980
`;
11081

@@ -196,7 +167,6 @@ export const StorylinesSectionContent = ({
196167
containerId,
197168
storylinesContent,
198169
editionId,
199-
pillar,
200170
pagination,
201171
dislikeHandler,
202172
likeHandler,
@@ -216,10 +186,6 @@ export const StorylinesSectionContent = ({
216186
(s) => s.id === activeStorylineId,
217187
);
218188

219-
const selectedStorylineColour = setSelectedStorylineColour(pillar);
220-
221-
const categoryColour = setCategoryColour(pillar);
222-
223189
function handleStorylineChange(newStorylineId: string) {
224190
const currentId = activeStorylineId;
225191
setActiveStorylineId(newStorylineId);
@@ -291,18 +257,14 @@ export const StorylinesSectionContent = ({
291257
</div>
292258
{/* Active storyline title */}
293259
{activeStoryline && (
294-
<div css={selectedTitleStyles(selectedStorylineColour)}>
295-
{activeStoryline.title}
296-
</div>
260+
<div css={selectedTitleStyles}>{activeStoryline.title}</div>
297261
)}
298262
{/* Content by categories */}
299263
<div css={contentStyles}>
300264
{activeStoryline?.categories.map((category, idx) => (
301265
<div key={idx} css={contentCss}>
302266
{category.title !== 'Key Stories' && (
303-
<h2 css={categoryTitleCss(categoryColour)}>
304-
{category.title}
305-
</h2>
267+
<h2 css={categoryTitleCss}>{category.title}</h2>
306268
)}
307269
<FlexibleGeneral
308270
groupedTrails={category.groupedTrails}
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/**
2+
* Used to indicate a beta feature.
3+
* At the moment this is just used for the AI storylines section on tag pages.
4+
* If commonly reused in the future, might benefit from being uploaded to guim.co.uk or moved to source.
5+
*/
6+
export const SvgBetaLabel = () => (
7+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 74.23 74.23">
8+
<defs>
9+
<style>
10+
{`.cls-1 {
11+
fill: #94daf8;
12+
}
13+
14+
.cls-2 {
15+
fill: #f9f9fa;
16+
}
17+
18+
.cls-3 {
19+
isolation: isolate;
20+
}
21+
22+
.cls-4 {
23+
mix-blend-mode: multiply;
24+
}
25+
26+
.cls-5 {
27+
fill: #1f2f60;
28+
fill-rule: evenodd;
29+
}`}
30+
</style>
31+
</defs>
32+
<g className="cls-3">
33+
<g id="Layer_1">
34+
<g className="cls-4">
35+
<path
36+
className="cls-5"
37+
d="M37.11,0C16.62,0,0,16.62,0,37.11s16.62,37.11,37.11,37.11,37.11-16.62,37.11-37.11S57.61,0,37.11,0Z"
38+
/>
39+
</g>
40+
<polygon
41+
className="cls-2"
42+
points="17.72 31.92 18.95 31.28 18.95 21.62 18.02 21.62 15.75 24.63 15.49 24.63 15.64 21.27 25.49 21.27 25.63 24.63 25.36 24.63 23.14 21.62 22.18 21.62 22.18 31.26 23.42 31.92 23.42 32.24 17.72 32.24 17.72 31.92"
43+
/>
44+
<path
45+
className="cls-2"
46+
d="M26.76,31.5v-10.72l-.95-.38v-.2l3.46-.62h.36v5.07l.1-.08c.76-.67,1.86-1.1,2.96-1.1,1.51,0,2.18.85,2.18,2.44v5.58l.81.44v.32s-4.52,0-4.52,0v-.32l.81-.44v-5.6c0-.88-.38-1.23-1.1-1.23-.48,0-.89.15-1.19.39v6.45l.8.44v.31h-4.52v-.31l.81-.46Z"
47+
/>
48+
<path
49+
className="cls-2"
50+
d="M38.52,28.21c.09,1.77.89,3.14,2.77,3.14.91,0,1.55-.42,2.16-.74v.35c-.47.64-1.66,1.55-3.32,1.55-2.91,0-4.4-1.62-4.4-4.43s1.63-4.45,4.26-4.45c2.48,0,3.76,1.24,3.76,4.5v.08h-5.23ZM38.47,27.8l2.56-.16c0-2.19-.38-3.65-1.13-3.65-.8,0-1.44,1.69-1.44,3.81"
51+
/>
52+
<path
53+
className="cls-2"
54+
d="M1.46,36.53c0-4.66,3.09-6.32,6.53-6.32,1.46,0,2.84.23,3.61.55l.07,3.25h-.33l-2.02-3.15c-.35-.15-.67-.21-1.28-.21-1.83,0-2.76,2.11-2.73,5.58.03,4.14.75,6.02,2.43,6.02.44,0,.77-.07,1.01-.17v-4.44l-1.11-.63v-.37h5.35v.4l-1.09.61v4.38c-.91.35-2.43.69-4.04.69-3.91,0-6.39-1.81-6.39-6.19"
55+
/>
56+
<path
57+
className="cls-2"
58+
d="M12.93,34.36v-.27l3.6-.63.39.03v7.09c0,.85.41,1.12,1.1,1.12.44,0,.85-.17,1.17-.55v-6.36l-.99-.43v-.28l3.6-.63.36.03v8.13l.97.41v.26l-3.55.44-.36-.03v-1.07h-.1c-.66.61-1.58,1.13-2.7,1.13-1.73,0-2.52-1.02-2.52-2.56v-5.39l-.99-.43Z"
59+
/>
60+
<path
61+
className="cls-2"
62+
d="M35.94,33.44l.3.03v2.63s.08,0,.08,0c.38-1.93,1.23-2.64,2.27-2.64.16,0,.35.02.44.07v2.69c-.16-.05-.46-.07-.74-.07-.82,0-1.43.15-1.96.39v5.19s.82.45.82.45v.34s-4.67,0-4.67,0v-.33l.84-.46v-7.08l-.99-.29v-.24l3.6-.67Z"
63+
/>
64+
<path
65+
className="cls-2"
66+
d="M44.98,33.66v-2.77l-.99-.35v-.22l3.63-.67.35.05v11.9l1,.36v.31l-3.58.48-.28-.03v-.98h-.08c-.53.53-1.25,1-2.38,1-1.96,0-3.39-1.5-3.39-4.55,0-3.22,1.66-4.81,4.18-4.81.72,0,1.27.13,1.54.28M44.98,41.28v-7.11c-.23-.15-.4-.33-.99-.31-.97.03-1.57,1.5-1.57,4.11,0,2.35.43,3.66,1.73,3.62.36-.01.66-.14.84-.32"
67+
/>
68+
<path
69+
className="cls-2"
70+
d="M52.97,33.43l.31.03v8.26l.82.45v.34s-4.67,0-4.67,0v-.33l.84-.46v-6.95l-1-.39v-.28l3.7-.67ZM53.3,31.2c0,.87-.74,1.53-1.59,1.53s-1.58-.66-1.58-1.53.69-1.55,1.58-1.55,1.59.67,1.59,1.55"
71+
/>
72+
<path
73+
className="cls-2"
74+
d="M64.58,41.72v-7.03l-.99-.35v-.34l3.58-.67.36.03v1.05h.1c.77-.69,1.92-1.13,3.06-1.13,1.56,0,2.25.74,2.25,2.38v6.03l.84.47v.34s-4.67,0-4.67,0v-.33l.84-.46v-5.88c0-.9-.39-1.27-1.13-1.27-.48,0-.87.12-1.23.39v6.75l.82.46v.34h-4.67v-.33l.84-.46Z"
75+
/>
76+
<path
77+
className="cls-2"
78+
d="M59.4,37.3v-1.18c0-1.78-.39-2.36-1.49-2.36-.13,0-.24.02-.37.03l-1.95,2.65h-.27v-2.44c.84-.26,1.89-.57,3.28-.57,2.39,0,3.78.66,3.78,2.66v5.75l.86.23v.23c-.34.21-1.02.4-1.76.4-1.18,0-1.74-.39-2-1.03h-.08c-.5.68-1.21,1.07-2.32,1.07-1.42,0-2.39-.89-2.39-2.42s.92-2.29,2.79-2.65l1.94-.37ZM59.4,41.28v-3.55l-.6.05c-.94.08-1.28.68-1.28,2,0,1.44.47,1.81,1.13,1.81.37,0,.58-.11.74-.31"
79+
/>
80+
<path
81+
className="cls-2"
82+
d="M28.17,37.3v-1.18c0-1.78-.39-2.36-1.49-2.36-.13,0-.24.02-.37.03l-1.95,2.65h-.27v-2.44c.84-.26,1.89-.57,3.28-.57,2.39,0,3.78.66,3.78,2.66v5.75l.86.23v.23c-.34.21-1.02.4-1.76.4-1.18,0-1.74-.39-2-1.03h-.08c-.5.68-1.21,1.07-2.33,1.07-1.42,0-2.39-.89-2.39-2.42s.92-2.29,2.79-2.65l1.94-.37ZM28.17,41.28v-3.55l-.6.05c-.94.08-1.28.68-1.28,2,0,1.44.47,1.81,1.13,1.81.37,0,.58-.11.74-.31"
83+
/>
84+
<g>
85+
<path
86+
className="cls-1"
87+
d="M18.84,55.85v-12.19h2.45v4.54h.08c.61-.62,1.33-1.07,2.53-1.07,1.5,0,3.14.87,3.14,4.01v.81c0,3.22-1.56,4.54-4.57,4.54-1.38,0-2.73-.26-3.63-.64ZM24.51,52.3v-.9c0-1.87-.54-2.25-1.79-2.25-.58,0-1.13.21-1.43.36v5c.28.13.67.28,1.33.28,1.09,0,1.89-.54,1.89-2.48Z"
88+
/>
89+
<path
90+
className="cls-1"
91+
d="M28.08,52.24v-.86c0-2.76,1.63-4.24,4.1-4.24,2.66,0,3.86,1.4,3.86,4.24v1.17h-5.46c.1,1.61.87,1.99,2.53,1.99,1.09,0,1.89-.23,2.61-.51v1.69c-.64.35-1.64.76-3.21.76-2.99,0-4.44-1.43-4.44-4.24ZM30.53,50.95h3.12c0-1.63-.56-2.07-1.5-2.07-.82,0-1.58.36-1.63,2.07Z"
92+
/>
93+
<path
94+
className="cls-1"
95+
d="M38.11,54.01v-4.84h-1.28v-1.88h1.28v-2.14h2.45v2.14h2.01v1.88h-2.01v4.46c0,.71.3.89,1.07.89.31,0,.74-.07,1.02-.15v1.66c-.36.2-1.05.41-1.92.41-1.64,0-2.61-.56-2.61-2.43Z"
96+
/>
97+
<path
98+
className="cls-1"
99+
d="M43.57,53.9c0-1.81,1.15-2.48,2.98-2.71l1.76-.25v-.54c0-.95-.46-1.23-1.81-1.23-.85,0-1.64.13-2.22.26v-1.78c.87-.35,1.91-.51,3.17-.51,2.15,0,3.31.81,3.31,2.85v6.33h-2.02l-.20-.87h-.10c-.38.59-1.12,1.04-2.19,1.04-1.6,0-2.68-.86-2.68-2.58ZM48.3,54.44v-2.12l-1.25.13c-.76.08-1.10.46-1.10,1.27s.48,1.15,1.12,1.15c.49,0,.99-.18,1.23-.43Z"
100+
/>
101+
</g>
102+
</g>
103+
</g>
104+
</svg>
105+
);

dotcom-rendering/src/layouts/TagPageLayout.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,11 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
142142
tagPage.pagination.currentPage === 1) && // Only on the first page
143143
index === 0; // Only after the first section
144144

145-
/**
146-
* The pagination should appear at the bottom of the page; usually this is done by passing to FrontSection.
147-
* If the storylines section is being inserted when there's only one other container on the page,
148-
* we want to attach the pagination to it instead of the last trails section.
149-
*/
145+
/**
146+
* The pagination should appear at the bottom of the page; usually this is done by passing to FrontSection.
147+
* If the storylines section is being inserted when there's only one other container on the page,
148+
* we want to attach the pagination to it instead of the last trails section.
149+
*/
150150
const tagPagePagination =
151151
index === tagPage.groupedTrails.length - 1 &&
152152
tagPage.pagination &&
@@ -213,9 +213,6 @@ export const TagPageLayout = ({ tagPage, NAV }: Props) => {
213213
tagPage.storylinesContent
214214
}
215215
containerId="storylines"
216-
pillar={
217-
tagPage.nav.currentPillarTitle
218-
}
219216
pagination={paginationForStorylines}
220217
/>
221218
</Island>

0 commit comments

Comments
 (0)