Skip to content

Commit 182cbd1

Browse files
authored
Merge pull request #14894 from guardian/gallery-secondary-onward-container
Add new scrollable onwards container with new design
2 parents e8a9dc0 + e93889e commit 182cbd1

17 files changed

+660
-305
lines changed

dotcom-rendering/fixtures/generated/story-package.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const storyPackage: FEStoryPackage = {
3838
theme: 'NewsPillar',
3939
display: 'StandardDisplay',
4040
},
41-
webPublicationDate: '2025-03-24T19:00:47.000Z',
41+
webPublicationDate: '2022-01-01T11:00:47.000Z',
4242
headline:
4343
'Nasa rover discovers largest organic compounds yet found on Mars',
4444
shortUrl: 'https://www.theguardian.com/p/xxp8eq',
@@ -69,7 +69,7 @@ export const storyPackage: FEStoryPackage = {
6969
theme: 'NewsPillar',
7070
display: 'StandardDisplay',
7171
},
72-
webPublicationDate: '2025-03-13T11:56:49.000Z',
72+
webPublicationDate: '2022-01-01T11:56:49.000Z',
7373
headline: 'Passing probe captures images of mysterious Mars moon',
7474
shortUrl: 'https://www.theguardian.com/p/xxn2cq',
7575
discussion: {
@@ -100,7 +100,7 @@ export const storyPackage: FEStoryPackage = {
100100
theme: 'NewsPillar',
101101
display: 'StandardDisplay',
102102
},
103-
webPublicationDate: '2025-02-24T23:35:09.000Z',
103+
webPublicationDate: '2021-02-24T23:35:09.000Z',
104104
headline:
105105
'Mars once had an ocean with sandy beaches, researchers say',
106106
shortUrl: 'https://www.theguardian.com/p/xxjy3h',
@@ -132,7 +132,7 @@ export const storyPackage: FEStoryPackage = {
132132
theme: 'NewsPillar',
133133
display: 'StandardDisplay',
134134
},
135-
webPublicationDate: '2025-03-07T02:59:44.000Z',
135+
webPublicationDate: '2021-03-01T02:59:44.000Z',
136136
headline:
137137
'SpaceX’s Starship explodes in second failure for Musk’s Mars program',
138138
shortUrl: 'https://www.theguardian.com/p/xxyyzx',
@@ -163,7 +163,7 @@ export const storyPackage: FEStoryPackage = {
163163
theme: 'NewsPillar',
164164
display: 'ImmersiveDisplay',
165165
},
166-
webPublicationDate: '2025-01-11T11:00:01.000Z',
166+
webPublicationDate: '2021-01-11T11:00:01.000Z',
167167
headline:
168168
'‘I think there is life there. Today’: the race to put a human on Mars – in pictures',
169169
shortUrl: 'https://www.theguardian.com/p/xx66cn',
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
import {
2+
ArticleDesign,
3+
ArticleDisplay,
4+
Pillar,
5+
} from '../../src/lib/articleFormat';
6+
import { getDataLinkNameCard } from '../../src/lib/getDataLinkName';
7+
import { type TrailType } from '../../src/types/trails';
8+
9+
export const galleryOnwardsTrails: TrailType[] = [
10+
{
11+
url: 'https://www.theguardian.com/environment/gallery/2025/aug/22/week-in-wildlife-a-clumsy-fox-swinging-orangutang-and-rescued-jaguarundi-cub',
12+
linkText:
13+
'Week in wildlife: a clumsy fox, a swinging orangutan and a rescued jaguarundi cub',
14+
showByline: false,
15+
byline: 'Pejman Faratin',
16+
image: {
17+
src: 'https://media.guim.co.uk/a81e974ffee6c8c88fa280c2d02eaf5dc2af863e/151_292_1020_816/master/1020.jpg',
18+
altText: '',
19+
},
20+
format: {
21+
theme: Pillar.News,
22+
design: ArticleDesign.Gallery,
23+
display: ArticleDisplay.Standard,
24+
},
25+
webPublicationDate: '2022-01-01T06:00:25.000Z',
26+
headline:
27+
'Week in wildlife: a clumsy fox, a swinging orangutan and a rescued jaguarundi cub',
28+
shortUrl: 'https://www.theguardian.com/p/x32n89',
29+
discussion: {
30+
isCommentable: false,
31+
isClosedForComments: true,
32+
discussionId: '/p/x32n89',
33+
},
34+
discussionId: 'zHoBy6HNKsk',
35+
dataLinkName: getDataLinkNameCard(
36+
{
37+
theme: Pillar.News,
38+
design: ArticleDesign.Gallery,
39+
display: ArticleDisplay.Standard,
40+
},
41+
'0',
42+
0,
43+
),
44+
trailText:
45+
'Guinness World Records is looking back at the extraordinary feats achieved since its inception - as well as unveiling 70 whacky and unclaimed records ',
46+
kickerText: 'Politics', // Get data for this
47+
mainMedia: { type: 'Gallery', count: '6' },
48+
},
49+
{
50+
url: 'https://www.theguardian.com/money/gallery/2025/aug/22/characterful-cottages-for-sale-in-england-in-pictures',
51+
linkText: 'Characterful cottages for sale in England – in pictures',
52+
showByline: false,
53+
byline: 'Anna White',
54+
image: {
55+
src: 'https://media.guim.co.uk/58cd9356e6d68e8efa6028162bb959f9798307d5/515_0_5000_4000/master/5000.jpg',
56+
altText: '',
57+
},
58+
format: {
59+
design: ArticleDesign.Gallery,
60+
theme: Pillar.Lifestyle,
61+
display: ArticleDisplay.Standard,
62+
},
63+
webPublicationDate: '2022-01-01T06:00:24.000Z',
64+
headline: 'Characterful cottages for sale in England – in pictures',
65+
shortUrl: 'https://www.theguardian.com/p/x32gqj',
66+
discussion: {
67+
isCommentable: false,
68+
isClosedForComments: true,
69+
discussionId: '/p/x32gqj',
70+
},
71+
dataLinkName: getDataLinkNameCard(
72+
{
73+
design: ArticleDesign.Gallery,
74+
theme: Pillar.Lifestyle,
75+
display: ArticleDisplay.Standard,
76+
},
77+
'0',
78+
1,
79+
),
80+
trailText:
81+
'Picked from a record 60,636 entries, the first images from the Natural History Museum’s wildlife photographer of the year competition have been released. The photographs, which range from a lion facing down a cobra to magnified mould spores, show the diversity, beauty and complexity of the natural world and humanity’s relationship with it',
82+
mainMedia: { type: 'Gallery', count: '6' },
83+
},
84+
{
85+
url: 'https://www.theguardian.com/news/gallery/2025/aug/22/sunsets-aid-parachutes-and-giant-pandas-photos-of-the-day-friday',
86+
linkText:
87+
'Sunsets, aid parachutes and giant pandas: photos of the day – Friday ',
88+
showByline: false,
89+
byline: 'Eithne Staunton',
90+
image: {
91+
src: 'https://media.guim.co.uk/4ce0b080206fe9b65b976c1acf219d81072cc814/0_0_2113_1690/master/2113.png',
92+
altText: '',
93+
},
94+
format: {
95+
design: ArticleDesign.Gallery,
96+
theme: Pillar.News,
97+
display: ArticleDisplay.Standard,
98+
},
99+
webPublicationDate: '2022-01-01T08:49:42.000Z',
100+
headline:
101+
'Sunsets, aid parachutes and giant pandas: photos of the day – Friday ',
102+
shortUrl: 'https://www.theguardian.com/p/x3359z',
103+
discussion: {
104+
isCommentable: false,
105+
isClosedForComments: true,
106+
discussionId: '/p/x3359z',
107+
},
108+
dataLinkName: getDataLinkNameCard(
109+
{
110+
design: ArticleDesign.Gallery,
111+
theme: Pillar.News,
112+
display: ArticleDisplay.Standard,
113+
},
114+
'0',
115+
2,
116+
),
117+
trailText:
118+
'From the mock-Tudor fad of the 1920s to drivers refuelling on a roundabout, each era produces its own distinctive petrol stations – as photographer Philip Butler discovered',
119+
mainMedia: { type: 'Gallery', count: '6' },
120+
},
121+
{
122+
url: 'https://www.theguardian.com/fashion/gallery/2025/aug/22/what-to-wear-to-notting-hill-carnival',
123+
linkText: 'On parade: what to wear to Notting Hill carnival',
124+
showByline: false,
125+
byline: 'Melanie Wilkinson',
126+
image: {
127+
src: 'https://media.guim.co.uk/49a9656cd10c4f64f8bdd54380afb915c7a3648b/207_0_1500_1200/master/1500.jpg',
128+
altText: '',
129+
},
130+
format: {
131+
design: ArticleDesign.Gallery,
132+
theme: Pillar.Lifestyle,
133+
display: ArticleDisplay.Standard,
134+
},
135+
webPublicationDate: '2022-01-01T05:00:23.000Z',
136+
headline: 'On parade: what to wear to Notting Hill carnival',
137+
shortUrl: 'https://www.theguardian.com/p/x32mte',
138+
discussion: {
139+
isCommentable: false,
140+
isClosedForComments: true,
141+
discussionId: '/p/x32mte',
142+
},
143+
dataLinkName: getDataLinkNameCard(
144+
{
145+
design: ArticleDesign.Gallery,
146+
theme: Pillar.Lifestyle,
147+
display: ArticleDisplay.Standard,
148+
},
149+
'0',
150+
1,
151+
),
152+
trailText:
153+
'The Guardian’s picture editors select photographs from around the world',
154+
mainMedia: { type: 'Gallery', count: '6' },
155+
},
156+
{
157+
url: 'https://www.theguardian.com/artanddesign/gallery/2025/aug/21/psychedelic-rock-glass-mountain-michael-lundgren',
158+
linkText:
159+
'Psychedelic rock! Formations that mess with your mind – in pictures ',
160+
showByline: false,
161+
image: {
162+
src: 'https://media.guim.co.uk/2810af61b2d2d2d5f71ec01e56e6555e0a6d4635/55_0_2813_2250/master/2813.jpg',
163+
altText: '',
164+
},
165+
format: {
166+
design: ArticleDesign.Gallery,
167+
theme: Pillar.Culture,
168+
display: ArticleDisplay.Standard,
169+
},
170+
webPublicationDate: '2025-08-21T06:01:01.000Z',
171+
headline:
172+
'Psychedelic rock! Formations that mess with your mind – in pictures ',
173+
shortUrl: 'https://www.theguardian.com/p/x2p663',
174+
discussion: {
175+
isCommentable: false,
176+
isClosedForComments: true,
177+
discussionId: '/p/x2p663',
178+
},
179+
dataLinkName: getDataLinkNameCard(
180+
{
181+
design: ArticleDesign.Gallery,
182+
theme: Pillar.Culture,
183+
display: ArticleDisplay.Standard,
184+
},
185+
'0',
186+
1,
187+
),
188+
trailText:
189+
'Politicians and their partners put on their best show at this year’s Midwinter Ball, an annual dinner hosted by the Federal Parliamentary Press Gallery in Canberra',
190+
mainMedia: { type: 'Gallery', count: '6' },
191+
},
192+
];

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

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ export type Position = 'inner' | 'outer' | 'none';
8080
export type Props = {
8181
linkTo: string;
8282
format: ArticleFormat;
83+
/** The format of the article holding the card */
84+
contextFormat?: ArticleFormat;
8385
serverTime?: number;
8486
headlineText: string;
8587
headlineSizes?: ResponsiveFontSize;
@@ -365,6 +367,7 @@ const liveBulletStyles = css`
365367
export const Card = ({
366368
linkTo,
367369
format,
370+
contextFormat,
368371
headlineText,
369372
headlineSizes,
370373
showQuotedHeadline,
@@ -561,13 +564,25 @@ export const Card = ({
561564
);
562565
}
563566

567+
// Determine if the card is used within a gallery article
568+
const isInGalleryContext = contextFormat?.design === ArticleDesign.Gallery;
569+
570+
// This is due to a re-design for onwards content.
571+
// Currently this re-design is only applied for galleries secondary onwards content.
572+
// We plan to apply this to all onwards content in the future.
573+
const isGallerySecondaryOnward =
574+
isInGalleryContext && onwardsSource !== 'more-galleries';
575+
576+
const isMoreGalleriesOnwardContent =
577+
isOnwardContent && onwardsSource === 'more-galleries';
578+
564579
/**
565580
- * Media cards have contrasting background colours. We add additional
566581
* padding to these cards to keep the text readable.
567582
- */
568583
const isMediaCardOrNewsletter = isMediaCard(format) || isNewsletter;
569584

570-
const showPill = isMediaCardOrNewsletter;
585+
const showPill = isMediaCardOrNewsletter && !isGallerySecondaryOnward;
571586

572587
const media = getMedia({
573588
imageUrl: image?.src,
@@ -607,9 +622,15 @@ export const Card = ({
607622
isBetaContainer,
608623
);
609624

610-
const backgroundColour = isMediaCardOrNewsletter
611-
? palette('--card-media-background')
612-
: palette('--card-background');
625+
const backgroundColour = () => {
626+
if (isGallerySecondaryOnward) {
627+
return palette('--onward-background');
628+
}
629+
if (isMediaCardOrNewsletter) {
630+
return palette('--card-media-background');
631+
}
632+
return palette('--card-background');
633+
};
613634

614635
/* Whilst we migrate to the new container types, we need to check which container we are in. */
615636
const isFlexibleContainer =
@@ -636,8 +657,6 @@ export const Card = ({
636657
return 'tablet';
637658
};
638659

639-
const isMoreGalleriesOnwardContent =
640-
isOnwardContent && onwardsSource === 'more-galleries';
641660
const shouldShowTrailText = isMoreGalleriesOnwardContent
642661
? media?.type !== 'podcast' && isOnwardSplash
643662
: media?.type !== 'podcast';
@@ -647,7 +666,7 @@ export const Card = ({
647666
* Order matters here as the logic is based on the card properties
648667
*/
649668
const getGapSizes = (): GapSizes => {
650-
if (isOnwardContent) {
669+
if (isOnwardContent && !isGallerySecondaryOnward) {
651670
return {
652671
row: 'none',
653672
column: 'none',
@@ -760,6 +779,7 @@ export const Card = ({
760779
betaContainer: boolean,
761780
onwardContent: boolean,
762781
): 'large' | 'small' | undefined => {
782+
if (isInGalleryContext) return undefined;
763783
if (mediaCard && betaContainer) return 'large';
764784
if (mediaCard || onwardContent) return 'small';
765785
return undefined;
@@ -847,6 +867,11 @@ export const Card = ({
847867
showTopBarDesktop={showTopBarDesktop}
848868
showTopBarMobile={showTopBarMobile}
849869
containerPalette={containerPalette}
870+
topBarColour={
871+
isGallerySecondaryOnward
872+
? palette('--onward-content-top-border')
873+
: undefined
874+
}
850875
>
851876
<CardLink
852877
linkTo={linkTo}
@@ -859,7 +884,7 @@ export const Card = ({
859884
css={css`
860885
padding-bottom: ${space[5]}px;
861886
`}
862-
style={{ backgroundColor: backgroundColour }}
887+
style={{ backgroundColor: backgroundColour() }}
863888
>
864889
<CardHeadline
865890
headlineText={headlineText}
@@ -891,7 +916,7 @@ export const Card = ({
891916
)}
892917

893918
<CardLayout
894-
cardBackgroundColour={backgroundColour}
919+
cardBackgroundColour={backgroundColour()}
895920
mediaPositionOnDesktop={mediaPositionOnDesktop}
896921
mediaPositionOnMobile={mediaPositionOnMobile}
897922
minWidthInPixels={minWidthInPixels}
@@ -919,7 +944,11 @@ export const Card = ({
919944
mediaType={media.type}
920945
mediaPositionOnDesktop={mediaPositionOnDesktop}
921946
mediaPositionOnMobile={mediaPositionOnMobile}
922-
padMedia={isMediaCardOrNewsletter && isBetaContainer}
947+
padMedia={
948+
isMediaCardOrNewsletter &&
949+
isBetaContainer &&
950+
!isGallerySecondaryOnward
951+
}
923952
isBetaContainer={isBetaContainer}
924953
isSmallCard={isSmallCard}
925954
>
@@ -1161,7 +1190,7 @@ export const Card = ({
11611190
padContent={determinePadContent(
11621191
isMediaCardOrNewsletter,
11631192
isBetaContainer,
1164-
isOnwardContent && !isMoreGalleriesOnwardContent,
1193+
isOnwardContent,
11651194
)}
11661195
>
11671196
{/* This div is needed to keep the headline and trail text justified at the start */}
@@ -1300,12 +1329,15 @@ export const Card = ({
13001329
css`
13011330
${from.tablet} {
13021331
flex-basis: 100%;
1303-
background-color: ${backgroundColour};
1332+
background-color: ${backgroundColour()};
13041333
}
13051334
`
13061335
}
13071336
style={{
1308-
padding: isOnwardContent ? `0 ${space[2]}px` : 0,
1337+
padding:
1338+
isOnwardContent && !isInGalleryContext
1339+
? `0 ${space[2]}px`
1340+
: 0,
13091341
}}
13101342
>
13111343
{showLivePlayable && liveUpdatesPosition === 'outer' && (

0 commit comments

Comments
 (0)