diff --git a/src/componets/Sidebar.css b/src/componets/Sidebar.css index 2a4f100..849d01c 100644 --- a/src/componets/Sidebar.css +++ b/src/componets/Sidebar.css @@ -1,7 +1,7 @@ @import 'tailwindcss'; .sidebar { - @apply fixed top-0 left-0 w-60 h-screen bg-[#161616] flex flex-col border-e-[1px] border-[#2a2a2a]; + @apply fixed top-0 left-0 w-60 h-screen bg-[#161616] flex flex-col border-e-[1px] border-[#2a2a2a] z-[999]; } .sidebar-downloads { diff --git a/src/componets/Sidebar.tsx b/src/componets/Sidebar.tsx index 7ded230..3c14c81 100644 --- a/src/componets/Sidebar.tsx +++ b/src/componets/Sidebar.tsx @@ -2,7 +2,7 @@ import './Sidebar.css' import Icon from '../Icon.png' import { openUrl } from '@tauri-apps/plugin-opener' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faCog, faDownload, faServer } from '@fortawesome/free-solid-svg-icons' +import { faCog, faDownload, faRankingStar, faServer } from '@fortawesome/free-solid-svg-icons' import { faDiscord } from '@fortawesome/free-brands-svg-icons' import { useState } from 'react' import { platform } from '@tauri-apps/plugin-os' @@ -74,7 +74,8 @@ export default function Sidebar({ setShowPopup, setPopupMode, setFadeOut }: Side
{ setPopupMode(1); setShowPopup(true); setFadeOut(false) }}>

Downloads

diff --git a/src/main.tsx b/src/main.tsx index a4b4571..2ac7c9a 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -12,6 +12,7 @@ import { listen } from '@tauri-apps/api/event' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { faAdd, faRemove, faX } from '@fortawesome/free-solid-svg-icons' import '@fontsource/roboto' +import Leaderboards from './routes/Leaderboards' function App () { const [hash, setHash] = useState(window.location.hash || '#installs') @@ -108,6 +109,8 @@ function App () { return } else if (hash === '#settings') { return + } else if (hash === '#leaderboards') { + return } return null } diff --git a/src/routes/Leaderboards.css b/src/routes/Leaderboards.css new file mode 100644 index 0000000..da49b9a --- /dev/null +++ b/src/routes/Leaderboards.css @@ -0,0 +1,17 @@ +@import 'tailwindcss'; + +.leaderboard-container { + @apply flex justify-center; +} + +.leaderboard-scroll { + @apply h-[85vh] bg-[#161616] border border-[#242424] rounded-lg overflow-y-auto max-w-md w-full; +} + +.leaderboard-entry { + @apply flex justify-between items-center m-2 p-4 rounded-lg text-gray-200 text-lg transition-colors cursor-default bg-[#242424] hover:bg-[#323232] border border-[#484848] hover:border-[#565656]; +} + +.leaderboard-entry p.score { + @apply font-mono text-blue-500 text-lg; +} diff --git a/src/routes/Leaderboards.tsx b/src/routes/Leaderboards.tsx new file mode 100644 index 0000000..e0cd437 --- /dev/null +++ b/src/routes/Leaderboards.tsx @@ -0,0 +1,45 @@ +import { useEffect, useState } from 'react' +import './Leaderboards.css' +import axios from 'axios' +import { LeaderboardEntry } from '../types/LeaderboardEntry' + +export default function Leaderboards() { + const [leaderboardData, setLeaderboardData] = useState([]) + + function refresh() { + setLeaderboardData([]) + axios + .get('https://berrydash.lncvrt.xyz/database/getTopPlayersAPI.php') + .then(res => setLeaderboardData(res.data)) + .catch(e => console.error('Error fetching leaderboard data:', e)) + } + + useEffect(() => { + refresh() + }, []) + + return ( +
+
+

Leaderboards

+ +
+
+
+ {leaderboardData.length ? ( + leaderboardData.map((entry, i) => ( +
+

#{i + 1} {entry.username}

+

{entry.scoreFormatted}

+
+ )) + ) : ( +
+

Loading...

+
+ )} +
+
+
+ ) +} diff --git a/src/types/LeaderboardEntry.ts b/src/types/LeaderboardEntry.ts new file mode 100644 index 0000000..aa742a5 --- /dev/null +++ b/src/types/LeaderboardEntry.ts @@ -0,0 +1,5 @@ +export interface LeaderboardEntry { + username: string + score: bigint + scoreFormatted: string +}