feat(ui): error & state UX — error surface, view states, map selection, sheet gestures (F4)
Tests · UI / test (push) Waiting to run
Tests · UI / test (pull_request) Failing after 7m13s

- lib/error/: classify any caught error into a stable ErrorKind from the
  transport signal (HTTP status / Connect Code / fetch TypeError /
  navigator.onLine); map to translated error.* messages via reportError
  (sticky Retry toast for retryable kinds) or errorMessageKey (inline).
  Mail compose now surfaces the translated 403/error inline.
- lib/ui/view-state.svelte: shared loading/empty/error placeholder with
  the right live-region role + optional action; entity tables
  (races/sciences/ship-classes) migrated, rest adopt incrementally.
- map/selection-ring.ts: accent ring around the selected planet, fed into
  the map buildExtras alongside the reach circles.
- lib/ui/sheet-dismiss.ts: tap-outside + drag-handle swipe-down dismissal
  for the planet/ship-group bottom-sheets (hand-rolled pointer events).

Tests: error, view-state, selection-ring, sheet-dismiss (761 total).
Docs: ui/docs/error-state-ux.md (+ index); F4 marked done.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilia Denisov
2026-05-22 13:29:11 +02:00
parent 87d524fb89
commit 8dcaf1c6c6
22 changed files with 788 additions and 37 deletions
+36
View File
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import {
computeSelectionRing,
SELECTION_RING_COLOR,
SELECTION_RING_ID,
} from "../src/map/selection-ring";
const planets = [
{ number: 1, x: 10, y: 20 },
{ number: 2, x: 30, y: 40 },
];
describe("computeSelectionRing", () => {
it("returns null when nothing is selected", () => {
expect(computeSelectionRing(planets, null)).toBeNull();
});
it("returns null when the selected planet is absent from the report", () => {
expect(computeSelectionRing(planets, 99)).toBeNull();
});
it("rings the selected planet at its coordinates", () => {
const ring = computeSelectionRing(planets, 2);
expect(ring).toMatchObject({
kind: "circle",
id: SELECTION_RING_ID,
x: 30,
y: 40,
hitSlopPx: 0,
});
expect(ring?.style.strokeColor).toBe(SELECTION_RING_COLOR);
// Sits outside the planet marker (radius 6 world units).
expect(ring?.radius ?? 0).toBeGreaterThan(6);
});
});