Skip to content
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

Added skeleton loader for leaderboard #580

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"react-fast-marquee": "^1.6.4",
"react-hot-toast": "^2.4.1",
"react-icons": "^5.2.1",
"react-loading-skeleton": "^3.4.0",
"react-parallax-tilt": "^1.7.231",
"react-responsive-modal": "^6.4.2",
"react-router-dom": "^6.24.0",
Expand Down
59 changes: 59 additions & 0 deletions frontend/src/components/LeaderboardSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import Skeleton from 'react-loading-skeleton';
import 'react-loading-skeleton/dist/skeleton.css';

const LeaderboardSkeleton = () => {
const skeletonArray = Array(5).fill(0); // Adjust the number of skeleton rows as needed

return (
<div className="overflow-x-auto">
<table className="min-w-full divide-y divide-gray-200">
<thead className="text-center text-sm font-medium text-[#000435] bg-white dark:text-white dark:bg-[#5f67de] border-b-2 border-sky-600">
<tr>
<th scope="col" className="px-2 py-3 sm:px-6 text-[#5f67de] bg-white dark:text-white dark:bg-[#000435] uppercase tracking-wider">
<Skeleton width={60} height={20} className=" rounded dark:bg-white" />
</th>
<th scope="col" className="px-2 py-3 sm:px-6 text-[#5f67de] bg-white dark:text-white dark:bg-[#000435] uppercase tracking-wider">
<Skeleton width={80} height={20} className=" rounded dark:bg-white" />
</th>
<th scope="col" className="px-2 py-3 sm:px-6 mx-12 text-[#5f67de] bg-white dark:text-white dark:bg-[#000435] uppercase tracking-wider">
<Skeleton width={120} height={20} className=" rounded dark:bg-white" />
</th>
<th scope="col" className="px-2 py-3 sm:px-6 text-[#5f67de] bg-white dark:text-white dark:bg-[#000435] uppercase tracking-wider">
<Skeleton width={60} height={20} className=" rounded dark:bg-white" />
</th>
<th scope="col" className="px-2 py-3 sm:px-6 text-[#5f67de] bg-white dark:text-white dark:bg-[#000435] uppercase tracking-wider">
<Skeleton width={60} height={20} className=" rounded dark:bg-white" />
</th>
</tr>
</thead>
<tbody>
{skeletonArray.map((_, index) => (
<tr key={index} className="text-center text-[#000435] dark:text-gray-50 border-b-2 border-sky-900">
<td className="px-2 py-4 sm:px-6">
<div className="flex flex-col items-center">
<Skeleton width={40} height={40} circle={true} className=" rounded-full dark:bg-white" />
</div>
</td>
<td className="px-2 py-4 sm:px-6">
<div className="flex flex-col items-center">
<Skeleton width={40} height={40} circle={true} className=" rounded-full dark:bg-white" />
</div>
</td>
<td className="px-2 py-4 sm:px-6">
<Skeleton width={120} height={20} className=" rounded dark:bg-white" />
</td>
<td className="px-2 py-4 sm:px-6">
<Skeleton width={60} height={20} className=" rounded dark:bg-white" />
</td>
<td className="px-2 py-4 sm:px-6">
<Skeleton width={60} height={20} className=" rounded dark:bg-white" />
</td>
</tr>
))}
</tbody>
</table>
</div>
);
};

export default LeaderboardSkeleton;
4 changes: 2 additions & 2 deletions frontend/src/pages/LeaderBoard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useNavigate } from 'react-router-dom';
import Loader from '../components/Loader';
import { GiTrophyCup } from "react-icons/gi";
import { useRecoilValue } from 'recoil';
import { userState } from '../store/atoms/auth';
import useLeaderboard from '../hooks/useLeadearboard';
import bgHero from "../assets/bgHero.png";
import LeaderboardSkeleton from '../components/LeaderboardSkeleton';

const LeaderBoard = () => {
const { loading, leaderboard } = useLeaderboard();
Expand All @@ -24,7 +24,7 @@ const LeaderBoard = () => {
<div className="shadow-md text-[#5f67de] bg-white dark:text-white dark:bg-[#000435] backdrop-blur-sm rounded-lg p-4 border-2 border-sky-500 lg:mx-52 md:mx-20 overflow-x-auto">
{loading ? (
<div className="flex justify-center">
<Loader />
<LeaderboardSkeleton />
</div>
) : (
<div className="overflow-x-auto">
Expand Down
Loading