summaryrefslogtreecommitdiff
path: root/web/src/lib/ui/MainList.svelte
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2026-11-17 23:12:38 +0100
committerJoel Klinghed <the_jk@spawned.biz>2026-11-17 23:12:38 +0100
commitd64cf3514e5ff1ddb1c7f3ddac9a769db3e7dde0 (patch)
tree781ec9f63220f3c15b309658e9b32ad7d9c70b3a /web/src/lib/ui/MainList.svelte
parent94e2850fb73005f3fb30af8489905e5cdfb6fac5 (diff)
Phase 5: campaign meta, notes, special rules (M5)
Web: - Note rows: create/edit menu (text, 12-swatch palette, player/monster link with per-standee selection, delete) with the reference's create-vs-edit commit semantics; row rendering with target-derived gradient colour, link indent + connector, standee N:/All: prefixes, tap-to-edit; whole-list drag-to-reorder (reorderList); quick per-figure note (setFigureNote) from the status menu - Special monsters: Ice Wraith "Switch Form" (deck == "Ice Wraith" gate), summon mark toggle (round-green/summon standee artwork, standee-nr badges, per-owner grayscale), character summon boxes + AddSummonMenu (class summons gated by level and standee cap, item summons from summons.json) - Ally deck show/hide in the main menu (shouldShowAlliesDeck gate); settings "clear unlocked" + Special Unlocks menu - AddSectionMenu parity: search filter, findNrFromScenarioName numeric ordering, added sections greyed + no-op, #Random Dungeon label - gameData.ts: SummonModel, ClassData.summons, summons() fetch Server: - unlock_special_command_test (last command without a test; ally-deck hide and remove-sanctuary were already covered) PLAN.md: Phase 5 boxes checked, M5 progress-log entry
Diffstat (limited to 'web/src/lib/ui/MainList.svelte')
-rw-r--r--web/src/lib/ui/MainList.svelte107
1 files changed, 89 insertions, 18 deletions
diff --git a/web/src/lib/ui/MainList.svelte b/web/src/lib/ui/MainList.svelte
index f594778..87f83b9 100644
--- a/web/src/lib/ui/MainList.svelte
+++ b/web/src/lib/ui/MainList.svelte
@@ -1,13 +1,13 @@
<!--
The main list (the reference `MainList`/`GameList`): one row per entry of
the server's `currentList`. The reference lays wide screens out as two
- reorderable columns; the web Phase 3 uses a single centred, scrollable
- column (reordering arrives later, if at all).
+ long-press reorderable columns; the web uses a single centred column with
+ drag-to-reorder (the reference `ReorderableWrap` → `reorderList`).
-->
<script lang="ts">
import type { GameSession } from '$lib/state/session';
import { isCharacter, isMonster, isNoteRow } from '$lib/protocol/types';
- import type { MonsterItem } from '$lib/protocol/types';
+ import type { CharacterItem, MonsterItem, NoteRowItem } from '$lib/protocol/types';
import type { CampaignData } from '$lib/data/gameData';
import type { FigureRef } from './StatusMenu.svelte';
import CharacterRow from './CharacterRow.svelte';
@@ -17,37 +17,94 @@
let {
session,
onOpenMenu,
+ onEditNote,
+ onAddSummon,
campaignData,
onOpenAbility,
onZoomAbility
}: {
session: GameSession;
onOpenMenu: (figure: FigureRef) => void;
+ onEditNote: (item: NoteRowItem) => void;
+ onAddSummon: (item: CharacterItem) => void;
campaignData: CampaignData | null;
onOpenAbility: (item: MonsterItem) => void;
onZoomAbility: (item: MonsterItem) => void;
} = $props();
const gameState = session.state;
+ const player = session.player;
+
+ // --- reordering (HTML5 drag & drop, the reference long-press drag) -------
+
+ let dragIndex = $state<number | null>(null);
+ let dropIndex = $state<number | null>(null);
+
+ function onDragStart(e: DragEvent, i: number) {
+ if (!$player) return;
+ dragIndex = i;
+ if (e.dataTransfer) {
+ e.dataTransfer.effectAllowed = 'move';
+ e.dataTransfer.setData('text/plain', String(i));
+ }
+ }
+ function onDragOver(e: DragEvent, i: number) {
+ if (dragIndex == null) return;
+ e.preventDefault();
+ if (e.dataTransfer) e.dataTransfer.dropEffect = 'move';
+ dropIndex = i;
+ }
+ function onDrop() {
+ if (dragIndex != null && dropIndex != null && dragIndex !== dropIndex) {
+ session.command('reorderList', {
+ newIndex: dropIndex,
+ oldIndex: dragIndex
+ });
+ }
+ dragIndex = null;
+ dropIndex = null;
+ }
+ function onDragEnd() {
+ dragIndex = null;
+ dropIndex = null;
+ }
</script>
<div class="list">
{#if $gameState}
- {#each $gameState.currentList as item (item.id)}
- {#if isCharacter(item)}
- <CharacterRow {session} {item} {onOpenMenu} />
- {:else if isMonster(item)}
- <MonsterRow
- {session}
- {item}
- {onOpenMenu}
- {campaignData}
- {onOpenAbility}
- {onZoomAbility}
- />
- {:else if isNoteRow(item)}
- <NoteRow {session} {item} />
- {/if}
+ {#each $gameState.currentList as item, i (item.id)}
+ <div
+ class="list__slot"
+ class:list__slot--drop={dropIndex === i && dragIndex != null && dragIndex !== i}
+ draggable={!!$player}
+ ondragstart={(e) => onDragStart(e, i)}
+ ondragover={(e) => onDragOver(e, i)}
+ ondrop={onDrop}
+ ondragend={onDragEnd}
+ ondragleave={() => {
+ if (dropIndex === i) dropIndex = null;
+ }}
+ >
+ {#if isCharacter(item)}
+ <CharacterRow
+ {session}
+ {item}
+ {onOpenMenu}
+ onAddSummon={() => onAddSummon(item)}
+ />
+ {:else if isMonster(item)}
+ <MonsterRow
+ {session}
+ {item}
+ {onOpenMenu}
+ {campaignData}
+ {onOpenAbility}
+ {onZoomAbility}
+ />
+ {:else if isNoteRow(item)}
+ <NoteRow {session} {item} onEdit={onEditNote} />
+ {/if}
+ </div>
{/each}
{#if $gameState.currentList.length === 0}
<p style="padding: 40px 12px; text-align: center; opacity: 0.7">
@@ -57,3 +114,17 @@
{/if}
{/if}
</div>
+
+<style>
+ .list__slot {
+ width: 100%;
+ }
+ .list__slot--drop {
+ outline: 2px solid #7ec8ff;
+ outline-offset: -2px;
+ border-radius: 6px;
+ }
+ .list__slot:focus-visible {
+ outline: 2px solid #7ec8ff;
+ }
+</style>