diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/client.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/client.tsx new file mode 100644 index 0000000..367a85a --- /dev/null +++ b/src/app/(stats)/player/[ign]/_stats/skywars/client.tsx @@ -0,0 +1,56 @@ +"use client" + +import { getHeads } from "@/lib/hypixel/skywars/skywars" +import { cn } from "@/lib/utils" +import { useEffect, useState } from "react" +import { Tooltip } from "react-tooltip" + +export function HeadsBar({ heads, heads_total }: { heads: [string, number][], heads_total: number }) { + const [pos, setPos] = useState({ x: 0, y: 0 }) + + useEffect(() => { + const controller = new AbortController() + + window.addEventListener("mousemove", (e) => { + if (!(e.target instanceof HTMLDivElement)) return + if (e.target.dataset.id !== "heads-bar") return + + setPos({ x: e.clientX, y: e.clientY - 10 }) + }, { signal: controller.signal }) + + return () => { + controller.abort() + } + }) + + return ( + <> +
+ {heads.map(([key, total], index) => { + const head = getHeads(key) + const percent = heads_total === 0 ? 0 : total / heads_total + + return ( +
+
+ ) + })} +
+ + + ) +} diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx index e19e40b..4c1ced1 100644 --- a/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx +++ b/src/app/(stats)/player/[ign]/_stats/skywars/components.tsx @@ -1,8 +1,9 @@ import { formatNumber } from "@/lib/formatters" import { getSkywarsLevel } from "@/lib/hypixel/skywars/level" -import { getHeadsColor, getPrestigeName, getSkyWarsIcon, getTextColor } from "@/lib/hypixel/skywars/skywars" +import { getPrestigeName, getSkyWarsIcon, getTextColor } from "@/lib/hypixel/skywars/skywars" import { cn } from "@/lib/utils" import GenericProgress from "../../_components/GenericProgress" +import { HeadsBar } from "./client" type SkywarsHeadsProps = { heads: number @@ -26,17 +27,17 @@ export function SkywarsHeads({ }: SkywarsHeadsProps) { const total_special = Object.values(heads_special).reduce((a, b) => a + b) const percentages = { - heavenly: heads_special.heavenly / heads, - divine: heads_special.divine / heads, - sweet: heads_special.sweet / heads, - succulent: heads_special.succulent / heads, - tasty: heads_special.tasty / heads, - salty: heads_special.salty / heads, - decent: heads_special.decent / heads, - meh: heads_special.meh / heads, - yucky: heads_special.yucky / heads, - eww: heads_special.eww / heads, - rest: (heads - total_special) / heads + heavenly: heads_special.heavenly, + divine: heads_special.divine, + sweet: heads_special.sweet, + succulent: heads_special.succulent, + tasty: heads_special.tasty, + salty: heads_special.salty, + decent: heads_special.decent, + meh: heads_special.meh, + yucky: heads_special.yucky, + eww: heads_special.eww, + rest: (heads - total_special) } const headsArray = Object.entries(percentages) @@ -47,29 +48,7 @@ export function SkywarsHeads({ {"Total Heads Gathered: "} {formatNumber(heads)}

- {total_special > 0 && ( -
- {headsArray.map(([key, val], index) => { - const color = getHeadsColor(key) - - return ( -
-
- ) - })} -
- )} + {total_special > 0 && } ) } @@ -99,12 +78,12 @@ export function AngelOfDeath( ) } -export function ShardProgress({ percent }: { percent: number }) { +export function ShardProgress({ percent, shards }: { percent: number, shards: number }) { return (

Shard Progress

- +
) diff --git a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx index 7d5d784..c0b9403 100644 --- a/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx +++ b/src/app/(stats)/player/[ign]/_stats/skywars/skywars.tsx @@ -100,7 +100,7 @@ export default function SkyWarsStats(
- + v.id === key)?.color +export function getHeads(key: string) { + const val = HEADS.find(v => v.id === key) if (!val) return null - return val + return { + color: val.color, + name: val.name + } } export function concatSkywarsStats(...stats: SkywarsModeStats[]) {