Skip to content

Added Leaderboard Page for Amfoss home #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Conversation

PinJinx
Copy link
Contributor

@PinJinx PinJinx commented Feb 9, 2025

PR for Issue#15
Description:
=>This PR adds a Leader board page to amfoss home page where all the member's rank is listed and compared.
=>The leader board can be accessed at http://localhost:3000/leaderboard

Content Added:
-> A new page file and a layout file for the Leaderboard has been added to /src/app/leaderboard
-> An Image for the Leader board platforms has been added to /src/public

Copy link

netlify bot commented Feb 9, 2025

Deploy Preview for zingy-speculoos-372a93 ready!

Name Link
🔨 Latest commit aa2d488
🔍 Latest deploy log https://app.netlify.com/sites/zingy-speculoos-372a93/deploys/67c0803e4a70980008ff3ce3
😎 Deploy Preview https://deploy-preview-23--zingy-speculoos-372a93.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

import { Trophy, Award, Medal, Ribbon } from "lucide-react";
import { useState } from "react";

export default function Home() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this page named Home, it should be LeaderBoard

const [alltimemode, setmode] = useState(false);

return (
<li className="w-full overflow-hidden gap-7 flex flex-col items-center bg-[#161616]">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this a list item when there is no ul or ol present


return (
<li className="w-full overflow-hidden gap-7 flex flex-col items-center bg-[#161616]">
<p className="mt-5 text-center text-white text-[3rem] sm:text-[2.5rem] md:text-[4.2rem] lg:text-[5rem] font-medium">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a bit verbose, try to use inbuilt tailwind classes and lessen the no of breakpoints, also when it is a heading try to use <h1>

</p>
</button>
<button
style={{ backgroundColor: !alltimemode ? "#292929" : "#1C1C1C" }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having hardcoded colors makes it hard to manage the colors on a later update, add the color to tailwind.config.js and use tailwind conditional classes
eg:

Suggested change
style={{ backgroundColor: !alltimemode ? "#292929" : "#1C1C1C" }}
className={`transition-colors duration-300 flex w-[50%] justify-center items-center rounded-md ${
alltimemode ? "bg-somecolor" : "bg-othercolor"
}`}

}`}

Comment on lines 73 to 127
function ProfileBottom() {
const imgpath = "/placeholder.webp";
const name = "Placeholder";
return (
<div className="flex flex-col items-center w-full sm:w-auto scale-100 sm:scale-75">
<div className="flex flex-col items-center justify-center relative">
<Image
src={imgpath}
alt="profile"
width={200}
height={200}
className="rounded-full z-10 mb-4"
/>
<p className="text-5xl z-10 text-white text-center">{name}</p>
</div>
<p className="text-base sm:text-2xl md:text-xl mt-3 text-center text-white gap-2">
Points
</p>
</div>
);
}

function Profile({ mt = 0, rank = "" }) {
const imgpath = "/placeholder.webp";
const name = "Placeholder";
let sticker = <Medal className="w-5 h-5" />;
if (rank == "Gold") {
sticker = <Trophy className="w-5 h-5" />;
}
return (
<div style={{ marginTop: `${mt}rem` }} className="scale-100 sm:scale-75">
<div className="flex flex-col items-center justify-center relative">
<div className="absolute w-[200px] h-[200px] rounded-md border-[20px] border-yellow-400 mb-4 blur-2xl"></div>
<Image
src={imgpath}
alt="profile"
width={200}
height={200}
className="rounded-md z-10 mb-4"
/>
<p className="text-5xl z-10 text-white text-center">{name}</p>
</div>
<div
className="w-[250px] sm:w-[300px] h-[250px] sm:h-[300px] bg-cover bg-center flex flex-col items-center text-white"
style={{ backgroundImage: "url('/leaderboard.svg')" }}
>
<p className="text-4xl font-semibold mt-8 text-white">{rank}</p>
<hr className="border-[1.5px] border-yellow-400 w-[80%]" />
<p className="text-base sm:text-2xl md:text-xl w-1/3 mt-3 text-center text-white flex items-center justify-center gap-2">
{sticker}Points
</p>
</div>
</div>
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make a separate component for this

sticker = <Trophy className="w-5 h-5" />;
}
return (
<div style={{ marginTop: `${mt}rem` }} className="scale-100 sm:scale-75">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use tailwind conditional classes

Comment on lines 74 to 75
const imgpath = "/placeholder.webp";
const name = "Placeholder";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

placeholder is fine but shouldn´t the component need to accept actual image path when its available

const imgpath = "/placeholder.webp";
const name = "Placeholder";
let sticker = <Medal className="w-5 h-5" />;
if (rank == "Gold") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this only handle gold, what about silver and bronze

Comment on lines 129 to 182
function Table() {
let players = [];
for (let i = 1; i <= 100; i++) {
let col = "";
let k = <div className="w-5 h-5" />;
if (i == 1) {
col = "#EFBF04";
k = <Trophy className="w-5 h-5" />;
} else if (i == 2) {
col = "#a1a1a1";
k = <Medal className="w-5 h-5" />;
} else if (i == 3) {
col = "#804A00";
k = <Medal className="w-5 h-5" />;
} else {
col = "#232323";
}
players.push(
<div
key={i}
style={{ backgroundColor: col }}
className="hover:bg-[#303030] rounded-md transition-transform duration-300 ease-in-out transform hover:scale-105"
>
<div className="h-10 flex items-center justify-evenly rounded-md px-4">
<p className="w-1/3 text-center text-white flex items-center justify-center gap-2 mr-3">
<Award className="w-5 h-5" /> {i}
</p>
<p className="w-1/3 text-center text-white">Player</p>
<div className="w-1/3 text-center text-white flex items-center justify-center gap-2 ml-4">
{k}
<p>{i * 1000}</p>
</div>
</div>
</div>
);
}

return (
<div className="w-full flex flex-col items-center rounded-lg">
<div className="w-[90%] sm:max-h-[400px] lg:max-h-[800px] overflow-y-auto rounded-lg">
<table className="sticky top-0 z-40 w-full text-white border-collapse">
<thead className="bg-[#161616]">
<tr className="text-left ">
<th className="px-4 py-2 text-center w-1/3">Rank</th>
<th className="px-4 py-2 text-center w-1/3">Name</th>
<th className="px-4 py-2 text-center w-1/3">Points</th>
</tr>
</thead>
</table>
<div className="w-full flex flex-col gap-1 p-2">{players}</div>
</div>
</div>
);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is quite expensive to load, and when we have actual data a for loop will be too much, use .map() and make this an another component and dynamically import it to reduce re render on every change.

@sabarixr sabarixr merged commit cbd46e9 into amfoss:main Feb 28, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants