fix motd on mobile and format the player counts
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 55s

This commit is contained in:
Lee 2024-04-16 21:50:08 +01:00
parent 2824bb5878
commit e1ebccd5b7
8 changed files with 32 additions and 15 deletions

@ -57,8 +57,8 @@ export default async function Page({ params }: Params): Promise<JSX.Element> {
<Card> <Card>
{player == null && <NotFound message="Invalid UUID / Username" />} {player == null && <NotFound message="Invalid UUID / Username" />}
{player != null && ( {player != null && (
<div className="flex gap-4 flex-col md:flex-row"> <div className="flex gap-4 flex-col xs:flex-row">
<div className="flex justify-center md:justify-start"> <div className="flex justify-center xs:justify-start">
<Image <Image
className="w-[96px] h-[96px]" className="w-[96px] h-[96px]"
src={player.skin.parts.head} src={player.skin.parts.head}

@ -2,6 +2,7 @@ import { Card } from "@/app/components/card";
import { NotFound } from "@/app/components/not-found"; import { NotFound } from "@/app/components/not-found";
import { LookupServer } from "@/app/components/server/lookup-server"; import { LookupServer } from "@/app/components/server/lookup-server";
import { generateEmbed } from "@/common/embed"; import { generateEmbed } from "@/common/embed";
import { formatNumber } from "@/common/number-utils";
import { capitalizeFirstLetter } from "@/common/string-utils"; import { capitalizeFirstLetter } from "@/common/string-utils";
import { getServer } from "mcutils-library"; import { getServer } from "mcutils-library";
import JavaMinecraftServer from "mcutils-library/dist/types/server/javaServer"; import JavaMinecraftServer from "mcutils-library/dist/types/server/javaServer";
@ -78,9 +79,9 @@ export default async function Page({ params: { platform, hostname } }: Params):
{server == null && <NotFound message="Server not responding" />} {server == null && <NotFound message="Server not responding" />}
{server != null && ( {server != null && (
<div className="flex gap-4 flex-col"> <div className="flex gap-4 flex-col">
<div className="flex gap-4 flex-col md:flex-row"> <div className="flex gap-4 flex-col xs:flex-row">
{favicon && ( {favicon && (
<div className="flex justify-center md:justify-start"> <div className="flex justify-center xs:justify-start">
<Image <Image
className="w-[64px] h-[64px]" className="w-[64px] h-[64px]"
src={favicon} src={favicon}
@ -96,13 +97,13 @@ export default async function Page({ params: { platform, hostname } }: Params):
<h2 className="text-xl">{server.hostname}</h2> <h2 className="text-xl">{server.hostname}</h2>
<div className="text-primary"> <div className="text-primary">
<p> <p>
Players online: {server.players.online}/{server.players.max} Players online: {formatNumber(server.players.online)}/{formatNumber(server.players.max)}
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<div className="bg-background rounded-lg p-2"> <div className="bg-background rounded-lg p-2 text-sm xs:text-md">
{server.motd.html.map((line, index) => { {server.motd.html.map((line, index) => {
return <p key={index} dangerouslySetInnerHTML={{ __html: line }}></p>; return <p key={index} dangerouslySetInnerHTML={{ __html: line }}></p>;
})} })}

@ -6,7 +6,7 @@ export default function Container({
children: React.ReactNode; children: React.ReactNode;
}>): JSX.Element { }>): JSX.Element {
return ( return (
<div className="z-[9999] m-auto flex h-screen min-h-full flex-col items-center opacity-90 md:max-w-[1200px]"> <div className="z-[9999] m-auto flex h-screen min-h-full flex-col items-center opacity-90 xs:max-w-[1200px]">
<NavBar /> <NavBar />
<div className="w-full flex-1 p-4">{children}</div> <div className="w-full flex-1 p-4">{children}</div>
</div> </div>

@ -18,7 +18,7 @@ export default function NavBar(): JSX.Element {
<div className="bg-secondary w-full rounded-lg flex items-center gap-3 mt-2 bg-opacity-85 h-12"> <div className="bg-secondary w-full rounded-lg flex items-center gap-3 mt-2 bg-opacity-85 h-12">
<div className="flex items-center gap-2 pl-3 pr-3"> <div className="flex items-center gap-2 pl-3 pr-3">
<Logo /> <Logo />
<Link href="/" className="hidden md:block"> <Link href="/" className="hidden xs:block">
<p>Minecraft Utilities</p> <p>Minecraft Utilities</p>
</Link> </Link>
</div> </div>
@ -29,7 +29,7 @@ export default function NavBar(): JSX.Element {
<div className="flex-grow"></div> <div className="flex-grow"></div>
<div className="mr-4 flex items-center gap-2"> <div className="mr-4 flex items-center gap-2">
<div className="hidden md:block"> <div className="hidden xs:block">
<RedirectButton <RedirectButton
title="Star us on Github!" title="Star us on Github!"
url="https://github.com/RealFascinated/minecraft-helper" url="https://github.com/RealFascinated/minecraft-helper"

@ -30,7 +30,7 @@ export function LookupPlayer(): JSX.Element {
return ( return (
<form className="flex gap-2 justify-center mt-2"> <form className="flex gap-2 justify-center mt-2">
<Input className="w-fit" placeholder="UUID / Username" value={player} onChange={setPlayerValue} /> <Input className="w-fit" placeholder="UUID / Username" value={player} onChange={setPlayerValue} maxLength={36} />
<Button type="submit" onClick={() => lookupPlayer()}> <Button type="submit" onClick={() => lookupPlayer()}>
Lookup Lookup
</Button> </Button>

@ -32,10 +32,12 @@ export function LookupServer(): JSX.Element {
}; };
return ( return (
<form className="flex gap-2 justify-center mt-2"> <form className="flex gap-2 justify-center items-center mt-2 flex-col xs:flex-row">
<Input className="w-fit" placeholder="Hostname" value={hostname} onChange={setHostnameValue} /> <Input className="w-fit" placeholder="Hostname" value={hostname} onChange={setHostnameValue} maxLength={128} />
<div className="flex gap-2 justify-center">
<Button onClick={() => lookupServer(ServerPlatform.Java)}>Java</Button> <Button onClick={() => lookupServer(ServerPlatform.Java)}>Java</Button>
<Button onClick={() => lookupServer(ServerPlatform.Bedrock)}>Bedrock</Button> <Button onClick={() => lookupServer(ServerPlatform.Bedrock)}>Bedrock</Button>
</div>
</form> </form>
); );
} }

@ -0,0 +1,9 @@
/**
* Formats a number using the browser's locale
*
* @param number the number to format
* @returns the formatted number
*/
export function formatNumber(number: number): string {
return new Intl.NumberFormat().format(number);
}

@ -1,4 +1,5 @@
import type { Config } from "tailwindcss"; import type { Config } from "tailwindcss";
import defaultTheme from "tailwindcss/defaultTheme";
const config = { const config = {
darkMode: ["class"], darkMode: ["class"],
@ -9,10 +10,14 @@ const config = {
center: true, center: true,
padding: "2rem", padding: "2rem",
screens: { screens: {
"2xl": "1400px", xs: "475px",
...defaultTheme.screens,
}, },
}, },
extend: { extend: {
screens: {
xs: "475px",
},
colors: { colors: {
border: "hsl(var(--border))", border: "hsl(var(--border))",
input: "hsl(var(--input))", input: "hsl(var(--input))",