Replace play dialog with inline server address field

- Add PlayField with Java/Bedrock edition switcher, read-only address input, and copy button
- Show Add Friend link for Bedrock gamertag
- Remove Play and Donate buttons and footer line from homepage
- Animate server status chip into an expandable panel with spring motion and outside-click/Escape close
This commit is contained in:
anonymousratwastaken 2026-10-24 10:24:37 +01:00
parent 00fc2adf63
commit 9d67dd94d8
3 changed files with 142 additions and 64 deletions

View file

@ -1,17 +1,14 @@
"use client";
import localFont from "next/font/local";
import Link from "next/link";
import { useRef, useState } from "react";
import { Button } from "@/components/ui/button";
import { useRef } from "react";
import { TopBar } from "@/components/top-bar";
import { PlayDialog } from "@/components/play-dialog";
import { PlayField } from "@/components/play-dialog";
import { ServerStatusChip } from "@/components/server-status-chip";
import { GradientShimmer, type GradientShimmerHandle } from "@/components/gradient-shimmer";
const makeSans = localFont({ src: "../../public/font/makesans.ttf" });
export default function Page() {
const [playOpen, setPlayOpen] = useState(false);
const shimmerRef = useRef<GradientShimmerHandle>(null);
return (
<main className="min-h-screen bg-background text-foreground flex flex-col font-mona">
@ -24,20 +21,11 @@ export default function Page() {
</div>
<h1 className={`${makeSans.className} text-4xl md:text-5xl font-extrabold lowercase text-primary tracking-tight leading-none`}>FRG Network</h1>
<p className="text-sm leading-relaxed text-muted-foreground max-w-md mx-auto">A small and fun Minecraft server and surrounding community.</p>
<div className="pt-1 flex justify-center gap-3">
<Button
size="lg"
onClick={() => setPlayOpen(true)}
onMouseEnter={() => shimmerRef.current?.emphasize()}
>
Play
</Button>
<Button size="lg" variant="outline" asChild><Link href="/donate">Donate</Link></Button>
</div>
<p className="text-xs text-muted-foreground/70">Java &amp; Bedrock · frg.network</p>
<div className="pt-1 flex justify-center">
<PlayField onMouseEnter={() => shimmerRef.current?.emphasize()} />
</div>
</div>
</div>
<PlayDialog open={playOpen} onOpenChange={setPlayOpen} />
</main>
);
}

View file

@ -1,7 +1,10 @@
"use client";
import { useState } from "react";
import { CheckIcon, ChevronDownIcon, CopyIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription } from "@/components/ui/dialog";
import { DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from "@/components/ui/input-group";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
export function PlayDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (v: boolean) => void }) {
@ -35,3 +38,58 @@ export function PlayButton({ size = "sm" }: { size?: "sm" | "default" | "lg" })
</>
);
}
const PLATFORMS = {
java: { label: "Java", value: "frg.network", copyLabel: "Copy address", href: undefined, hint: "Multiplayer → Add Server, then paste the address." },
bedrock: { label: "Bedrock", value: "FRG Servers", copyLabel: "Copy gamertag", href: "https://www.xbox.com/en-GB/play/user/FRG%20Servers", hint: "Add this gamertag as an Xbox Live friend, then join via Friends." },
} as const;
type Platform = keyof typeof PLATFORMS;
export function PlayField({ onMouseEnter }: { onMouseEnter?: () => void }) {
const [platform, setPlatform] = useState<Platform>("java");
const [copied, setCopied] = useState(false);
const p = PLATFORMS[platform];
const copy = async () => {
await navigator.clipboard.writeText(p.value);
setCopied(true);
setTimeout(() => setCopied(false), 1500);
};
return (
<div className="w-full max-w-xs space-y-2 text-left">
<div className="rounded-md bg-background">
<InputGroup className="h-10">
<InputGroupAddon align="inline-start">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<InputGroupButton variant="ghost" aria-label="Choose edition" className="font-semibold text-foreground">
{p.label}<ChevronDownIcon />
</InputGroupButton>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuRadioGroup value={platform} onValueChange={(v) => { setPlatform(v as Platform); setCopied(false); }}>
{(Object.keys(PLATFORMS) as Platform[]).map((k) => (
<DropdownMenuRadioItem key={k} value={k}>{PLATFORMS[k].label}</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
</DropdownMenuContent>
</DropdownMenu>
</InputGroupAddon>
<InputGroupInput readOnly value={p.value} aria-label={p.label === "Java" ? "Server address" : "Xbox gamertag"} className="font-mono text-sm" onFocus={(e) => e.currentTarget.select()} />
<InputGroupAddon align="inline-end">
<InputGroupButton variant="ghost" size="icon-xs" aria-label={p.copyLabel} onClick={copy} onMouseEnter={onMouseEnter}>
{copied ? <CheckIcon /> : <CopyIcon />}
</InputGroupButton>
</InputGroupAddon>
</InputGroup>
</div>
{p.href && (
<div className="rounded-md bg-background">
<Button asChild variant="outline" className="w-full" onMouseEnter={onMouseEnter}>
<a href={p.href} target="_blank" rel="noopener noreferrer">Add Friend</a>
</Button>
</div>
)}
<p className="text-center text-xs text-muted-foreground" aria-live="polite">{copied ? "Copied!" : p.hint}</p>
</div>
);
}

View file

@ -1,5 +1,6 @@
"use client";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { motion } from "motion/react";
import type { ServerStatus } from "@/lib/server-status";
const REFRESH_MS = 60_000;
@ -19,6 +20,23 @@ const TEXT = {
export function ServerStatusChip() {
const [status, setStatus] = useState<ServerStatus | null>(null);
const [open, setOpen] = useState(false);
const rootRef = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const onDown = (e: PointerEvent) => {
if (!rootRef.current?.contains(e.target as Node)) setOpen(false);
};
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") setOpen(false);
};
document.addEventListener("pointerdown", onDown);
document.addEventListener("keydown", onKey);
return () => {
document.removeEventListener("pointerdown", onDown);
document.removeEventListener("keydown", onKey);
};
}, [open]);
useEffect(() => {
let cancelled = false;
@ -45,30 +63,42 @@ export function ServerStatusChip() {
: null;
return (
<div className="inline-flex flex-col items-center">
<button
<div ref={rootRef} className="relative h-[26px] w-full">
<div className="absolute inset-x-0 top-0 z-10 flex justify-center">
<motion.div
className="overflow-hidden rounded-[20px] border border-border bg-background/60 backdrop-blur-md text-left shadow-xl shadow-black/0 data-[open=true]:shadow-black/30 data-[open=true]:bg-background/80"
data-open={open}
>
<motion.button
type="button"
onClick={() => setOpen((v) => !v)}
aria-expanded={open}
aria-controls="server-status-panel"
className="inline-flex items-center gap-2 rounded-full border border-border bg-background/60 backdrop-blur-sm px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors"
className="flex w-full items-center gap-2 px-3 py-1 text-xs font-medium text-muted-foreground hover:text-foreground transition-colors whitespace-nowrap"
>
<span className={`inline-flex h-2 w-2 rounded-full ${DOT[state]}`} />
<span>{status ? TEXT[state] : "Checking…"}</span>
{state === "online" && status?.players && (
<span className="text-muted-foreground/70">· {status.players.online} online</span>
)}
</button>
</motion.button>
{open && (
<div
<motion.div
id="server-status-panel"
className="mt-2 w-72 rounded-xl border border-border bg-background/80 backdrop-blur-md p-4 text-left text-sm shadow-xl shadow-black/30"
initial={false}
animate={{ height: open ? "auto" : 0, width: open ? 256 : 0, opacity: open ? 1 : 0 }}
transition={{
height: { type: "spring", stiffness: 420, damping: 38 },
width: { type: "spring", stiffness: 420, damping: 38 },
opacity: { duration: 0.15, delay: open ? 0.08 : 0 },
}}
aria-hidden={!open}
inert={!open}
className="overflow-hidden"
>
<div className="w-64 px-4 pb-4 pt-2">
{status ? (
<dl className="grid grid-cols-[auto_1fr] gap-x-4 gap-y-2 text-xs">
<dt className="text-muted-foreground">Address</dt>
<dd className="font-mono text-foreground">{status.host}</dd>
<dt className="text-muted-foreground">Players</dt>
<dd className="text-foreground">
{state === "online" && status.players ? `${status.players.online} / ${status.players.max}` : "—"}
@ -93,7 +123,9 @@ export function ServerStatusChip() {
: null}
</p>
</div>
)}
</motion.div>
</motion.div>
</div>
</div>
);
}