Skip to content

Commit 660fd8d

Browse files
authored
Link match header league name to tag page (#15602)
* Allow league name to be a link * Allow league name and URL to be passed to header * Move league name and URL to vars
1 parent 0c8802d commit 660fd8d

File tree

7 files changed

+54
-11
lines changed

7 files changed

+54
-11
lines changed

dotcom-rendering/src/components/FootballMatchHeader/FootballMatchHeader.stories.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export const Fixture = meta.story({
3636
args: {
3737
initialTab: 'info',
3838
initialData: {
39-
leagueName: feHeaderData.competitionName,
4039
match: {
4140
kind: 'Fixture',
4241
kickOff: new Date('2025-11-05T20:30:00Z'),
@@ -56,6 +55,7 @@ export const Fixture = meta.story({
5655
matchKind: 'Fixture',
5756
},
5857
},
58+
leagueName: 'Premier League',
5959
edition: 'UK',
6060
getHeaderData: () =>
6161
getMockData({
@@ -102,6 +102,8 @@ export const Fixture = meta.story({
102102
export const Live = meta.story({
103103
args: {
104104
initialTab: 'live',
105+
leagueName: 'Premier League',
106+
leagueURL: 'https://www.theguardian.com/football/premierleague',
105107
edition: 'EUR',
106108
matchHeaderURL:
107109
'https://api.nextgen.guardianapps.co.uk/football/api/match-header/2026/02/08/26247/48490.json',
@@ -147,6 +149,8 @@ export const Live = meta.story({
147149
export const Result = meta.story({
148150
args: {
149151
initialTab: 'report',
152+
leagueName: 'Premier League',
153+
leagueURL: 'https://www.theguardian.com/football/premierleague',
150154
edition: 'AU',
151155
matchHeaderURL:
152156
'https://api.nextgen.guardianapps.co.uk/football/api/match-header/2026/02/08/26247/48490.json',
@@ -190,6 +194,8 @@ export const Result = meta.story({
190194
export const AppsResult = meta.story({
191195
args: {
192196
initialTab: 'report',
197+
leagueName: 'Premier League',
198+
leagueURL: 'https://www.theguardian.com/football/premierleague',
193199
edition: 'AU',
194200
matchHeaderURL:
195201
'https://api.nextgen.guardianapps.co.uk/football/api/match-header/2026/02/08/26247/48490.json',

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
textSansItalic15Object,
1414
until,
1515
} from '@guardian/source/foundations';
16-
import { type ComponentProps, type ReactNode, useMemo } from 'react';
16+
import { type ComponentProps, useMemo } from 'react';
1717
import type { SWRConfiguration } from 'swr';
1818
import useSWR from 'swr';
1919
import type { FootballMatch } from '../../footballMatchV2';
@@ -39,6 +39,8 @@ import { Tabs } from './Tabs';
3939
export type FootballMatchHeaderProps = {
4040
initialTab: ComponentProps<typeof Tabs>['selected'];
4141
initialData?: HeaderData;
42+
leagueName: string;
43+
leagueURL?: string;
4244
edition: EditionId;
4345
matchHeaderURL: string;
4446
renderingTarget: RenderingTarget;
@@ -60,7 +62,6 @@ export const FootballMatchHeader = (props: Props) => {
6062

6163
const match = data?.match ?? props.initialData?.match;
6264
const tabs = data?.tabs ?? props.initialData?.tabs;
63-
const leagueName = data?.leagueName ?? props.initialData?.leagueName;
6465

6566
if (error) {
6667
if (
@@ -79,7 +80,7 @@ export const FootballMatchHeader = (props: Props) => {
7980
return null;
8081
}
8182

82-
if (match === undefined || tabs === undefined || leagueName === undefined) {
83+
if (match === undefined || tabs === undefined) {
8384
return (
8485
<Placeholder
8586
heights={
@@ -113,7 +114,8 @@ export const FootballMatchHeader = (props: Props) => {
113114
}}
114115
>
115116
<StatusLine
116-
leagueName={leagueName}
117+
leagueName={props.leagueName}
118+
leagueURL={props.leagueURL}
117119
match={match}
118120
edition={props.edition}
119121
/>
@@ -161,6 +163,7 @@ const fetcher =
161163

162164
const StatusLine = (props: {
163165
leagueName: string;
166+
leagueURL?: string;
164167
match: FootballMatch;
165168
edition: EditionId;
166169
}) => (
@@ -179,15 +182,20 @@ const StatusLine = (props: {
179182
color: palette(secondaryText(props.match.kind)),
180183
}}
181184
>
182-
<LeagueName matchKind={props.match.kind}>{props.leagueName}</LeagueName>
185+
<LeagueName
186+
matchKind={props.match.kind}
187+
name={props.leagueName}
188+
url={props.leagueURL}
189+
/>
183190
{props.match.venue ? `${props.match.venue} • ` : null}
184191
<MatchStatus edition={props.edition} match={props.match} />
185192
</p>
186193
);
187194

188195
const LeagueName = (props: {
189196
matchKind: FootballMatch['kind'];
190-
children: ReactNode;
197+
name: string;
198+
url?: string;
191199
}) => (
192200
<>
193201
<span
@@ -220,7 +228,20 @@ const LeagueName = (props: {
220228
},
221229
}}
222230
>
223-
{props.children}
231+
{props.url ? (
232+
<a
233+
href={props.url}
234+
css={{
235+
color: 'inherit',
236+
textDecoration: 'none',
237+
'&:hover': { textDecoration: 'underline' },
238+
}}
239+
>
240+
{props.name}
241+
</a>
242+
) : (
243+
props.name
244+
)}
224245
</span>
225246
<span
226247
css={{

dotcom-rendering/src/components/FootballMatchHeader/headerData.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import type { Tabs } from './Tabs';
1616
export type HeaderData = {
1717
tabs: ComponentProps<typeof Tabs>;
1818
match: FootballMatch;
19-
leagueName: string;
2019
};
2120

2221
export const parse =
@@ -55,7 +54,6 @@ export const parse =
5554
return ok({
5655
match: parsedMatch.value,
5756
tabs: maybeTabs.value,
58-
leagueName: feData.value.competitionName,
5957
});
6058
};
6159

dotcom-rendering/src/components/FootballMatchHeaderWrapper.island.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ export const FootballMatchHeaderWrapper = (props: Props) => (
1616
<FootballMatchHeader
1717
initialTab={props.initialTab}
1818
initialData={props.initialData}
19+
leagueName={props.leagueName}
20+
leagueURL={props.leagueURL}
1921
edition={props.edition}
2022
matchHeaderURL={props.matchHeaderURL}
2123
article={props.article}

dotcom-rendering/src/components/FootballMatchInfoPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ export const FootballMatchInfoPage = ({
3434
<FootballMatchHeaderWrapper
3535
initialTab="info"
3636
initialData={{
37-
leagueName: competitionName,
3837
match: matchInfo,
3938
tabs: {
4039
selected: 'info',
@@ -44,6 +43,7 @@ export const FootballMatchInfoPage = ({
4443
liveURL: undefined,
4544
},
4645
}}
46+
leagueName={competitionName}
4747
edition={edition}
4848
matchHeaderURL={matchHeaderUrl.href}
4949
renderingTarget={renderingTarget}

dotcom-rendering/src/layouts/LiveLayout.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
295295
? article.matchStatsUrl
296296
: undefined;
297297

298+
const footballMatchLeagueName = article.sectionLabel;
299+
const footballMatchLeagueUrl = `${article.guardianBaseURL}/${article.sectionUrl}`;
300+
298301
const cricketMatchUrl =
299302
article.matchType === 'CricketMatchType' ? article.matchUrl : undefined;
300303

@@ -385,6 +388,8 @@ export const LiveLayout = (props: WebProps | AppsProps) => {
385388
>
386389
<FootballMatchHeaderWrapper
387390
initialTab="live"
391+
leagueName={footballMatchLeagueName}
392+
leagueURL={footballMatchLeagueUrl}
388393
edition={article.editionId}
389394
matchHeaderURL={footballMatchHeaderUrl}
390395
renderingTarget={renderingTarget}

dotcom-rendering/src/layouts/StandardLayout.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,9 @@ export const StandardLayout = (props: WebProps | AppProps) => {
363363
? article.matchHeaderUrl
364364
: undefined;
365365

366+
const footballMatchLeagueName = article.sectionLabel;
367+
const footballMatchLeagueUrl = `${article.guardianBaseURL}/${article.sectionUrl}`;
368+
366369
const isMatchReport =
367370
format.design === ArticleDesign.MatchReport && !!footballMatchUrl;
368371

@@ -433,6 +436,8 @@ export const StandardLayout = (props: WebProps | AppProps) => {
433436
<MatchHeaderContainer
434437
isMatchReport={isMatchReport}
435438
footballMatchHeaderUrl={footballMatchHeaderUrl}
439+
leagueName={footballMatchLeagueName}
440+
leagueUrl={footballMatchLeagueUrl}
436441
editionId={editionId}
437442
renderingTarget={renderingTarget}
438443
/>
@@ -1052,11 +1057,15 @@ export const StandardLayout = (props: WebProps | AppProps) => {
10521057
const MatchHeaderContainer = ({
10531058
isMatchReport,
10541059
footballMatchHeaderUrl,
1060+
leagueName,
1061+
leagueUrl,
10551062
editionId,
10561063
renderingTarget,
10571064
}: {
10581065
isMatchReport: boolean;
10591066
footballMatchHeaderUrl: string | undefined;
1067+
leagueName: string;
1068+
leagueUrl: string;
10601069
editionId: EditionId;
10611070
renderingTarget: RenderingTarget;
10621071
}) => {
@@ -1076,6 +1085,8 @@ const MatchHeaderContainer = ({
10761085
<Island priority="feature" defer={{ until: 'visible' }}>
10771086
<FootballMatchHeaderWrapper
10781087
initialTab="report"
1088+
leagueName={leagueName}
1089+
leagueURL={leagueUrl}
10791090
edition={editionId}
10801091
matchHeaderURL={footballMatchHeaderUrl}
10811092
renderingTarget={renderingTarget}

0 commit comments

Comments
 (0)