Skip to content

Commit db59932

Browse files
Add Football Match summary layout (#13810)
* Add FE type and match summary parser - check has team stats in component * add page type and schema * Add layout and expand sportDataPage type - remove competition from match stats props * Add handler function
1 parent bc491db commit db59932

15 files changed

+125
-48
lines changed

dotcom-rendering/src/components/FootballCompetitionSelect.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { Option, Select } from '@guardian/source/react-components';
22
import { palette } from '../palette';
3-
import type { FootballPageKind, Region } from '../sportDataPage';
3+
import type { FootballPageWithRegionsKind, Region } from '../sportDataPage';
44

55
type Props = {
66
regions: Region[];
7-
kind: FootballPageKind;
7+
kind: FootballPageWithRegionsKind;
88
pageId: string;
99
onChange: (competitionTag: string) => void;
1010
};
1111

12-
const allLabel = (kind: FootballPageKind): string => {
12+
const allLabel = (kind: FootballPageWithRegionsKind): string => {
1313
switch (kind) {
1414
case 'FootballFixtures':
1515
return 'All fixtures';
@@ -22,7 +22,7 @@ const allLabel = (kind: FootballPageKind): string => {
2222
}
2323
};
2424

25-
const getPagePath = (kind: FootballPageKind) => {
25+
const getPagePath = (kind: FootballPageWithRegionsKind) => {
2626
switch (kind) {
2727
case 'FootballFixtures':
2828
return '/football/fixtures';

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ type Story = StoryObj<typeof meta>;
2020

2121
export const FootballMatchSummary = {
2222
args: {
23-
homeTeam: matchReport.homeTeam,
24-
awayTeam: matchReport.awayTeam,
25-
competition: matchReport.competition.fullName,
26-
comments: matchReport.comments,
23+
match: {
24+
homeTeam: matchReport.homeTeam,
25+
awayTeam: matchReport.awayTeam,
26+
comments: matchReport.comments,
27+
},
2728
},
2829
} satisfies Story;

dotcom-rendering/src/components/FootballMatchSummary.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { css } from '@emotion/react';
22
import { from } from '@guardian/source/foundations';
3-
import type { FootballTeam } from '../footballMatch';
3+
import type { FootballMatch } from '../footballMatch';
44
import { grid } from '../grid';
55
import { palette } from '../palette';
66
import { MatchNav } from './MatchNav';
@@ -27,18 +27,10 @@ const gridStyles = css`
2727
`;
2828

2929
type Props = {
30-
homeTeam: FootballTeam;
31-
awayTeam: FootballTeam;
32-
comments?: string;
33-
competition: string;
30+
match: FootballMatch;
3431
};
3532

36-
export const FootballMatchSummary = ({
37-
homeTeam,
38-
awayTeam,
39-
comments,
40-
competition,
41-
}: Props) => (
33+
export const FootballMatchSummary = ({ match }: Props) => (
4234
<main id="maincontent" css={gridStyles}>
4335
<div
4436
css={css`
@@ -59,9 +51,9 @@ export const FootballMatchSummary = ({
5951
`}
6052
>
6153
<MatchNav
62-
homeTeam={homeTeam}
63-
awayTeam={awayTeam}
64-
comments={comments}
54+
homeTeam={match.homeTeam}
55+
awayTeam={match.awayTeam}
56+
comments={match.comments}
6557
/>
6658
</div>
6759
<div
@@ -70,9 +62,8 @@ export const FootballMatchSummary = ({
7062
`}
7163
>
7264
<MatchStats
73-
home={homeTeam}
74-
away={awayTeam}
75-
competition={competition}
65+
home={match.homeTeam}
66+
away={match.awayTeam}
7667
usage="MatchSummary"
7768
/>
7869
</div>

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ export const GetMatchStats = ({ matchUrl, format }: Props) => {
9999
<MatchStats
100100
home={cleanTeamData(data.homeTeam)}
101101
away={cleanTeamData(data.awayTeam)}
102-
competition={data.competition.fullName}
103102
format={format}
104103
usage="Article"
105104
/>

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const Default = () => {
1717
<MatchStats
1818
home={matchReport.homeTeam}
1919
away={matchReport.awayTeam}
20-
competition="FA Cup"
2120
format={{
2221
display: ArticleDisplay.Standard,
2322
design: ArticleDesign.Standard,
@@ -46,7 +45,6 @@ export const InContext = () => {
4645
<MatchStats
4746
home={matchReport.homeTeam}
4847
away={matchReport.awayTeam}
49-
competition="FA Cup"
5048
format={{
5149
display: ArticleDisplay.Standard,
5250
design: ArticleDesign.Standard,
@@ -69,7 +67,6 @@ const DefaultInLiveblog = () => {
6967
<MatchStats
7068
home={matchReport.homeTeam}
7169
away={matchReport.awayTeam}
72-
competition="FA Cup"
7370
format={{
7471
display: ArticleDisplay.Standard,
7572
design: ArticleDesign.DeadBlog,
@@ -98,7 +95,6 @@ export const NoStats = () => {
9895
corners: 0,
9996
fouls: 0,
10097
}}
101-
competition="Women's Nations League"
10298
format={{
10399
display: ArticleDisplay.Standard,
104100
design: ArticleDesign.Standard,

dotcom-rendering/src/components/MatchStats.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { Lineup } from './Lineup';
2222
type MatchStatsData = {
2323
home: TeamType;
2424
away: TeamType;
25-
competition: string;
2625
};
2726

2827
type MatchSummaryProps = MatchStatsData & {

dotcom-rendering/src/footballMatch.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export type FootballTeam = {
2929
corners: number;
3030
fouls: number;
3131
colours: string;
32+
// ToDo: this needs to be optional
3233
score: number;
3334
crest: string;
3435
scorers: string[];
@@ -48,7 +49,7 @@ export type FootballPlayer = {
4849
export type FootballMatch = {
4950
homeTeam: FootballTeam;
5051
awayTeam: FootballTeam;
51-
comment: string;
52+
comments: string;
5253
};
5354

5455
type UnknownEventType = {
@@ -142,6 +143,6 @@ export const parse = (
142143
return ok({
143144
homeTeam: parsedHomeTeam.value,
144145
awayTeam: parsedAwayTeam.value,
145-
comment: feFootballMatch.comment,
146+
comments: feFootballMatch.comments,
146147
});
147148
};

dotcom-rendering/src/frontend/feFootballMatchPage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export type FEFootballMatch = {
3636
id: string;
3737
homeTeam: FEFootballTeam;
3838
awayTeam: FEFootballTeam;
39-
comment: string;
39+
comments: string;
4040
};
4141

4242
export type FEFootballMatchPage = FEFootballDataPage & {

dotcom-rendering/src/frontend/schemas/feFootballMatchPage.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,13 @@
283283
"shotsOn"
284284
]
285285
},
286-
"comment": {
286+
"comments": {
287287
"type": "string"
288288
}
289289
},
290290
"required": [
291291
"awayTeam",
292-
"comment",
292+
"comments",
293293
"homeTeam",
294294
"id"
295295
]

dotcom-rendering/src/layouts/SportDataPageLayout.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { palette } from '@guardian/source/foundations';
22
import { CricketScorecardPage } from '../components/CricketScorecardPage';
33
import { FootballMatchesPageWrapper } from '../components/FootballMatchesPageWrapper.importable';
4+
import { FootballMatchSummary } from '../components/FootballMatchSummary';
45
import { FootballTablesPage } from '../components/FootballTablesPage';
56
import { Footer } from '../components/Footer';
67
import { HeaderAdSlot } from '../components/HeaderAdSlot';
@@ -63,6 +64,8 @@ const SportsPage = ({
6364
guardianBaseUrl={sportData.guardianBaseURL}
6465
/>
6566
);
67+
case 'FootballMatchSummary':
68+
return <FootballMatchSummary match={sportData.match} />;
6669
}
6770
};
6871

0 commit comments

Comments
 (0)