fix(ssr): make the player page less jarring when initally loading
All checks were successful
deploy / deploy (push) Successful in 1m16s

This commit is contained in:
Lee
2023-11-08 08:01:00 +00:00
parent c251239e45
commit 8e5aeadce0
4 changed files with 141 additions and 137 deletions

View File

@ -6,6 +6,7 @@ import { useSettingsStore } from "@/store/settingsStore";
import { SortType, SortTypes } from "@/types/SortTypes";
import { ScoreSaberAPI } from "@/utils/scoresaber/api";
import useStore from "@/utils/useStore";
import clsx from "clsx";
import dynamic from "next/dynamic";
import { useCallback, useEffect, useState } from "react";
import Card from "../Card";
@ -99,7 +100,13 @@ export default function Scores({ playerData, page, sortType }: ScoresProps) {
}
return (
<Card outerClassName="mt-2" className="w-full items-center md:flex-col">
<Card
outerClassName="mt-2"
className={clsx(
"w-full items-center md:flex-col",
scores.loading && "min-h-[1050px]",
)}
>
{/* Sort */}
<div className="mb-2 mt-1 w-full text-sm">
<div className="flex justify-center gap-2">
@ -124,46 +131,45 @@ export default function Scores({ playerData, page, sortType }: ScoresProps) {
</div>
</div>
<div className="w-full p-1">
<div className="flex h-full w-full flex-col items-center justify-center">
{scores.loading ? (
<div className="flex justify-center">
<div className="mt-2">
<Spinner />
</div>
) : (
<div className="grid grid-cols-1 divide-y divide-border">
{!scores.loading && scores.scores.length == 0 ? (
<p className="text-red-400">{errorMessage}</p>
) : (
scores.scores.map((scoreData, id) => {
const { score, leaderboard } = scoreData;
<>
<div className="grid min-w-full grid-cols-1 divide-y divide-border">
{!scores.loading && scores.scores.length == 0 ? (
<p className="text-red-400">{errorMessage}</p>
) : (
scores.scores.map((scoreData, id) => {
const { score, leaderboard } = scoreData;
return (
<Score
key={id}
player={playerData}
score={score}
leaderboard={leaderboard}
ownProfile={settingsStore?.player}
/>
);
})
)}
</div>
return (
<Score
key={id}
player={playerData}
score={score}
leaderboard={leaderboard}
ownProfile={settingsStore?.player}
/>
);
})
)}
</div>
{/* Pagination */}
<div className="pt-3">
<Pagination
currentPage={scores.page}
totalPages={scores.totalPages}
onPageChange={(page) => {
updateScoresPage(scores.sortType, page);
}}
/>
</div>
</>
)}
</div>
{/* Pagination */}
<div>
<div className="pt-3">
<Pagination
currentPage={scores.page}
totalPages={scores.totalPages}
onPageChange={(page) => {
updateScoresPage(scores.sortType, page);
}}
/>
</div>
</div>
</Card>
);
}