implement a janky fix for mobile until i can be bothered to make it mobile friendly
All checks were successful
Deploy Website / deploy (push) Successful in 3m26s

This commit is contained in:
Lee 2024-10-11 03:35:12 +01:00
parent e4f0376af3
commit 4894e0597c

@ -11,19 +11,8 @@ import { PlayerRanking } from "@/components/ranking/player-ranking";
const REFRESH_INTERVAL = 1000 * 60 * 5; const REFRESH_INTERVAL = 1000 * 60 * 5;
type RankingDataProps = { type RankingDataProps = {
/**
* The page to show when opening the leaderboard.
*/
initialPage: number; initialPage: number;
/**
* The country to show when opening the leaderboard.
*/
country?: string | undefined; country?: string | undefined;
/**
* The leaderboard to display.
*/
initialPageData?: ScoreSaberPlayersPageToken; initialPageData?: ScoreSaberPlayersPageToken;
}; };
@ -53,9 +42,6 @@ export default function RankingData({ initialPage, country, initialPageData }: R
} }
}, [data, isLoading, isError]); }, [data, isLoading, isError]);
/**
* Gets the URL to the page.
*/
const getUrl = useCallback( const getUrl = useCallback(
(page: number) => { (page: number) => {
return `/ranking/${country != undefined ? `${country}/` : ""}${page}`; return `/ranking/${country != undefined ? `${country}/` : ""}${page}`;
@ -63,10 +49,6 @@ export default function RankingData({ initialPage, country, initialPageData }: R
[country] [country]
); );
/**
* Handle updating the URL when the page number,
* sort, or search term changes.
*/
useEffect(() => { useEffect(() => {
const newUrl = getUrl(currentPage); const newUrl = getUrl(currentPage);
window.history.replaceState({ ...window.history.state, as: newUrl, url: newUrl }, "", newUrl); window.history.replaceState({ ...window.history.state, as: newUrl, url: newUrl }, "", newUrl);
@ -80,6 +62,8 @@ export default function RankingData({ initialPage, country, initialPageData }: R
return ( return (
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
{/* Wrapping the table in a scrollable container */}
<div className="overflow-x-auto">
<table className="table w-full table-auto border-spacing-2 border-none text-left"> <table className="table w-full table-auto border-spacing-2 border-none text-left">
<thead> <thead>
<tr> <tr>
@ -92,7 +76,7 @@ export default function RankingData({ initialPage, country, initialPageData }: R
<th className="px-4 py-2 text-center">Weekly Change</th> <th className="px-4 py-2 text-center">Weekly Change</th>
</tr> </tr>
</thead> </thead>
<tbody className="border-none overflow-x-scroll w-full"> <tbody className="border-none">
{players.map(player => ( {players.map(player => (
<tr key={player.rank} className="border-b border-border"> <tr key={player.rank} className="border-b border-border">
<PlayerRanking isCountry={country != undefined} player={player} /> <PlayerRanking isCountry={country != undefined} player={player} />
@ -100,6 +84,7 @@ export default function RankingData({ initialPage, country, initialPageData }: R
))} ))}
</tbody> </tbody>
</table> </table>
</div>
{/* Pagination */} {/* Pagination */}
<Pagination <Pagination