From b978bc14df07b70e1dbb9303848c76769dd5f170 Mon Sep 17 00:00:00 2001 From: Liam Date: Thu, 18 Apr 2024 02:31:52 +0100 Subject: [PATCH] add more stats and add a tooltip to them --- src/app/(pages)/page.tsx | 12 ++++---- src/app/components/container.tsx | 2 +- src/app/components/player/lookup-player.tsx | 4 +-- src/app/components/server/lookup-server.tsx | 2 +- src/app/components/stats.tsx | 34 ++++++++++++++++++--- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/src/app/(pages)/page.tsx b/src/app/(pages)/page.tsx index 4c2cd11..71bd8b0 100644 --- a/src/app/(pages)/page.tsx +++ b/src/app/(pages)/page.tsx @@ -1,9 +1,9 @@ -import Link from "next/link"; -import { Button } from "../components/ui/button"; -import { Tooltip, TooltipContent, TooltipTrigger } from "../components/ui/tooltip"; -import { Separator } from "../components/ui/separator"; -import { ReactElement } from "react"; import { Stats } from "@/app/components/stats"; +import Link from "next/link"; +import { ReactElement } from "react"; +import { Button } from "../components/ui/button"; +import { Separator } from "../components/ui/separator"; +import { Tooltip, TooltipContent, TooltipTrigger } from "../components/ui/tooltip"; type Button = { title: string; @@ -29,7 +29,7 @@ const buttons: Button[] = [ export default function Home(): ReactElement { return ( -
+

Minecraft Utilities

diff --git a/src/app/components/container.tsx b/src/app/components/container.tsx index 99b5b6a..9a93be8 100644 --- a/src/app/components/container.tsx +++ b/src/app/components/container.tsx @@ -8,7 +8,7 @@ export default function Container({ return (
-
{children}
+
{children}
); } diff --git a/src/app/components/player/lookup-player.tsx b/src/app/components/player/lookup-player.tsx index d62b55e..cc845a2 100644 --- a/src/app/components/player/lookup-player.tsx +++ b/src/app/components/player/lookup-player.tsx @@ -37,14 +37,14 @@ export function LookupPlayer(): JSX.Element { }; return ( -
event.preventDefault()}> + event.preventDefault()}> { + onChange={event => { setId(event.target.value); }} maxLength={36} diff --git a/src/app/components/server/lookup-server.tsx b/src/app/components/server/lookup-server.tsx index 8c9745a..eb12e86 100644 --- a/src/app/components/server/lookup-server.tsx +++ b/src/app/components/server/lookup-server.tsx @@ -68,7 +68,7 @@ export function LookupServer(): JSX.Element { event.preventDefault()} + onSubmit={event => event.preventDefault()} > , + }, + { + id: "totalPlayerLookups", + displayName: "Player Lookups", + tooltip: "The total amount of player lookups", + icon: , + }, + { + id: "totalServerLookups", + displayName: "Server Lookups", + tooltip: "The total amount of server lookups", icon: , }, ]; export function Stats(): ReactElement { - const { lastMessage, readyState } = useWebSocket("wss://api.mcutils.xyz/websocket/metrics"); + const { lastMessage } = useWebSocket("wss://api.mcutils.xyz/websocket/metrics"); const metrics = lastMessage !== null ? JSON.parse(lastMessage.data).metrics : undefined; return ( - <> +
{stats.map((stat, index) => { const value = metrics ? metrics[stat.id] : "???"; - return ; + return ( + + + + + +

{stat.tooltip}

+
+
+ ); })} - +
); }