From e1bfa05b9fcc41fcd6deb6ffc3df21c923f17d70 Mon Sep 17 00:00:00 2001 From: Malaber Date: Mon, 17 Mar 2025 16:07:41 +0100 Subject: [PATCH] Togglescroll? --- js/components/GroupStage.js | 127 ++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 49 deletions(-) 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 ( - - - - - - - - - - - {props.scores.map(groupScore => )} - -
#TeamPkt.Dif.Gew.
); + return ( + + + + + + + + + + + + {props.scores.map(groupScore => )} + +
#TeamPkt.Dif.Gew.
+ ); } - function GroupScoresTableRow(props) { const teamId = `favorite-team-groupstage-${props.score.team.id}`; return (