From 416a4fbc86e18496eee025b57286276342bb758b Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 14 Mar 2025 22:13:28 +0100 Subject: [PATCH] Add basic scroll to favorite behaviour --- js/components/FavoriteBar.js | 44 ++++++++++++++++++++++++------------ js/components/GroupStage.js | 17 ++++++++------ 2 files changed, 39 insertions(+), 22 deletions(-) diff --git a/js/components/FavoriteBar.js b/js/components/FavoriteBar.js index f2f50d3..e0cd9c8 100644 --- a/js/components/FavoriteBar.js +++ b/js/components/FavoriteBar.js @@ -1,11 +1,11 @@ -import React, { useState, useEffect } from 'react'; -import { Button } from 'reactstrap'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faStar as filledStar } from '@fortawesome/free-solid-svg-icons'; -import { faStar as emptyStar } from '@fortawesome/free-regular-svg-icons'; -import { faHeartCirclePlus } from '@fortawesome/free-solid-svg-icons'; +import React, {useState, useEffect} from 'react'; +import {Button} from 'reactstrap'; +import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; +import {faStar as filledStar} from '@fortawesome/free-solid-svg-icons'; +import {faStar as emptyStar} from '@fortawesome/free-regular-svg-icons'; +import {faHeartCirclePlus} from '@fortawesome/free-solid-svg-icons'; -export function FavoriteBar({ teams }) { +export function FavoriteBar({teams}) { const [favorite, setFavorite] = useState(null); const [isVisible, setIsVisible] = useState(false); const [isLoading, setIsLoading] = useState(true); @@ -31,32 +31,46 @@ export function FavoriteBar({ teams }) { } }; + const scrollToFavorite = () => { + if (favorite) { + const el = document.getElementById(`favorite-team-groupstage-${favorite.id}`); + if (el) { + el.scrollIntoView({behavior: 'smooth', block: 'end'}); + } + } + }; + if (isLoading) { return
Loading...
; } return (
-
-

Favorit:

-

{favorite ? favorite.name : ''}

+
+

Favorit:

+

{favorite ? favorite.name : ''}

+ {favorite && ( + + )}
{isVisible && (

All Teams

{teams.map(team => ( -
- - {team.name} {favorite && favorite.id === team.id && (Favorite)} + {team.name}
))} @@ -65,4 +79,4 @@ export function FavoriteBar({ teams }) { )}
); -} \ No newline at end of file +} diff --git a/js/components/GroupStage.js b/js/components/GroupStage.js index 17b45ed..6cc4f19 100644 --- a/js/components/GroupStage.js +++ b/js/components/GroupStage.js @@ -94,11 +94,14 @@ function GroupScoresTable(props) { function GroupScoresTableRow(props) { - return ( - {props.score.position} - {props.score.team.name} - {props.score.group_points} - {props.score.difference_in_points} - {props.score.scored_points} - ); + const teamId = `favorite-team-groupstage-${props.score.team.id}`; + return ( + + {props.score.position} + {props.score.team.name} + {props.score.group_points} + {props.score.difference_in_points} + {props.score.scored_points} + + ); }