-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
✅ Deploy Preview for zingy-speculoos-372a93 ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
src/app/leaderboard/page.tsx
Outdated
import { Trophy, Award, Medal, Ribbon } from "lucide-react"; | ||
import { useState } from "react"; | ||
|
||
export default function Home() { |
There was a problem hiding this comment.
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
src/app/leaderboard/page.tsx
Outdated
const [alltimemode, setmode] = useState(false); | ||
|
||
return ( | ||
<li className="w-full overflow-hidden gap-7 flex flex-col items-center bg-[#161616]"> |
There was a problem hiding this comment.
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
src/app/leaderboard/page.tsx
Outdated
|
||
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"> |
There was a problem hiding this comment.
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>
src/app/leaderboard/page.tsx
Outdated
</p> | ||
</button> | ||
<button | ||
style={{ backgroundColor: !alltimemode ? "#292929" : "#1C1C1C" }} |
There was a problem hiding this comment.
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:
style={{ backgroundColor: !alltimemode ? "#292929" : "#1C1C1C" }} | |
className={`transition-colors duration-300 flex w-[50%] justify-center items-center rounded-md ${ | |
alltimemode ? "bg-somecolor" : "bg-othercolor" | |
}`} | |
}`}
src/app/leaderboard/page.tsx
Outdated
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> | ||
); | ||
} |
There was a problem hiding this comment.
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
src/app/leaderboard/page.tsx
Outdated
sticker = <Trophy className="w-5 h-5" />; | ||
} | ||
return ( | ||
<div style={{ marginTop: `${mt}rem` }} className="scale-100 sm:scale-75"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tailwind conditional classes
src/app/leaderboard/page.tsx
Outdated
const imgpath = "/placeholder.webp"; | ||
const name = "Placeholder"; |
There was a problem hiding this comment.
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
src/app/leaderboard/page.tsx
Outdated
const imgpath = "/placeholder.webp"; | ||
const name = "Placeholder"; | ||
let sticker = <Medal className="w-5 h-5" />; | ||
if (rank == "Gold") { |
There was a problem hiding this comment.
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
src/app/leaderboard/page.tsx
Outdated
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> | ||
); | ||
} |
There was a problem hiding this comment.
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.
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