diff --git a/js/components/FavoriteBar.js b/js/components/FavoriteBar.js index 9be9735..48e5816 100644 --- a/js/components/FavoriteBar.js +++ b/js/components/FavoriteBar.js @@ -11,6 +11,7 @@ export function FavoriteBar({teams}) { const [isLoading, setIsLoading] = useState(true); const [isPulsing, setIsPulsing] = useState(false); const headingRef = useRef(null); + const favoriteBarRef = useRef(null); useEffect(() => { const savedFavorite = localStorage.getItem('favoriteTeam'); @@ -23,6 +24,14 @@ export function FavoriteBar({teams}) { setIsLoading(false); }, [teams]); + useEffect(() => { + if (isVisible && favoriteBarRef.current) { + favoriteBarRef.current.style.maxHeight = `${favoriteBarRef.current.scrollHeight}px`; + } else if (favoriteBarRef.current) { + favoriteBarRef.current.style.maxHeight = '0'; + } + }, [isVisible]); + const toggleFavorite = team => { if (favorite && favorite.id === team.id) { setFavorite(null); @@ -72,24 +81,22 @@ export function FavoriteBar({teams}) { )} - {isVisible && ( -
-
- {sortedTeams.map(team => ( -
- - - {team.name} - -
- ))} -
+
+
+ {sortedTeams.map(team => ( +
+ + + {team.name} + +
+ ))}
- )} +
); -} \ No newline at end of file +} diff --git a/public/static/css/tournament.css b/public/static/css/tournament.css index 572a1de..6728a6f 100644 --- a/public/static/css/tournament.css +++ b/public/static/css/tournament.css @@ -19,7 +19,7 @@ } .match:hover { - box-shadow: 0 .5rem 1rem rgba(0,0,0,.15)!important; + box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15) !important; } .match:hover > div { @@ -45,4 +45,14 @@ .pulse-animation { animation: pulse 1s infinite; -} \ No newline at end of file +} + +.favorite-bar { + max-height: 0; + overflow: hidden; + transition: max-height 0.7s ease-in-out; +} + +.favorite-bar.visible { + max-height: none; +}