Loading files
05241c15dThis file is pinned to the selected release. Download the original to open it in your design tool.
"use client";
import { useCallback, useEffect, useState } from "react";
import { createPortal } from "react-dom";
/**
* Top-right "HELP" button + an explainer modal (what ARMCADE is / how to drive the arm).
*
* Deliberately NOT a native <dialog>: the arcade UI nests several `fixed inset-0` +
* `pointer-events-none` overlay layers, and a top-layer <dialog> fought them (rendered behind
* content, click-through, centering quirks). Instead this is a plain state-driven modal portaled to
* <body>, so it escapes every parent stacking context and pointer-events rule. Closes on the ✕, an
* overlay (outside-panel) click, or Escape.
*/
export function HelpDialog() {
const [open, setOpen] = useState(false);
const close = useCallback(() => setOpen(false), []);
// Escape to close + lock background scroll while open
useEffect(() => {
if (!open) return;
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") setOpen(false);
};
window.addEventListener("keydown", onKey);
const prevOverflow = document.body.style.overflow;
document.body.style.overflow = "hidden";
return () => {
window.removeEventListener("keydown", onKey);
document.body.style.overflow = prevOverflow;
};
}, [open]);
return (
<>
<button
type="button"
onClick={() => setOpen(true)}
aria-label="Help"
aria-haspopup="dialog"
aria-expanded={open}
className="pointer-events-auto flex h-6 w-6 items-center justify-center rounded-md border border-neon-cyan/70 bg-black/40 font-pixel text-[10px] text-neon-cyan neon-text-soft transition-colors hover:bg-neon-cyan/15 sm:h-7 sm:w-7 sm:text-xs"
>
?
</button>
{open &&
typeof document !== "undefined" &&
createPortal(
<div
role="dialog"
aria-modal="true"
aria-labelledby="help-title"
onClick={close}
className="fixed inset-0 z-[200] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm"
>
{/* panel — stop propagation so clicks inside don't hit the overlay's close handler */}
<div
onClick={(e) => e.stopPropagation()}
className="flex max-h-[85vh] w-full max-w-[560px] flex-col overflow-hidden rounded-2xl border-2 border-neon-cyan bg-cab-900 text-white/90 shadow-2xl"
>
<header className="flex shrink-0 items-center justify-between border-b border-cab-600/70 px-5 py-3 sm:px-6">
<h2 id="help-title" className="font-pixel text-sm text-neon-cyan neon-text sm:text-base">
ARMCADE — HELP
</h2>
<button
type="button"
onClick={close}
aria-label="Close help"
className="flex h-8 w-8 items-center justify-center rounded-md border border-cab-500 text-neon-magenta transition-colors hover:bg-neon-magenta/15 sm:h-9 sm:w-9"
>
<svg viewBox="0 0 20 20" className="h-4 w-4" aria-hidden="true">
<path d="M4 4l12 12M16 4L4 16" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
</svg>
</button>
</header>
<div className="min-h-0 flex-1 overflow-y-auto px-5 py-4 font-terminal text-base leading-relaxed sm:px-6 sm:text-lg">
<section>
<h3 className="font-pixel text-[11px] uppercase tracking-wider text-neon-amber neon-text-soft sm:text-xs">
What is this?
</h3>
<p className="mt-2">
ARMCADE.TV is a remote-controlled robot arcade. A real robot arm sits in a studio
in New York — anyone with a browser can join the queue and drive it live. Pick
things up, move them around, put them down. When you're not driving,
you're watching whoever is.
</p>
</section>
<section className="mt-5">
<h3 className="font-pixel text-[11px] uppercase tracking-wider text-neon-amber neon-text-soft sm:text-xs">
How to play
</h3>
<ol className="mt-2 list-decimal space-y-1.5 pl-5">
<li>Tap <span className="text-neon-green">JOIN QUEUE</span> (or <span className="text-neon-green">CONTROL ARM</span> if a robot is free).</li>
<li>When it's your turn, the top of the screen switches to <span className="text-neon-green">YOU'RE IN CONTROL</span> with a 3-minute countdown.</li>
<li>Drive using the on-screen keys or your keyboard.</li>
<li>Stay idle too long and the arm passes to the next player.</li>
</ol>
</section>
<section className="mt-5">
<h3 className="font-pixel text-[11px] uppercase tracking-wider text-neon-amber neon-text-soft sm:text-xs">
Controls
</h3>
<dl className="mt-2 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1.5">
<dt className="text-neon-cyan">Move</dt>
<dd>arrow keys · on-screen D-pad</dd>
<dt className="text-neon-cyan">Lift</dt>
<dd>
<span className="font-mono">'</span> up ·{" "}
<span className="font-mono">.</span> down · on-screen Up / Down
</dd>
<dt className="text-neon-cyan">Gripper</dt>
<dd>
<span className="font-mono">[</span> open ·{" "}
<span className="font-mono">]</span> close · on-screen Open / Close
</dd>
<dt className="text-neon-cyan">Camera</dt>
<dd>tap any camera tile to change your view</dd>
</dl>
</section>
<section className="mt-5">
<h3 className="font-pixel text-[11px] uppercase tracking-wider text-neon-amber neon-text-soft sm:text-xs">
Rules
</h3>
<ul className="mt-2 list-disc space-y-1.5 pl-5">
<li>One driver at a time. If two robots are running they alternate.</li>
<li>Turns cap at 3 minutes. The queue is first-come-first-served.</li>
<li>Don't close the tab while queued — you'll lose your spot.</li>
<li>If the arm gets into a bad state, the studio parks it. You'll see a status banner up top.</li>
</ul>
</section>
{/* CC-BY attribution for the poly.pizza models (cabinet GLB + favicon source) */}
<section className="mt-5 border-t border-cab-600/70 pt-3 text-sm text-white/50">
<p>
Cabinet: <a href="https://poly.pizza/m/GLDkMhiynM" target="_blank" rel="noreferrer" className="underline hover:text-white/80">"Arcade Machine"</a> by dook (CC-BY)
{" · "}
Icon: <a href="https://poly.pizza/m/9HIzs__db3k" target="_blank" rel="noreferrer" className="underline hover:text-white/80">"Robot"</a> by Martin Calviello (CC-BY)
{" · "}
Music: "Retro Game Music Pack" by Juhani Junkala (CC0)
</p>
</section>
</div>
</div>
</div>,
document.body,
)}
</>
);
}