Skip to content

Commit 225c9c2

Browse files
Only add Match nav scoreboard placeholders for articles (#13837)
1 parent 3e72807 commit 225c9c2

File tree

4 files changed

+42
-15
lines changed

4 files changed

+42
-15
lines changed

dotcom-rendering/src/components/FootballMatchSummary.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const FootballMatchSummary = ({ match }: Props) => (
5454
homeTeam={match.homeTeam}
5555
awayTeam={match.awayTeam}
5656
comments={match.comments}
57+
usage="MatchSummary"
5758
/>
5859
</div>
5960
<div

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const GetMatchNav = ({
141141
homeTeam={data.homeTeam}
142142
awayTeam={data.awayTeam}
143143
comments={data.comments}
144+
usage="Article"
144145
/>
145146
);
146147
}

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,26 @@ export const Default = () => {
5454
homeTeam={homeTeam}
5555
awayTeam={awayTeam}
5656
comments="Here is a comments string"
57+
usage="Article"
5758
/>
5859
);
5960
};
6061
Default.storyName = 'default';
6162

62-
export const ZeroZero = () => {
63+
export const NilNil = () => {
6364
return (
6465
<MatchNav
6566
homeTeam={{ ...homeTeam, score: 0, scorers: [] }}
6667
awayTeam={{ ...awayTeam, score: 0, scorers: [] }}
6768
comments="Neither team scored any goals"
69+
usage="Article"
6870
/>
6971
);
7072
};
71-
ZeroZero.storyName = 'zero - zero';
73+
NilNil.storyName = 'nil - nil';
7274

7375
export const NoComments = () => {
74-
return <MatchNav homeTeam={homeTeam} awayTeam={awayTeam} />;
76+
return <MatchNav homeTeam={homeTeam} awayTeam={awayTeam} usage="Article" />;
7577
};
7678
NoComments.storyName = 'with no comments';
7779

@@ -93,6 +95,7 @@ export const InContext = () => {
9395
homeTeam={homeTeam}
9496
awayTeam={awayTeam}
9597
comments="Here is a comments string"
98+
usage="Article"
9699
/>
97100
</ArticleContainer>
98101
<RightColumn>
@@ -109,7 +112,19 @@ export const NoScore = () => {
109112
<MatchNav
110113
homeTeam={{ ...homeTeam, score: undefined, scorers: [] }}
111114
awayTeam={{ ...awayTeam, score: undefined, scorers: [] }}
115+
usage="Article"
112116
/>
113117
);
114118
};
115119
NoScore.storyName = 'with no scores';
120+
121+
export const NilNilInMatchSummary = () => {
122+
return (
123+
<MatchNav
124+
homeTeam={{ ...homeTeam, score: 0, scorers: [] }}
125+
awayTeam={{ ...awayTeam, score: 0, scorers: [] }}
126+
usage="MatchSummary"
127+
/>
128+
);
129+
};
130+
NilNilInMatchSummary.storyName = 'nil - nil in match summary';

dotcom-rendering/src/components/MatchNav.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Props = {
1717
homeTeam: Team;
1818
awayTeam: Team;
1919
comments?: string;
20+
usage: 'MatchSummary' | 'Article';
2021
};
2122

2223
const Row = ({ children }: { children: React.ReactNode }) => (
@@ -155,15 +156,7 @@ const TeamNav = ({
155156
`}
156157
>
157158
<TeamName name={name} />
158-
<Scorers
159-
scorers={[
160-
...scorers,
161-
// this ensures we reserve space for at least three scorers per team
162-
'placeholder-1',
163-
'placeholder-2',
164-
'placeholder-3',
165-
].slice(0, Math.max(3, scorers.length))}
166-
/>
159+
<Scorers scorers={scorers} />
167160
</div>
168161
<CrestRow>
169162
<Crest crest={crest} />
@@ -207,7 +200,16 @@ const YellowBorder = () => (
207200
/>
208201
);
209202

210-
export const MatchNav = ({ homeTeam, awayTeam, comments }: Props) => (
203+
const addScorerPlaceholders = (scorers: string[]): string[] =>
204+
[
205+
...scorers,
206+
// this ensures we reserve space for at least three scorers per team
207+
'placeholder-1',
208+
'placeholder-2',
209+
'placeholder-3',
210+
].slice(0, Math.max(3, scorers.length));
211+
212+
export const MatchNav = ({ homeTeam, awayTeam, comments, usage }: Props) => (
211213
<div
212214
css={css`
213215
display: flex;
@@ -227,14 +229,22 @@ export const MatchNav = ({ homeTeam, awayTeam, comments }: Props) => (
227229
name={homeTeam.name}
228230
score={homeTeam.score}
229231
crest={homeTeam.crest}
230-
scorers={homeTeam.scorers}
232+
scorers={
233+
usage === 'Article'
234+
? addScorerPlaceholders(homeTeam.scorers)
235+
: homeTeam.scorers
236+
}
231237
/>
232238
<YellowBorder />
233239
<TeamNav
234240
name={awayTeam.name}
235241
score={awayTeam.score}
236242
crest={awayTeam.crest}
237-
scorers={awayTeam.scorers}
243+
scorers={
244+
usage === 'Article'
245+
? addScorerPlaceholders(awayTeam.scorers)
246+
: awayTeam.scorers
247+
}
238248
/>
239249
</Row>
240250
{!!comments && <Comments comments={comments} />}

0 commit comments

Comments
 (0)