Add a collapse button for all matches in a group stage

The button defaults to show if the playoff hasn't started, otherwise to hide.
This commit is contained in:
Felix Hamme 2019-06-14 22:56:52 +02:00
parent 5a9d543a01
commit 99ca99ea38
3 changed files with 42 additions and 14 deletions

View File

@ -1,15 +1,36 @@
import {Card, CardBody, Col, Row, Table} from 'reactstrap'; import {Button, Card, CardBody, Col, Collapse, Row, Table} from 'reactstrap';
import {Match} from './Match'; import {Match} from './Match';
import React from 'react'; import React, {Component} from 'react';
export default function GroupStage(props) { export default class GroupStage extends Component {
return (<div className='py-5 px-5'> constructor(props) {
<h1 className='custom-font'>Gruppenphase</h1> super(props);
<Row> this.state = {showMatches: this.props.showMatches};
{props.groups.map(group => <Group group={group} key={group.id} isSignedIn={props.isSignedIn} this.toggleShowMatches = this.toggleShowMatches.bind(this);
isOwner={props.isOwner}/>)} }
</Row>
</div>); toggleShowMatches() {
this.setState({showMatches: !this.state.showMatches});
}
render() {
return (<div className='py-5 px-5'>
<h1 className='custom-font'>
Gruppenphase
<ShowMatchesToggleButton show={this.state.showMatches} toggle={this.toggleShowMatches}/>
</h1>
<Row className='mt-3'>
{this.props.groups.map(group => <Group group={group} key={group.id} isSignedIn={this.props.isSignedIn}
isOwner={this.props.isOwner} showMatches={this.state.showMatches}/>)}
</Row>
</div>);
}
}
function ShowMatchesToggleButton(props) {
return (<Button onClick={props.toggle} className='float-right default-font-family'>
{props.show ? 'Spiele ausblenden' : 'Spiele anzeigen'}
</Button>);
} }
function Group(props) { function Group(props) {
@ -17,8 +38,10 @@ function Group(props) {
<Card> <Card>
<CardBody> <CardBody>
<h3 className='custom-font'>Gruppe {props.group.id + 1}</h3> <h3 className='custom-font'>Gruppe {props.group.id + 1}</h3>
{props.group.matches.map((match => ( <Collapse isOpen={props.showMatches}>
<Match match={match} isSignedIn={props.isSignedIn} isOwner={props.isOwner} key={match.id}/>)))} {props.group.matches.map((match => (
<Match match={match} isSignedIn={props.isSignedIn} isOwner={props.isOwner} key={match.id}/>)))}
</Collapse>
<GroupScoresTable scores={props.group.scores}/> <GroupScoresTable scores={props.group.scores}/>
</CardBody> </CardBody>
</Card> </Card>

View File

@ -37,7 +37,8 @@ class PrivateTournamentPage extends React.Component {
</Container> </Container>
<div className='stages pt-5'> <div className='stages pt-5'>
{groupStage != null && {groupStage != null &&
<div><GroupStage groups={groupStage.groups} isSignedIn={isSignedIn} isOwner={isOwner}/></div>} <div><GroupStage groups={groupStage.groups} isSignedIn={isSignedIn} isOwner={isOwner}
showMatches={playoffStages !== null}/></div>}
<PlayoffStages playoffStages={playoffStages} isSignedIn={isSignedIn} <PlayoffStages playoffStages={playoffStages} isSignedIn={isSignedIn}
isOwner={isOwner}/> isOwner={isOwner}/>
</div> </div>

View File

@ -7,6 +7,10 @@
font-family: Halt, sans-serif; font-family: Halt, sans-serif;
} }
.default-font-family {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.navbar-brand { .navbar-brand {
font-family: Halt, sans-serif; font-family: Halt, sans-serif;
font-size: 2em; font-size: 2em;
@ -67,4 +71,4 @@ footer {
background: url("/static/images/tennis-blurred.jpg") no-repeat top; background: url("/static/images/tennis-blurred.jpg") no-repeat top;
background-size: cover; background-size: cover;
min-height: 100vh; min-height: 100vh;
} }