Space Engine-style viewport with cockpit frame, glyph rail, console overlays for orbits/wormhole/decay/reconstitute.
127 lines
4.3 KiB
TypeScript
127 lines
4.3 KiB
TypeScript
import { motion } from "motion/react";
|
|
import type { Snapshot } from "../../api";
|
|
import { formatBytes, formatWhen } from "../../lib/format";
|
|
|
|
export function VaultRing({
|
|
snapshots,
|
|
onSelect,
|
|
onCapture,
|
|
capturing,
|
|
}: {
|
|
snapshots: Snapshot[];
|
|
onSelect: (id: string) => void;
|
|
onCapture?: () => void;
|
|
capturing?: boolean;
|
|
}) {
|
|
const count = Math.max(snapshots.length, 1);
|
|
const radius = 128;
|
|
const tiles = snapshots.slice(0, 16);
|
|
|
|
return (
|
|
<div className="relative h-full w-full flex flex-col items-center justify-center px-4">
|
|
<div className="relative w-full max-w-[min(100vw,420px)] aspect-square flex items-center justify-center">
|
|
<svg
|
|
viewBox="-220 -220 440 440"
|
|
className="w-full h-full drop-shadow-[0_0_40px_rgba(167,139,250,0.12)]"
|
|
role="img"
|
|
aria-label="Orbital vault ring of snapshots"
|
|
>
|
|
<defs>
|
|
<radialGradient id="vaultGlow" cx="50%" cy="50%" r="50%">
|
|
<stop offset="0%" stopColor="#1e2647" stopOpacity="0.9" />
|
|
<stop offset="100%" stopColor="#04050c" stopOpacity="0" />
|
|
</radialGradient>
|
|
</defs>
|
|
<circle cx="0" cy="0" r="200" fill="url(#vaultGlow)" />
|
|
<circle
|
|
cx="0"
|
|
cy="0"
|
|
r={radius + 28}
|
|
fill="none"
|
|
stroke="#2d3a6b"
|
|
strokeWidth="1.5"
|
|
strokeDasharray="6 10"
|
|
opacity="0.7"
|
|
/>
|
|
<motion.circle
|
|
cx="0"
|
|
cy="0"
|
|
r={radius + 28}
|
|
fill="none"
|
|
stroke="#a78bfa"
|
|
strokeWidth="1"
|
|
strokeDasharray="40 200"
|
|
strokeLinecap="round"
|
|
opacity="0.35"
|
|
animate={{ rotate: 360 }}
|
|
transition={{ duration: 90, repeat: Infinity, ease: "linear" }}
|
|
style={{ transformOrigin: "0px 0px" }}
|
|
/>
|
|
<text
|
|
x="0"
|
|
y="-6"
|
|
textAnchor="middle"
|
|
fill="#94a3d4"
|
|
fontSize="13"
|
|
fontWeight="500"
|
|
>
|
|
Vault
|
|
</text>
|
|
<text x="0" y="14" textAnchor="middle" fill="#6b7ab8" fontSize="9">
|
|
{snapshots.length} snapshot{tiles.length === 1 ? "" : "s"}
|
|
</text>
|
|
{tiles.length === 0 && (
|
|
<text x="0" y="50" textAnchor="middle" fill="#6b7ab8" fontSize="10">
|
|
Capture your first orbit
|
|
</text>
|
|
)}
|
|
{tiles.map((snap, i) => {
|
|
const angle = (i / Math.max(count, tiles.length)) * Math.PI * 2 - Math.PI / 2;
|
|
const x = Math.cos(angle) * radius;
|
|
const y = Math.sin(angle) * radius;
|
|
return (
|
|
<motion.g
|
|
key={snap.id}
|
|
initial={{ scale: 0, opacity: 0 }}
|
|
animate={{ scale: 1, opacity: 1 }}
|
|
transition={{ delay: i * 0.04 }}
|
|
style={{ cursor: "pointer" }}
|
|
onClick={() => onSelect(snap.id)}
|
|
>
|
|
<circle cx={x} cy={y} r="22" fill="#141a36" stroke="#4ade9a" strokeWidth="2" />
|
|
<circle cx={x} cy={y} r="14" fill="#1e2647" opacity="0.8" />
|
|
<title>
|
|
{snap.orbit_name} · {formatWhen(snap.taken_at)}
|
|
</title>
|
|
</motion.g>
|
|
);
|
|
})}
|
|
</svg>
|
|
</div>
|
|
{onCapture && (
|
|
<motion.button
|
|
type="button"
|
|
disabled={capturing}
|
|
onClick={onCapture}
|
|
className="mt-2 px-6 py-3 rounded-full bg-orbit-green/20 border border-orbit-green/45 text-orbit-green font-medium text-sm disabled:opacity-50"
|
|
whileTap={{ scale: 0.96 }}
|
|
>
|
|
{capturing ? "Orbit in progress…" : "Capture now"}
|
|
</motion.button>
|
|
)}
|
|
<p className="mt-2 text-[10px] font-mono text-star-400/80 max-w-xs text-center uppercase tracking-wider">
|
|
Select tile · stardust delta only
|
|
</p>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export function SnapshotSummaryRow({ snap }: { snap: Snapshot }) {
|
|
return (
|
|
<div className="flex justify-between text-sm py-2 border-b border-space-700/50">
|
|
<span className="text-star-200">{snap.orbit_name}</span>
|
|
<span className="text-star-400 text-xs">{formatBytes(snap.size_bytes)}</span>
|
|
</div>
|
|
);
|
|
}
|