Slight collapse change

This commit is contained in:
Felix Albrigtsen 2022-03-30 01:35:22 +02:00
parent 009760cd33
commit ab472c3875
1 changed files with 4 additions and 1 deletions

View File

@ -36,6 +36,7 @@ function shorten(description, maxLength) {
function TournamentListItem(props) {
const [longDescription, setLongDescription] = React.useState(false);
const maxLength = 200;
function toggleDescription() {
setLongDescription(!longDescription);
}
@ -45,9 +46,11 @@ function TournamentListItem(props) {
<Typography variant="body1" onClick={toggleDescription}>{props.tournament.description}</Typography>
<KeyboardDoubleArrowUpIcon onClick={toggleDescription} />
</Box> )
} else if (props.tournament.description.length < maxLength) {
return <Typography variant="body1" color="text.secondary" onClick={toggleDescription}>{props.tournament.description}</Typography>
} else {
return <Box component={Stack} direction="row">
<Typography variant="body1" color="text.secondary" onClick={toggleDescription}>{shorten(props.tournament.description, 200)}</Typography>
<Typography variant="body1" color="text.secondary" onClick={toggleDescription}>{shorten(props.tournament.description, maxLength)}</Typography>
<KeyboardDoubleArrowDownIcon onClick={toggleDescription} />
</Box>;
}