added podium ranks

This commit is contained in:
2025-08-07 14:51:33 -05:00
parent be9b9d6ba3
commit 7111eca531
5 changed files with 63 additions and 11 deletions
+17
View File
@@ -9,6 +9,8 @@
"version": "0.1.0", "version": "0.1.0",
"dependencies": { "dependencies": {
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"lucide": "^0.537.0",
"lucide-react": "^0.537.0",
"next": "15.4.6", "next": "15.4.6",
"react": "19.1.0", "react": "19.1.0",
"react-dom": "19.1.0" "react-dom": "19.1.0"
@@ -1363,6 +1365,21 @@
"url": "https://opencollective.com/parcel" "url": "https://opencollective.com/parcel"
} }
}, },
"node_modules/lucide": {
"version": "0.537.0",
"resolved": "https://registry.npmjs.org/lucide/-/lucide-0.537.0.tgz",
"integrity": "sha512-EuafIo7OaBBdHhIF5/v6G2H9IOFwZkY2ZFiqn2xHO8QEInXxQnPDJM+nX8CFylBISMZ8GlB9ktSMSgqP/L0kQw==",
"license": "ISC"
},
"node_modules/lucide-react": {
"version": "0.537.0",
"resolved": "https://registry.npmjs.org/lucide-react/-/lucide-react-0.537.0.tgz",
"integrity": "sha512-VxWsdxBGeFnlC+HwMg/l08HptN4YRU9o/lRog156jOmRxI1ERKqN+rJiNY/mPcKAdWdM0UbyO8ft1o0jq69SSQ==",
"license": "ISC",
"peerDependencies": {
"react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0"
}
},
"node_modules/magic-string": { "node_modules/magic-string": {
"version": "0.30.17", "version": "0.30.17",
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz",
+2
View File
@@ -10,6 +10,8 @@
}, },
"dependencies": { "dependencies": {
"date-fns": "^4.1.0", "date-fns": "^4.1.0",
"lucide": "^0.537.0",
"lucide-react": "^0.537.0",
"next": "15.4.6", "next": "15.4.6",
"react": "19.1.0", "react": "19.1.0",
"react-dom": "19.1.0" "react-dom": "19.1.0"
+2
View File
@@ -27,6 +27,8 @@ export default function RootLayout({
<body <body
className={`${geistSans.variable} ${geistMono.variable} antialiased`} className={`${geistSans.variable} ${geistMono.variable} antialiased`}
> >
<div className="w-full h-14 bg-neutral-900"></div>
{children} {children}
</body> </body>
</html> </html>
+21 -3
View File
@@ -34,18 +34,34 @@ export default function Home() {
time: 63, time: 63,
problem: "Two Sum", problem: "Two Sum",
date: 1651600541000, date: 1651600541000,
},{
rank: 2,
name: "Kleo",
time: 63,
problem: "Two Sum",
date: 1651600541000,
},{
rank: 3,
name: "Kleo",
time: 63,
problem: "Two Sum",
date: 1651600541000,
},{
rank: 4,
name: "Kleo",
time: 63,
problem: "Two Sum",
date: 1651600541000,
}, },
]; ];
return ( return (
<> <>
<div className="w-full h-14 bg-neutral-900"></div>
<div className="mt-5 mx-10 xl:mx-[35rem] flex gap-5"> <div className="mt-5 mx-10 xl:mx-[35rem] flex gap-5">
<div className="w-full"> <div className="w-full">
<SpeedrunTable data={users} /> <SpeedrunTable data={users} />
</div> </div>
<div className="w-[35rem]"> <div className="w-[35rem] h-max">
<div className="w-full bg-[#121212] h-full rounded-lg p-5"> <div className="w-full bg-[#121212] h-full rounded-lg p-5">
<h1 className="font-bold">LATEST NEWS</h1> <h1 className="font-bold">LATEST NEWS</h1>
<div className="flex flex-col w-full pt-3"> <div className="flex flex-col w-full pt-3">
@@ -75,6 +91,8 @@ export default function Home() {
/> />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</> </>
+21 -8
View File
@@ -1,5 +1,6 @@
import { format, timeAgo } from "@/lib/utils"; import { format, timeAgo } from "@/lib/utils";
import { formatDate } from "date-fns"; import { formatDate } from "date-fns";
import { TrophyIcon } from "lucide-react";
import React from "react"; import React from "react";
export interface Speedrun { export interface Speedrun {
@@ -38,25 +39,29 @@ const SpeedrunTable: React.FC<TableProps> = ({ data }) => {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{data.map((user) => ( {data.map((speedrun, i) => (
<tr <tr
key={user.rank} key={i}
className="hover:bg-[#1f1f1f] transition-colors border-b border-[#1e1e1e]" className="hover:bg-[#1f1f1f] transition-colors border-b border-[#1e1e1e]"
> >
<td className="px-6 py-4 whitespace-nowrap">{user.rank}</td> <td className="px-6 py-4 whitespace-nowrap flex justify-center">
<Rank rank={speedrun.rank} />
</td>
<td className="px-6 py-4 whitespace-nowrap font-bold"> <td className="px-6 py-4 whitespace-nowrap font-bold">
{user.name} {speedrun.name}
</td> </td>
<td className="px-6 py-4 whitespace-nowrap"> <td className="px-6 py-4 whitespace-nowrap">
{format(user.time)} {format(speedrun.time)}
</td> </td>
<td <td
className="px-6 py-4 whitespace-nowrap" className="px-6 py-4 whitespace-nowrap"
title={new Date(user.date).toLocaleString()} title={new Date(speedrun.date).toLocaleString()}
> >
{timeAgo(user.date)} {timeAgo(speedrun.date)}
</td>
<td className="px-6 py-4 whitespace-nowrap">
{speedrun.problem}
</td> </td>
<td className="px-6 py-4 whitespace-nowrap">{user.problem}</td>
</tr> </tr>
))} ))}
</tbody> </tbody>
@@ -65,4 +70,12 @@ const SpeedrunTable: React.FC<TableProps> = ({ data }) => {
); );
}; };
function Rank({ rank }: { rank: number }) {
if (rank === 1) return <TrophyIcon className="w-4 text-amber-400" />;
if (rank === 2) return <TrophyIcon className="w-4 text-slate-400" />;
if (rank === 3) return <TrophyIcon className="w-4 text-amber-600" />;
return rank;
}
export default SpeedrunTable; export default SpeedrunTable;