Updated site

This commit is contained in:
2025-09-01 00:00:44 +02:00
parent 3b15ba9214
commit 6cf2f2eea1
9 changed files with 263 additions and 9 deletions

View File

@@ -2,9 +2,57 @@
import { getHeads } from "@/lib/hypixel/skywars/skywars"
import { cn } from "@/lib/utils"
import Image from "next/image"
import Link from "next/link"
import { useEffect, useState } from "react"
import { Tooltip } from "react-tooltip"
export function PresigeousHeads({ heads }: { heads: { name: string | null, timestamp: number, sacrifice: string }[] }) {
const [pos, setPos] = useState({ x: 0, y: 0 })
useEffect(() => {
const controller = new AbortController()
window.addEventListener("mousemove", (e) => {
if (!(e.target instanceof HTMLImageElement)) return
if (e.target.dataset.id !== "presigeous-heads") return
setPos({ x: e.clientX, y: e.clientY - 10 })
}, { signal: controller.signal })
return () => {
controller.abort()
}
})
return (
<div className="flex flex-wrap gap-2">
{heads.map(({ name, sacrifice }, index) => {
if (!name) {
return null
}
const text = sacrifice.at(0) + sacrifice.split("").slice(1, sacrifice.length).join("").toLowerCase()
return (
<Link href={`/player/${name}`} key={index}>
<Image
data-id="presigeous-heads"
data-tooltip-id="presigeous-heads"
data-tooltip-content={text}
src={`https://minotar.net/helm/${name}/24.png`}
width={24}
height={24}
alt={name}
/>
</Link>
)
})}
<Tooltip id="presigeous-heads" position={pos} />
</div>
)
}
export function HeadsBar({ heads, heads_total }: { heads: [string, number][], heads_total: number }) {
const [pos, setPos] = useState({ x: 0, y: 0 })
@@ -25,7 +73,7 @@ export function HeadsBar({ heads, heads_total }: { heads: [string, number][], he
return (
<>
<div className="flex mt-2">
<div className="flex mt-2 mb-4">
{heads.map(([key, total], index) => {
const head = getHeads(key)
const percent = heads_total === 0 ? 0 : total / heads_total

View File

@@ -3,7 +3,7 @@ import { getSkywarsLevel } from "@/lib/hypixel/skywars/level"
import { getPrestigeName, getSkyWarsIcon, getTextColor } from "@/lib/hypixel/skywars/skywars"
import { cn } from "@/lib/utils"
import GenericProgress from "../../_components/GenericProgress"
import { HeadsBar } from "./client"
import { HeadsBar, PresigeousHeads } from "./client"
type SkywarsHeadsProps = {
heads: number
@@ -19,11 +19,13 @@ type SkywarsHeadsProps = {
divine: number
heavenly: number
}
prestigeous: { name: string | null, timestamp: number, sacrifice: string }[]
}
export function SkywarsHeads({
heads,
heads_special
heads_special,
prestigeous
}: SkywarsHeadsProps) {
const total_special = Object.values(heads_special).reduce((a, b) => a + b)
const percentages = {
@@ -49,6 +51,8 @@ export function SkywarsHeads({
<span className="text-mc-gray">{formatNumber(heads)}</span>
</p>
{total_special > 0 && <HeadsBar heads={headsArray} heads_total={heads} />}
<p className="font-bold">Prestigious Head Collection</p>
<PresigeousHeads heads={prestigeous} />
</div>
)
}

View File

@@ -121,6 +121,13 @@ export default function SkyWarsStats(
tasty: stats.heads_tasty,
yucky: stats.heads_yucky
}}
prestigeous={stats.head_collection === undefined ? [] : stats.head_collection.prestigious.map(v => {
return {
name: v.username,
timestamp: v.timestamp,
sacrifice: v.sacrifice
}
})}
/>
</div>
</CollapsibleContent>

View File

@@ -1,3 +1,5 @@
import { ReactScan } from "@/components/ReactScan"
import { ReactNode } from "react"
import "./globals.css"
import ThemeProvider from "@/components/ThemeProvider"
@@ -6,6 +8,7 @@ import { Toaster } from "@/components/ui/sonner"
export default function RootLayout({ children }: Readonly<{ children: ReactNode }>) {
return (
<html lang="en" suppressHydrationWarning>
{process.env.NODE_ENV === "development" && <ReactScan />}
<body className="antialiased">
<ThemeProvider>
{children}

View File

@@ -0,0 +1,14 @@
"use client"
import { JSX, useEffect } from "react"
import { scan } from "react-scan"
export function ReactScan(): JSX.Element {
useEffect(() => {
scan({
enabled: true
})
}, [])
return <></>
}

View File

@@ -258,5 +258,13 @@ export const skywarsStatsSchema = z.looseObject({
heads_succulent: z.number().default(0),
heads_sweet: z.number().default(0),
heads_divine: z.number().default(0),
heads_heavenly: z.number().default(0)
heads_heavenly: z.number().default(0),
head_collection: z.looseObject({
prestigious: z.array(z.object({
username: z.string().nullable(),
timestamp: z.number(),
mode: z.string(),
sacrifice: z.string()
}))
}).optional()
})