Skip to content

Commit

Permalink
XP meter in profile
Browse files Browse the repository at this point in the history
  • Loading branch information
renatodellosso committed Dec 30, 2024
1 parent 4e0def3 commit 9cb766b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions components/XpProgressBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { User } from "@/lib/Types";
import { xpRequiredForNextLevel } from "@/lib/Xp";
import { useState } from "react";

export default function XpProgressBar({ user, size }: { user: User, size: string }) {
const [hovered, setHovered] = useState(false);

return (
<div
className={`radial-progress text-accent m-2 text-${hovered ? "xs" : "sm"}`}
style={{ "--value": user.xp / xpRequiredForNextLevel(user.level) * 100 , "--size": size } as any}
role="progressbar"
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
>
{hovered ? `${user.xp}/${xpRequiredForNextLevel(user.level)}` : `Lvl ${user.level}`}
</div>
);
}
4 changes: 2 additions & 2 deletions components/competition/MatchScheduleCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export default function MatchScheduleCard(props: {
<div>No subjective scouter assigned</div>
)}
</div>
<Link
<a
className={`btn btn-primary btn-sm ${match.subjectiveScouter && usersById[match.subjectiveScouter]?.slackId && "-translate-y-1"}`}
href={`/${team?.slug}/${seasonSlug}/${comp?.slug}/${match._id}/subjective`}
>
Expand All @@ -301,7 +301,7 @@ export default function MatchScheduleCard(props: {
: 0
} in progress`}
)
</Link>
</a>
</div>
))}
</div>
Expand Down
2 changes: 2 additions & 0 deletions pages/profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import TeamCard from "@/components/TeamCard";
import { UpdateModal } from "@/components/UpdateModal";
import { Analytics } from "@/lib/client/Analytics";
import { signOut } from "next-auth/react";
import XpProgressBar from "@/components/XpProgressBar";

const api = new ClientApi();

Expand Down Expand Up @@ -120,6 +121,7 @@ export default function Profile(props: { teamList: Team[] }) {
<></>
)}
</Flex>
{ user != null && <XpProgressBar user={user} size="4rem" /> }
</div>
</Flex>
</Card>
Expand Down

0 comments on commit 9cb766b

Please sign in to comment.