change up map buttons to be more mobile friendly and fix time ago formatter eslint stuff
All checks were successful
Deploy / deploy (push) Successful in 4m20s

This commit is contained in:
Lee 2024-10-01 14:37:19 +01:00
parent bd4f49205b
commit 50d5c0e5bc
5 changed files with 13 additions and 13 deletions

@ -4,12 +4,12 @@
* @param input Date | number (timestamp) * @param input Date | number (timestamp)
* @returns the format of the time ago * @returns the format of the time ago
*/ */
export function timeAgo(input: number) { export function timeAgo(input: Date) {
const inputDate = new Date(input).getTime(); // Convert input to a Date object if it's not already const inputDate = new Date(input).getTime(); // Convert input to a Date object if it's not already
const now = new Date().getTime(); const now = new Date().getTime();
const deltaSeconds = Math.floor((now - inputDate) / 1000); // Get time difference in seconds const deltaSeconds = Math.floor((now - inputDate) / 1000); // Get time difference in seconds
if (deltaSeconds < 60) { if (deltaSeconds <= 60) {
return "just now"; return "just now";
} }
@ -21,10 +21,10 @@ export function timeAgo(input: number) {
{ unit: "m", seconds: 60 }, // minutes { unit: "m", seconds: 60 }, // minutes
]; ];
let result = []; const result = [];
let remainingSeconds = deltaSeconds; let remainingSeconds = deltaSeconds;
for (let { unit, seconds } of timeUnits) { for (const { unit, seconds } of timeUnits) {
const count = Math.floor(remainingSeconds / seconds); const count = Math.floor(remainingSeconds / seconds);
if (count > 0) { if (count > 0) {
result.push(`${count}${unit}`); result.push(`${count}${unit}`);

@ -14,7 +14,7 @@ type Props = {
export default function FallbackLink({ href, children }: Props) { export default function FallbackLink({ href, children }: Props) {
return href ? ( return href ? (
<NextLink href={href} target="_blank"> <NextLink href={href} target="_blank" className="w-fit">
{children} {children}
</NextLink> </NextLink>
) : ( ) : (

@ -24,7 +24,7 @@ type Props = {
export default function LeaderboardScore({ player, score, leaderboard }: Props) { export default function LeaderboardScore({ player, score, leaderboard }: Props) {
return ( return (
<div className="pb-1 pt-1"> <div className="pb-1.5 pt-1.5">
<div className="grid items-center w-full gap-2 grid-cols-[20px 1fr_1fr] lg:grid-cols-[130px_4fr_300px]"> <div className="grid items-center w-full gap-2 grid-cols-[20px 1fr_1fr] lg:grid-cols-[130px_4fr_300px]">
<ScoreRankInfo score={score} /> <ScoreRankInfo score={score} />
<LeaderboardPlayer player={player} score={score} /> <LeaderboardPlayer player={player} score={score} />

@ -28,12 +28,8 @@ export default function ScoreButtons({
const { toast } = useToast(); const { toast } = useToast();
return ( return (
<div className="flex justify-end"> <div className="flex justify-end gap-2">
<LeaderboardButton <div className="flex flex-row items-center lg:items-start justify-center flex-wrap gap-1 lg:justify-end">
isLeaderboardExpanded={isLeaderboardExpanded}
setIsLeaderboardExpanded={setIsLeaderboardExpanded}
/>
<div className="flex flex-row justify-center flex-wrap gap-1 lg:justify-end">
{beatSaverMap != undefined && ( {beatSaverMap != undefined && (
<> <>
{/* Copy BSR */} {/* Copy BSR */}
@ -75,6 +71,10 @@ export default function ScoreButtons({
<YouTubeLogo /> <YouTubeLogo />
</ScoreButton> </ScoreButton>
</div> </div>
<LeaderboardButton
isLeaderboardExpanded={isLeaderboardExpanded}
setIsLeaderboardExpanded={setIsLeaderboardExpanded}
/>
</div> </div>
); );
} }

@ -68,7 +68,7 @@ export default function ScoreSongInfo({ leaderboard, beatSaverMap }: Props) {
</p> </p>
<p className="text-sm text-gray-400">{leaderboard.songAuthorName}</p> <p className="text-sm text-gray-400">{leaderboard.songAuthorName}</p>
<FallbackLink href={mappersProfile}> <FallbackLink href={mappersProfile}>
<p className={clsx("text-sm", mappersProfile && "hover:brightness-75 transform-gpu transition-all")}> <p className={clsx("text-sm", mappersProfile && "hover:brightness-75 transform-gpu transition-all w-fit")}>
{leaderboard.levelAuthorName} {leaderboard.levelAuthorName}
</p> </p>
</FallbackLink> </FallbackLink>