Skip to content

Commit

Permalink
Clean up line breaks on multi winner results
Browse files Browse the repository at this point in the history
  • Loading branch information
ArendPeter committed Dec 16, 2024
1 parent c8616aa commit b76a7e7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 7 additions & 2 deletions packages/frontend/src/components/Election/Results/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,19 @@ export default function Results({ race, results }: {race: Race, results: Electio
}[results.votingMethod]
});

const winnersText = commaListFormatter
.format(results.elected.map(c => c.name.replace(' ', '__REPLACE_ME__')))
.split('__REPLACE_ME__')
.map(s => ([s, <>&nbsp;</>]))

return (
<RaceContextProvider race={race} results={results} t={t}>
<hr/>
<Typography variant="h3" component="h3" sx={{marginBottom: 2}}>
{race.title}
</Typography>
<div className="flexContainer" style={{textAlign: 'center'}}>
<Box sx={{pageBreakAfter:'avoid', pageBreakInside:'avoid'}}>
<Box sx={{pageBreakAfter:'avoid', pageBreakInside:'avoid', mx: 10}}>
{results.summaryData.nValidVotes == 0 && <h2>{t('results.waiting_for_results')}</h2>}
{results.summaryData.nValidVotes == 1 && <p>{t('results.single_vote')}</p> }
{results.summaryData.nValidVotes > 1 && <>
Expand All @@ -452,7 +457,7 @@ export default function Results({ race, results }: {race: Race, results: Electio
</Typography>}
</>
:
<Typography variant="h5" sx={{fontWeight: 'bold'}}>{t('results.win_title', {names: commaListFormatter.format(results.elected.map(c => c.name))})}</Typography>
<Typography variant='h5'>{winnersText}{t('results.win_title_postfix', {count: results.elected.length})}</Typography>
}
<Typography variant="h6">{t('results.vote_count', {n: results.summaryData.nValidVotes})}</Typography>
</>}
Expand Down
3 changes: 2 additions & 1 deletion packages/frontend/src/i18n/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ results:
Full results will be displayed once there's more votes.
tie_title: 'Tied!'
tiebreak_subtitle: '{{names}} won after tie breaker'
win_title: ⭐ {{names}} Wins! ⭐
win_title_postfix_one: 'Wins!'
win_title_postfix: 'Win!'
vote_count: '{{n}} voters'
method_context: 'Voting Method: {{voting_method}}'
learn_link_text: How {{voting_method}} works
Expand Down

0 comments on commit b76a7e7

Please sign in to comment.