Renamed files
This commit is contained in:
@@ -1,21 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { DEVUUIDS } from "@/data/general"
|
||||
import { Tooltip } from "react-tooltip"
|
||||
import DeveloperBadge from "../svgs/developer-badge"
|
||||
|
||||
export function DevBadge({ uuid, size }: { uuid: string, size?: number }) {
|
||||
if (!DEVUUIDS.includes(uuid)) return null
|
||||
|
||||
return (
|
||||
<>
|
||||
<DeveloperBadge
|
||||
data-id="dev-badge"
|
||||
data-tooltip-id="dev-badge"
|
||||
data-tooltip-content="Developer"
|
||||
size={size}
|
||||
/>
|
||||
<Tooltip id="dev-badge" />
|
||||
</>
|
||||
)
|
||||
}
|
||||
@@ -1,197 +0,0 @@
|
||||
import { getColor } from "@/lib/colors"
|
||||
import { head } from "@/lib/hypixel/general"
|
||||
import { Player } from "@/lib/schema/player"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
import { DevBadge } from "./badge"
|
||||
import { OnlineStatus } from "./online-status"
|
||||
|
||||
type NewPackageRank = Player["player"]["newPackageRank"]
|
||||
type MonthlyPackageRank = Player["player"]["monthlyPackageRank"]
|
||||
type RankColor = Player["player"]["monthlyRankColor"]
|
||||
|
||||
export default function DisplayName(
|
||||
{ ign, uuid, rank, monthly, rankColor, plusColor, guildTag, tagColor, specialRank, lastLogin, lastLogout, prefix }: {
|
||||
ign: string
|
||||
uuid: string
|
||||
rank: NewPackageRank
|
||||
monthly: MonthlyPackageRank
|
||||
rankColor: RankColor
|
||||
plusColor: string | undefined
|
||||
guildTag: string | undefined
|
||||
tagColor: string | undefined
|
||||
specialRank: string | undefined
|
||||
lastLogin: number | undefined
|
||||
lastLogout: number | undefined
|
||||
prefix: string | undefined
|
||||
}
|
||||
) {
|
||||
return (
|
||||
<div className="flex gap-2 items-center">
|
||||
<DevBadge uuid={uuid} size={40} />
|
||||
<Link href={`https://namemc.com/profile/${uuid}`}>
|
||||
<Image
|
||||
src={head(uuid, 40)}
|
||||
width={40}
|
||||
height={40}
|
||||
alt={ign}
|
||||
unoptimized
|
||||
className="shadow-2xl"
|
||||
/>
|
||||
</Link>
|
||||
<h1 className="font-bold sm:text-xl md:text-3xl text-md text-stroke text-stroke-foreground dark:text-stroke-transparent">
|
||||
<PlayerRank rank={rank} monthly={monthly} plusColor={plusColor} rankColor={rankColor} specialRank={specialRank} prefix={prefix} />
|
||||
{" "}
|
||||
<PlayerIGN ign={ign} rank={rank} monthly={monthly} rankColor={rankColor} specialRank={specialRank} prefix={prefix} />{" "}
|
||||
<GuildTag tag={guildTag} tagColor={tagColor} ign={ign} />
|
||||
</h1>
|
||||
<OnlineStatus lastLogin={lastLogin} lastLogout={lastLogout} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function PlayerIGN(
|
||||
{ ign, rank, monthly, rankColor, specialRank, prefix }: {
|
||||
ign: string
|
||||
rank: NewPackageRank
|
||||
monthly: MonthlyPackageRank
|
||||
rankColor: RankColor
|
||||
specialRank: string | undefined
|
||||
prefix: string | undefined
|
||||
}
|
||||
) {
|
||||
if (prefix === "[PIG+++]") {
|
||||
return <span className="text-mc-light-purple">{ign}</span>
|
||||
}
|
||||
|
||||
if (specialRank) {
|
||||
if (specialRank === "YOUTUBER") {
|
||||
return <span className="text-mc-red">{ign}</span>
|
||||
}
|
||||
|
||||
if (specialRank === "STAFF") {
|
||||
return <span className="text-mc-red">{ign}</span>
|
||||
}
|
||||
}
|
||||
|
||||
if (monthly === "SUPERSTAR") {
|
||||
if (rankColor === "GOLD") {
|
||||
return <span className="text-mc-gold">{ign}</span>
|
||||
} else {
|
||||
return <span className="text-mc-aqua">{ign}</span>
|
||||
}
|
||||
}
|
||||
|
||||
switch (rank) {
|
||||
case "VIP":
|
||||
return <span className="text-mc-green">{ign}</span>
|
||||
case "VIP_PLUS":
|
||||
return <span className="text-mc-green">{ign}</span>
|
||||
case "MVP":
|
||||
return <span className="text-mc-aqua">{ign}</span>
|
||||
case "MVP_PLUS":
|
||||
return <span className="text-mc-aqua">{ign}</span>
|
||||
default:
|
||||
return <span className="text-mc-gray">{ign}</span>
|
||||
}
|
||||
}
|
||||
|
||||
function PlayerRank(
|
||||
{ rank, monthly, plusColor, rankColor, specialRank, prefix }: {
|
||||
rank: NewPackageRank
|
||||
monthly: MonthlyPackageRank
|
||||
plusColor?: string
|
||||
rankColor: RankColor
|
||||
specialRank: string | undefined
|
||||
prefix: string | undefined
|
||||
}
|
||||
) {
|
||||
if (prefix === "[PIG+++]") {
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-light-purple">[PIG</span>
|
||||
<span className="text-mc-aqua">+++</span>
|
||||
<span className="text-mc-light-purple">]</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
if (specialRank) {
|
||||
if (specialRank === "YOUTUBER") {
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-red">[</span>
|
||||
<span className="text-mc-white">YOUTUBE</span>
|
||||
<span className="text-mc-red">]</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
if (specialRank === "STAFF") {
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-red">[</span>
|
||||
<span className="text-mc-gold">ዞ</span>
|
||||
<span className="text-mc-red">]</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (monthly === "SUPERSTAR") {
|
||||
if (rankColor === "GOLD") {
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-gold">[MVP</span>
|
||||
<span className={getColor(plusColor)}>++</span>
|
||||
<span className="text-mc-gold">]</span>
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-aqua">[MVP</span>
|
||||
<span className={getColor(plusColor)}>++</span>
|
||||
<span className="text-mc-aqua">]</span>
|
||||
</>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
switch (rank) {
|
||||
case "VIP":
|
||||
return <span className="text-mc-green">[VIP]</span>
|
||||
case "VIP_PLUS":
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-green">[VIP</span>
|
||||
<span className="text-mc-gold">+</span>
|
||||
<span className="text-mc-green">]</span>
|
||||
</>
|
||||
)
|
||||
case "MVP":
|
||||
return <span className="text-mc-aqua">[MVP]</span>
|
||||
case "MVP_PLUS":
|
||||
return (
|
||||
<>
|
||||
<span className="text-mc-aqua">[MVP</span>
|
||||
<span className={getColor(plusColor)}>+</span>
|
||||
<span className="text-mc-aqua">]</span>
|
||||
</>
|
||||
)
|
||||
default:
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
function GuildTag({ tag, tagColor, ign }: { tag?: string, tagColor?: string, ign: string }) {
|
||||
if (!tag) return null
|
||||
|
||||
const color = getColor(tagColor, "text", "gray")
|
||||
|
||||
return (
|
||||
<Link href={`/guild/${ign}`}>
|
||||
<span className={color}>[{tag}]</span>
|
||||
</Link>
|
||||
)
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { formatRelativeTime } from "@/lib/formatters"
|
||||
import { Wifi, WifiOff } from "lucide-react"
|
||||
import { useEffect, useState } from "react"
|
||||
import { Tooltip } from "react-tooltip"
|
||||
|
||||
export function OnlineStatus({ lastLogin, lastLogout }: { lastLogin: number | undefined, lastLogout: number | undefined }) {
|
||||
const [pos, setPos] = useState({ x: 0, y: 0 })
|
||||
const size = 36
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController()
|
||||
|
||||
window.addEventListener("mousemove", (e) => {
|
||||
if (!(e.target instanceof SVGElement)) return
|
||||
if (e.target.dataset.id !== "online-status") return
|
||||
|
||||
setPos({ x: e.clientX, y: e.clientY - 10 })
|
||||
}, { signal: controller.signal })
|
||||
|
||||
return () => {
|
||||
controller.abort()
|
||||
}
|
||||
})
|
||||
return (
|
||||
<>
|
||||
<OnlineIcon lastLogout={lastLogout} lastLogin={lastLogin} size={size} />
|
||||
<Tooltip id="online-status" position={pos} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
function OnlineIcon({ lastLogout, lastLogin, size }: { lastLogout?: number, lastLogin?: number, size: number }) {
|
||||
if (!lastLogout || !lastLogin) {
|
||||
return (
|
||||
<>
|
||||
<WifiOff
|
||||
data-id="online-status"
|
||||
data-tooltip-id="online-status"
|
||||
data-tooltip-content="Offline. Player is most likely in status offline or a staff with api off."
|
||||
suppressHydrationWarning
|
||||
className="text-mc-gray"
|
||||
size={size}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
if (lastLogout > lastLogin) {
|
||||
return (
|
||||
<>
|
||||
<WifiOff
|
||||
data-id="online-status"
|
||||
data-tooltip-id="online-status"
|
||||
data-tooltip-content={`Offline. Last seen online ${formatRelativeTime(lastLogout, "past")}`}
|
||||
suppressHydrationWarning
|
||||
className="text-mc-gray"
|
||||
size={size}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Wifi
|
||||
data-id="online-status"
|
||||
data-tooltip-id="online-status"
|
||||
data-tooltip-content={`Online. Online for ${formatRelativeTime(lastLogin, "future")}`}
|
||||
suppressHydrationWarning
|
||||
className="text-mc-green"
|
||||
size={size}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user