Skip to content

Commit 3a49f90

Browse files
committed
Add new onward container with new design
1 parent 2bf21d0 commit 3a49f90

File tree

10 files changed

+580
-42
lines changed

10 files changed

+580
-42
lines changed
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-08-22T05: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: 61 additions & 12 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;
@@ -364,6 +366,7 @@ const liveBulletStyles = css`
364366
export const Card = ({
365367
linkTo,
366368
format,
369+
contextFormat,
367370
headlineText,
368371
headlineSizes,
369372
showQuotedHeadline,
@@ -474,6 +477,11 @@ export const Card = ({
474477
showClock={showClock}
475478
serverTime={serverTime}
476479
isTagPage={isTagPage}
480+
colour={
481+
isGallerySecondaryOnward
482+
? palette('--onward-card-footer-text')
483+
: undefined
484+
}
477485
/>
478486
);
479487
};
@@ -504,6 +512,11 @@ export const Card = ({
504512
<CardCommentCount
505513
discussionApiUrl={discussionApiUrl}
506514
discussionId={discussionId}
515+
colour={
516+
isGallerySecondaryOnward
517+
? palette('--onward-card-footer-text')
518+
: undefined
519+
}
507520
/>
508521
</Island>
509522
</Link>
@@ -559,13 +572,24 @@ export const Card = ({
559572
);
560573
}
561574

575+
const isInGalleryContext = contextFormat?.design === ArticleDesign.Gallery;
576+
577+
// This is due to a re-design for onwards content.
578+
// Currently this re-design is only applied for galleries secondary onwards content.
579+
// We plan to apply this to all onwards content in the future.
580+
const isGallerySecondaryOnward =
581+
isInGalleryContext && onwardsSource !== 'more-galleries';
582+
583+
const isMoreGalleriesOnwardContent =
584+
isOnwardContent && onwardsSource === 'more-galleries';
585+
562586
/**
563587
- * Media cards have contrasting background colours. We add additional
564588
* padding to these cards to keep the text readable.
565589
- */
566590
const isMediaCardOrNewsletter = isMediaCard(format) || isNewsletter;
567591

568-
const showPill = isMediaCardOrNewsletter;
592+
const showPill = isMediaCardOrNewsletter && !isGallerySecondaryOnward;
569593

570594
const media = getMedia({
571595
imageUrl: image?.src,
@@ -605,9 +629,15 @@ export const Card = ({
605629
isBetaContainer,
606630
);
607631

608-
const backgroundColour = isMediaCardOrNewsletter
609-
? palette('--card-media-background')
610-
: palette('--card-background');
632+
const backgroundColour = () => {
633+
if (isGallerySecondaryOnward) {
634+
return palette('--onward-card-background');
635+
}
636+
if (isMediaCardOrNewsletter) {
637+
return palette('--card-media-background');
638+
}
639+
return palette('--card-background');
640+
};
611641

612642
/* Whilst we migrate to the new container types, we need to check which container we are in. */
613643
const isFlexibleContainer =
@@ -634,8 +664,6 @@ export const Card = ({
634664
return 'tablet';
635665
};
636666

637-
const isMoreGalleriesOnwardContent =
638-
isOnwardContent && onwardsSource === 'more-galleries';
639667
const shouldShowTrailText = isMoreGalleriesOnwardContent
640668
? media?.type !== 'podcast' && isOnwardSplash
641669
: media?.type !== 'podcast';
@@ -645,7 +673,7 @@ export const Card = ({
645673
* Order matters here as the logic is based on the card properties
646674
*/
647675
const getGapSizes = (): GapSizes => {
648-
if (isOnwardContent) {
676+
if (isOnwardContent && !isGallerySecondaryOnward) {
649677
return {
650678
row: 'none',
651679
column: 'none',
@@ -758,6 +786,7 @@ export const Card = ({
758786
betaContainer: boolean,
759787
onwardContent: boolean,
760788
): 'large' | 'small' | undefined => {
789+
if (isInGalleryContext) return undefined;
761790
if (mediaCard && betaContainer) return 'large';
762791
if (mediaCard || onwardContent) return 'small';
763792
return undefined;
@@ -845,6 +874,11 @@ export const Card = ({
845874
showTopBarDesktop={showTopBarDesktop}
846875
showTopBarMobile={showTopBarMobile}
847876
containerPalette={containerPalette}
877+
colour={
878+
isGallerySecondaryOnward
879+
? palette('--onward-content-border')
880+
: undefined
881+
}
848882
>
849883
<CardLink
850884
linkTo={linkTo}
@@ -857,7 +891,7 @@ export const Card = ({
857891
css={css`
858892
padding-bottom: ${space[5]}px;
859893
`}
860-
style={{ backgroundColor: backgroundColour }}
894+
style={{ backgroundColor: backgroundColour() }}
861895
>
862896
<CardHeadline
863897
headlineText={headlineText}
@@ -878,6 +912,11 @@ export const Card = ({
878912
showByline={showByline}
879913
isExternalLink={isExternalLink}
880914
showLabsRedesign={showLabsRedesign}
915+
headlineColour={
916+
isGallerySecondaryOnward
917+
? palette('--onward-caption-text')
918+
: undefined
919+
}
881920
/>
882921
{!isUndefined(starRating) ? (
883922
<StarRatingComponent
@@ -889,7 +928,7 @@ export const Card = ({
889928
)}
890929

891930
<CardLayout
892-
cardBackgroundColour={backgroundColour}
931+
cardBackgroundColour={backgroundColour()}
893932
mediaPositionOnDesktop={mediaPositionOnDesktop}
894933
mediaPositionOnMobile={mediaPositionOnMobile}
895934
minWidthInPixels={minWidthInPixels}
@@ -917,7 +956,12 @@ export const Card = ({
917956
mediaType={media.type}
918957
mediaPositionOnDesktop={mediaPositionOnDesktop}
919958
mediaPositionOnMobile={mediaPositionOnMobile}
920-
padMedia={isMediaCardOrNewsletter && isBetaContainer}
959+
hideMediaOverlay={media.type === 'slideshow'}
960+
padMedia={
961+
isMediaCardOrNewsletter &&
962+
isBetaContainer &&
963+
!isGallerySecondaryOnward
964+
}
921965
isBetaContainer={isBetaContainer}
922966
isSmallCard={isSmallCard}
923967
>
@@ -1158,7 +1202,7 @@ export const Card = ({
11581202
padContent={determinePadContent(
11591203
isMediaCardOrNewsletter,
11601204
isBetaContainer,
1161-
isOnwardContent && !isMoreGalleriesOnwardContent,
1205+
isOnwardContent,
11621206
)}
11631207
>
11641208
{/* This div is needed to keep the headline and trail text justified at the start */}
@@ -1200,6 +1244,11 @@ export const Card = ({
12001244
: undefined
12011245
}
12021246
showLabsRedesign={showLabsRedesign}
1247+
headlineColour={
1248+
isGallerySecondaryOnward
1249+
? palette('--onward-caption-text')
1250+
: undefined
1251+
}
12031252
/>
12041253
{!isUndefined(starRating) ? (
12051254
<StarRatingComponent
@@ -1297,7 +1346,7 @@ export const Card = ({
12971346
css`
12981347
${from.tablet} {
12991348
flex-basis: 100%;
1300-
background-color: ${backgroundColour};
1349+
background-color: ${backgroundColour()};
13011350
}
13021351
`
13031352
}

0 commit comments

Comments
 (0)