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 univeral loader #147

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions app/loading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { PacmanLoader } from "react-spinners";
export default function TopLoader() {
return (
<div className="flex w-full h-screen justify-center items-center">
<PacmanLoader color="#4ade80" />
</div>
);
}
20 changes: 8 additions & 12 deletions components/TournamentBracket.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import React, { useState, useEffect } from "react";
import { Card, CardContent } from "./ui/card";
import { motion, AnimatePresence } from "framer-motion";
import { Loader2 } from "lucide-react";
import { PacmanLoader } from "react-spinners";

const TournamentBracket = ({ matches, roundNames }) => {
const [rounds, setRounds] = useState([]);
Expand All @@ -17,7 +17,7 @@ const TournamentBracket = ({ matches, roundNames }) => {
organizeMatchesByRound(matches);
setError(null);
} catch (err) {
setError('Failed to organize matches');
setError("Failed to organize matches");
} finally {
setLoading(false);
}
Expand All @@ -37,18 +37,14 @@ const TournamentBracket = ({ matches, roundNames }) => {

if (loading) {
return (
<div className="flex justify-center items-center py-10">
<Loader2 className="h-6 w-6 animate-spin text-primary" />
<div className="flex w-full h-screen justify-center items-center">
<PacmanLoader color="#4ade80" />
</div>
);
}

if (error) {
return (
<div className="text-center text-destructive py-10">
{error}
</div>
);
return <div className="text-center text-destructive py-10">{error}</div>;
}

return (
Expand All @@ -72,13 +68,13 @@ const TournamentBracket = ({ matches, roundNames }) => {
>
{roundNames[roundIndex]}
</motion.h3>

{round.map((match, matchIndex) => (
<motion.div
key={matchIndex}
initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }}
transition={{ delay: (roundIndex * 0.1) + (matchIndex * 0.05) }}
transition={{ delay: roundIndex * 0.1 + matchIndex * 0.05 }}
>
<Card className="relative">
<CardContent className="p-4">
Expand All @@ -97,7 +93,7 @@ const TournamentBracket = ({ matches, roundNames }) => {
</div>
))}
</div>

{match.status && (
<div className="absolute -right-2 -top-2">
<span className="inline-block px-2 py-1 text-xs rounded-full bg-secondary/10 text-secondary">
Expand Down
11 changes: 11 additions & 0 deletions 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"react-hook-form": "7.52.1",
"react-icons": "5.2.1",
"react-loading-skeleton": "3.4.0",
"react-spinners": "^0.15.0",
"resend": "3.4.0",
"sharp": "^0.33.5",
"tailwind-merge": "2.4.0",
Expand Down
Loading