feat: rebuild the orbital vault as an operational map
This commit is contained in:
@@ -1,89 +1,132 @@
|
||||
import type { ReactNode } from "react";
|
||||
import type { VaultStatus } from "../../lib/format";
|
||||
import { StatusDot } from "../ui/StatusDot";
|
||||
import { formatBytes } from "../../lib/format";
|
||||
import type { Snapshot } from "../../api";
|
||||
|
||||
export function CockpitFrame({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="absolute inset-0 pointer-events-none z-20">
|
||||
<motionBorder />
|
||||
<p className="absolute top-3 left-4 text-[10px] font-mono tracking-[0.35em] text-star-400/80 uppercase">
|
||||
Tessera · orbital vault
|
||||
</p>
|
||||
<p className="absolute top-3 right-4 text-[10px] font-mono text-star-400/60">
|
||||
SYS // VAULT-01
|
||||
</p>
|
||||
<div className="absolute bottom-3 left-4 right-4 h-px bg-gradient-to-r from-transparent via-wormhole-violet/40 to-transparent" />
|
||||
<div className="vignette" />
|
||||
<div className="scanlines" />
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function motionBorder() {
|
||||
return (
|
||||
<>
|
||||
<span className="absolute top-8 left-6 w-12 h-12 border-l-2 border-t-2 border-wormhole-violet/50 rounded-tl" />
|
||||
<span className="absolute top-8 right-6 w-12 h-12 border-r-2 border-t-2 border-wormhole-violet/50 rounded-tr" />
|
||||
<span className="absolute bottom-16 left-6 w-16 h-10 border-l-2 border-b-2 border-star-400/25 rounded-bl" />
|
||||
<span className="absolute bottom-16 right-6 w-16 h-10 border-r-2 border-b-2 border-star-400/25 rounded-br" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
import type { KeyboardEvent, ReactNode } from "react";
|
||||
import type { Orbit, Snapshot } from "../../api";
|
||||
import { formatBytes, formatWhen, orbitStatus, schedulePhrase } from "../../lib/format";
|
||||
|
||||
export function TelemetryStrip({
|
||||
status,
|
||||
online,
|
||||
snapCount,
|
||||
totalBytes,
|
||||
orbitCount, failedCount, snapCount, totalBytes,
|
||||
}: {
|
||||
status: VaultStatus;
|
||||
online: boolean;
|
||||
snapCount: number;
|
||||
orbitCount?: number;
|
||||
failedCount: number;
|
||||
snapCount?: number;
|
||||
totalBytes: number;
|
||||
}) {
|
||||
return (
|
||||
<div className="pointer-events-none absolute top-12 left-4 right-4 flex justify-between items-start gap-2 text-[11px] font-mono">
|
||||
<div className="flex items-center gap-2 bg-space-950/50 backdrop-blur-sm border border-space-700/50 rounded px-2 py-1">
|
||||
<StatusDot status={online ? status : "grey"} size="sm" />
|
||||
<span className="text-star-300">{online ? "LINK OK" : "NO LINK"}</span>
|
||||
</div>
|
||||
<div className="text-right text-star-400/90 bg-space-950/40 px-2 py-1 rounded border border-space-800/40">
|
||||
<div>TILES {snapCount}</div>
|
||||
<div className="text-[10px] opacity-70">{formatBytes(totalBytes)} mass</div>
|
||||
</div>
|
||||
</div>
|
||||
<dl className="vault-telemetry">
|
||||
<div><dt>Orbits</dt><dd>{orbitCount ?? "—"}</dd></div>
|
||||
<div><dt>Failed</dt><dd className={failedCount ? "telemetry-alert" : ""}>{orbitCount === undefined ? "—" : failedCount}</dd></div>
|
||||
<div><dt>Snapshots</dt><dd>{snapCount ?? "—"}</dd></div>
|
||||
<div><dt>Payload</dt><dd>{snapCount === undefined ? "—" : formatBytes(totalBytes)}</dd></div>
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
|
||||
export function SnapshotsMiniList({
|
||||
snapshots,
|
||||
selected,
|
||||
onSelect,
|
||||
export function OrbitRegister({
|
||||
orbits, selected, message, onSelect, onManage,
|
||||
}: {
|
||||
snapshots: Snapshot[];
|
||||
selected: string | null;
|
||||
orbits: Orbit[];
|
||||
selected?: string;
|
||||
message?: string;
|
||||
onSelect: (id: string) => void;
|
||||
onManage: () => void;
|
||||
}) {
|
||||
if (!snapshots.length) return null;
|
||||
const active = orbits.some(({ id }) => id === selected) ? selected : orbits[0]?.id;
|
||||
|
||||
function moveFocus(event: KeyboardEvent<HTMLButtonElement>, index: number) {
|
||||
const next = { ArrowUp: index - 1, ArrowDown: index + 1, Home: 0, End: orbits.length - 1 }[event.key];
|
||||
if (next === undefined) return;
|
||||
event.preventDefault();
|
||||
const target = orbits[Math.min(orbits.length - 1, Math.max(0, next))];
|
||||
onSelect(target.id);
|
||||
document.getElementById(`register-${target.id}`)?.focus();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="pointer-events-auto absolute left-4 bottom-24 max-w-[140px] space-y-1">
|
||||
{snapshots.slice(0, 4).map((s, i) => (
|
||||
<button
|
||||
key={s.id}
|
||||
type="button"
|
||||
onClick={() => onSelect(s.id)}
|
||||
className={`w-full text-left text-[10px] font-mono px-2 py-1 rounded border transition-colors ${
|
||||
selected === s.id
|
||||
? "border-orbit-green/60 bg-orbit-green/10 text-orbit-green"
|
||||
: "border-space-700/50 bg-space-950/60 text-star-400 hover:border-star-400/40"
|
||||
}`}
|
||||
>
|
||||
{String(i + 1).padStart(2, "0")} · {s.orbit_name.slice(0, 12)}
|
||||
<section className="vault-console orbit-register" aria-labelledby="register-title">
|
||||
<header className="console-heading">
|
||||
<p className="instrument-label">Flight register</p>
|
||||
<h2 id="register-title">Orbits</h2>
|
||||
</header>
|
||||
{message && <p className="console-empty" role="status">{message}</p>}
|
||||
<ul className="register-list">
|
||||
{orbits.map((orbit, index) => {
|
||||
const status = orbitStatus(orbit.last_status);
|
||||
return (
|
||||
<li key={orbit.id}>
|
||||
<button
|
||||
type="button"
|
||||
id={`register-${orbit.id}`}
|
||||
className="register-row"
|
||||
aria-pressed={selected === orbit.id}
|
||||
tabIndex={active === orbit.id ? 0 : -1}
|
||||
onClick={() => onSelect(orbit.id)}
|
||||
onKeyDown={(event) => moveFocus(event, index)}
|
||||
>
|
||||
<span className={`register-signal signal-${status.tone}`} aria-hidden="true" />
|
||||
<span className="register-content">
|
||||
<span title={orbit.name}>{orbit.name}</span>
|
||||
<small>{orbit.provider}</small>
|
||||
</span>
|
||||
<span className={`register-state tone-${status.tone}`}>{status.label}</span>
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
<div className="console-bottom">
|
||||
<button type="button" className="console-control" onClick={onManage}>
|
||||
{orbits.length ? "Manage orbits" : "Set up an orbit"} <span aria-hidden="true">↗</span>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export function OrbitInspector({
|
||||
orbit, snapshots, snapshotMessage, capture, onSelectSnapshot,
|
||||
}: {
|
||||
orbit?: Orbit;
|
||||
snapshots: Snapshot[];
|
||||
snapshotMessage?: string;
|
||||
capture?: ReactNode;
|
||||
onSelectSnapshot: (id: string) => void;
|
||||
}) {
|
||||
const status = orbitStatus(orbit?.last_status ?? "idle");
|
||||
return (
|
||||
<section className="vault-console orbit-inspector" aria-labelledby="inspector-title">
|
||||
<header className="console-heading">
|
||||
<p className="instrument-label">Orbit detail</p>
|
||||
<h2 id="inspector-title">{orbit?.name ?? "Select an orbit"}</h2>
|
||||
{orbit && <p className={`inspector-state tone-${status.tone}`}><span className={`register-signal signal-${status.tone}`} />{status.label}</p>}
|
||||
</header>
|
||||
{orbit ? (
|
||||
<>
|
||||
<p className="inspector-schedule">{schedulePhrase(orbit.schedule, orbit.dry_run)}</p>
|
||||
<div className="inspector-capture">{capture}</div>
|
||||
<section className="inspector-history" aria-labelledby="history-title">
|
||||
<header>
|
||||
<h3 id="history-title">Snapshot history</h3>
|
||||
<span>{snapshots.length.toString().padStart(2, "0")}</span>
|
||||
</header>
|
||||
{snapshotMessage && <p className="console-empty" role="status">{snapshotMessage}</p>}
|
||||
<ul>
|
||||
{snapshots.map((snapshot, index) => (
|
||||
<li key={snapshot.id}>
|
||||
<button id={`snapshot-${snapshot.id}`} type="button" className="snapshot-row" onClick={() => onSelectSnapshot(snapshot.id)}>
|
||||
<span className="snapshot-glyph" aria-hidden="true">◇</span>
|
||||
<span>
|
||||
<strong>{formatWhen(snapshot.taken_at)}</strong>
|
||||
<small>{formatBytes(snapshot.size_bytes)}{index === 0 ? " · Latest" : ""}</small>
|
||||
</span>
|
||||
<span className="snapshot-arrow" aria-hidden="true">›</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</>
|
||||
) : (
|
||||
<p className="console-empty">Choose a star on the map or an orbit in the register to inspect its status and recovery points.</p>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,96 +1,54 @@
|
||||
import { motion, AnimatePresence } from "motion/react";
|
||||
import type { ReactNode } from "react";
|
||||
import { useId, useLayoutEffect, useRef, type ReactNode } from "react";
|
||||
|
||||
export function HUDPanel({
|
||||
open,
|
||||
title,
|
||||
subtitle,
|
||||
onClose,
|
||||
children,
|
||||
side = "right",
|
||||
open, title, subtitle, onClose, children,
|
||||
}: {
|
||||
open: boolean;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
onClose: () => void;
|
||||
children: ReactNode;
|
||||
side?: "left" | "right" | "bottom";
|
||||
}) {
|
||||
const pos =
|
||||
side === "left"
|
||||
? "left-0 top-12 bottom-20 w-[min(100%,380px)] border-r"
|
||||
: side === "bottom"
|
||||
? "inset-x-0 bottom-20 top-auto max-h-[55dvh] border-t"
|
||||
: "right-0 top-12 bottom-20 w-[min(100%,400px)] border-l";
|
||||
const dialog = useRef<HTMLDialogElement>(null);
|
||||
const heading = useRef<HTMLHeadingElement>(null);
|
||||
const labelId = useId();
|
||||
const descriptionId = useId();
|
||||
|
||||
useLayoutEffect(() => {
|
||||
const panel = dialog.current;
|
||||
if (!open || !panel) return;
|
||||
panel.showModal();
|
||||
return () => panel.close();
|
||||
}, [open]);
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (open) heading.current?.focus();
|
||||
}, [open, title]);
|
||||
|
||||
return (
|
||||
<AnimatePresence>
|
||||
{open && (
|
||||
<>
|
||||
<motion.button
|
||||
type="button"
|
||||
aria-label="Dismiss overlay"
|
||||
className="fixed inset-0 z-40 bg-space-950/50 backdrop-blur-[2px]"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1 }}
|
||||
exit={{ opacity: 0 }}
|
||||
onClick={onClose}
|
||||
/>
|
||||
<motion.aside
|
||||
className={`fixed z-50 ${pos} border-wormhole-violet/20 bg-space-900/92 backdrop-blur-xl overflow-y-auto scrollbar-none`}
|
||||
initial={{ opacity: 0, x: side === "right" ? 40 : side === "left" ? -40 : 0, y: side === "bottom" ? 40 : 0 }}
|
||||
animate={{ opacity: 1, x: 0, y: 0 }}
|
||||
exit={{ opacity: 0, x: side === "right" ? 20 : 0, y: side === "bottom" ? 20 : 0 }}
|
||||
transition={{ type: "spring", damping: 26, stiffness: 280 }}
|
||||
>
|
||||
<header className="sticky top-0 bg-space-900/95 border-b border-space-700/60 px-4 py-3 flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p className="text-[10px] font-mono text-wormhole-violet tracking-widest uppercase">
|
||||
Console
|
||||
</p>
|
||||
<h2 className="text-lg font-semibold text-star-100">{title}</h2>
|
||||
{subtitle && <p className="text-xs text-star-400 mt-0.5">{subtitle}</p>}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="font-mono text-xs text-star-400 border border-space-700 rounded px-2 py-1 hover:text-star-200"
|
||||
>
|
||||
ESC
|
||||
</button>
|
||||
</header>
|
||||
<div className="p-4 pb-8">{children}</div>
|
||||
</motion.aside>
|
||||
</>
|
||||
)}
|
||||
</AnimatePresence>
|
||||
);
|
||||
}
|
||||
|
||||
export function SceneAction({
|
||||
label,
|
||||
onClick,
|
||||
disabled,
|
||||
variant = "primary",
|
||||
}: {
|
||||
label: string;
|
||||
onClick: () => void;
|
||||
disabled?: boolean;
|
||||
variant?: "primary" | "ghost";
|
||||
}) {
|
||||
return (
|
||||
<motion.button
|
||||
type="button"
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
className={`pointer-events-auto font-mono text-xs tracking-wide px-5 py-2.5 rounded border ${
|
||||
variant === "primary"
|
||||
? "border-orbit-green/50 text-orbit-green bg-orbit-green/10 hover:bg-orbit-green/20"
|
||||
: "border-star-400/30 text-star-300 bg-space-950/60"
|
||||
} disabled:opacity-40`}
|
||||
whileTap={{ scale: 0.97 }}
|
||||
<dialog
|
||||
ref={dialog}
|
||||
className="vault-dialog"
|
||||
aria-labelledby={labelId}
|
||||
aria-describedby={subtitle ? descriptionId : undefined}
|
||||
onCancel={(event) => {
|
||||
event.preventDefault();
|
||||
onClose();
|
||||
}}
|
||||
>
|
||||
{label}
|
||||
</motion.button>
|
||||
{open && (
|
||||
<header className="dialog-heading">
|
||||
<div>
|
||||
<p className="instrument-label">Vault console</p>
|
||||
<h2 id={labelId} ref={heading} tabIndex={-1}>{title}</h2>
|
||||
{subtitle && <p id={descriptionId}>{subtitle}</p>}
|
||||
</div>
|
||||
<button type="button" className="console-control" onClick={onClose}>
|
||||
Close <span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</header>
|
||||
)}
|
||||
<div className="dialog-content">{children}</div>
|
||||
</dialog>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,60 +1,31 @@
|
||||
import { motion } from "motion/react";
|
||||
export type HUDMode = "scene" | "orbits" | "wormhole" | "decay" | "reconstitute" | "snapshot";
|
||||
|
||||
export type HUDMode = "scene" | "orbits" | "wormhole" | "decay" | "reconstitute";
|
||||
|
||||
const items: { id: HUDMode; label: string; glyph: string; hint: string }[] = [
|
||||
{ id: "scene", label: "Viewport", glyph: "◎", hint: "Vault ring" },
|
||||
{ id: "orbits", label: "Orbits", glyph: "⟳", hint: "Flight paths" },
|
||||
{ id: "wormhole", label: "Wormhole", glyph: "◉", hint: "Outpost link" },
|
||||
{ id: "decay", label: "Decay", glyph: "◇", hint: "Fade policy" },
|
||||
{ id: "reconstitute", label: "Restore", glyph: "↩", hint: "Reconstitute" },
|
||||
];
|
||||
const items = [
|
||||
{ id: "scene", label: "Vault" },
|
||||
{ id: "orbits", label: "Orbits" },
|
||||
{ id: "wormhole", label: "Outposts" },
|
||||
{ id: "decay", label: "Retention" },
|
||||
{ id: "reconstitute", label: "Restore" },
|
||||
] as const;
|
||||
|
||||
export function HUDRail({
|
||||
active,
|
||||
onSelect,
|
||||
capturing,
|
||||
active, onSelect,
|
||||
}: {
|
||||
active: HUDMode;
|
||||
onSelect: (m: HUDMode) => void;
|
||||
capturing?: boolean;
|
||||
onSelect: (mode: HUDMode) => void;
|
||||
}) {
|
||||
return (
|
||||
<nav
|
||||
className="pointer-events-auto absolute bottom-6 left-1/2 -translate-x-1/2 z-30 flex gap-1 px-2 py-1.5 rounded-full border border-wormhole-violet/25 bg-space-950/75 backdrop-blur-xl shadow-[0_0_40px_rgba(5,6,15,0.8)]"
|
||||
aria-label="Ship systems"
|
||||
>
|
||||
{items.map((item) => {
|
||||
const on = active === item.id;
|
||||
return (
|
||||
<motion.button
|
||||
key={item.id}
|
||||
type="button"
|
||||
title={item.hint}
|
||||
onClick={() => onSelect(item.id)}
|
||||
className={`relative px-3 py-2 rounded-full text-xs font-mono transition-colors ${
|
||||
on
|
||||
? "text-wormhole-violet bg-wormhole-violet/15"
|
||||
: "text-star-400 hover:text-star-200"
|
||||
}`}
|
||||
whileTap={{ scale: 0.94 }}
|
||||
>
|
||||
<span className="sr-only">{item.label}</span>
|
||||
<span aria-hidden className="text-sm">
|
||||
{item.glyph}
|
||||
</span>
|
||||
{on && (
|
||||
<motion.span
|
||||
layoutId="hud-pip"
|
||||
className="absolute -bottom-1 left-1/2 w-1 h-1 -translate-x-1/2 rounded-full bg-orbit-green"
|
||||
/>
|
||||
)}
|
||||
{item.id === "orbits" && capturing && (
|
||||
<span className="absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-orbit-amber animate-pulse" />
|
||||
)}
|
||||
</motion.button>
|
||||
);
|
||||
})}
|
||||
<nav className="vault-nav" aria-label="Vault systems">
|
||||
{items.map(({ id, label }) => (
|
||||
<button
|
||||
key={id}
|
||||
type="button"
|
||||
onClick={() => onSelect(id)}
|
||||
aria-current={active === id ? "page" : undefined}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user