diff --git a/js/components/GroupStage.js b/js/components/GroupStage.js
index c0153da..81cb898 100644
--- a/js/components/GroupStage.js
+++ b/js/components/GroupStage.js
@@ -11,6 +11,10 @@ export default class GroupStage extends Component {
super(props);
this.state = {showMatches: this.props.showMatches};
this.toggleShowMatches = this.toggleShowMatches.bind(this);
+ this.groupRefs = this.props.groups.reduce((acc, group) => {
+ acc[group.id] = React.createRef();
+ return acc;
+ }, {});
}
toggleShowMatches() {
@@ -18,21 +22,26 @@ export default class GroupStage extends Component {
}
render() {
- return (
-
- Gruppenphase
-
-
- {this.props.groups.map(group => )}
-
- );
+ return (
+
+
+ Gruppenphase
+
+
+ {this.props.groups.map(group => (
+
+ ))}
+
+
+ );
}
}
@@ -40,11 +49,11 @@ function ShowMatchesToggleChevron(props) {
const toggleClass = props.show ? 'rotate' : '';
return (
);
}
@@ -54,10 +63,18 @@ export class Group extends Component {
super(props);
this.state = props.group;
this.reload = this.reload.bind(this);
+ this.handleToggle = this.handleToggle.bind(this);
this.onReloadSuccess = this.onReloadSuccess.bind(this);
this.onReloadError = this.onReloadError.bind(this);
}
+ handleToggle() {
+ this.props.showMatchesToggle();
+ if (this.props.groupRef.current) {
+ this.props.groupRef.current.scrollIntoView({behavior: 'smooth', block: 'center'});
+ }
+ }
+
reload() {
getGroup(this.state.id, this.onReloadSuccess, this.onReloadError);
}
@@ -71,43 +88,55 @@ export class Group extends Component {
}
render() {
- return (
-
-
-
- Gruppe {this.state.number}
-
-
-
- {this.state.matches.sort(sortMatchesByPositionAscending()).map((match => (
- )))}
-
-
-
-
- );
+ return (
+
+
+
+
+ Gruppe {this.state.number}
+
+
+
+ {this.state.matches.sort(sortMatchesByPositionAscending()).map(match => (
+
+ ))}
+
+
+
+
+
+ );
}
}
function GroupScoresTable(props) {
- return (
-
-
- | # |
- Team |
- Pkt. |
- Dif. |
- Gew. |
-
-
-
- {props.scores.map(groupScore => )}
-
-
);
+ return (
+
+
+
+ | # |
+ Team |
+ Pkt. |
+ Dif. |
+ Gew. |
+
+
+
+ {props.scores.map(groupScore => )}
+
+
+ );
}
-
function GroupScoresTableRow(props) {
const teamId = `favorite-team-groupstage-${props.score.team.id}`;
return (