mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 05:41:09 +02:00
Nine files (8 ListViews + todo's TaskList) reimplemented the same context-menu state machinery character-for-character: a typed $state object with visible/x/y/<itemKey>, a handleItemContextMenu function that calls preventDefault and stuffs the click position in, and a close handler that resets the entity field. Extract `useItemContextMenu<T>()` in $lib/data/item-context-menu.svelte that returns a reactive handle with `.state` (visible/x/y/target), `.open(e, target)`, and `.close()`. Consumers derive their menu items from `ctxMenu.state.target` and pass `ctxMenu.close` directly to <ContextMenu onClose>. Per file: ~10 LOC of state declaration + handler removed; consumer items array switches from `ctxMenu.<entity>` to `ctxMenu.state.target`. Across the 9 files this is ~−90 LOC of pure boilerplate; helper itself is 50 LOC. Net small (~−40 LOC) but the boilerplate is gone and the shape is one helper away from being adjustable globally. Note: shared-ui already exports a `createContextMenuState` factory, but it's a plain default-value object — not a Svelte 5 reactive helper. This new wrapper composes with the existing `ContextMenuState<T>` type from shared-ui rather than replacing it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| api | ||
| calc/packages/shared | ||
| calendar | ||
| cards | ||
| chat | ||
| citycorners | ||
| contacts | ||
| context | ||
| docs | ||
| guides | ||
| inventar | ||
| mana | ||
| manavoxel | ||
| memoro | ||
| moodlit | ||
| mukke | ||
| news | ||
| nutriphi | ||
| photos | ||
| picture | ||
| planta | ||
| presi | ||
| questions | ||
| skilltree | ||
| storage | ||
| times | ||
| todo | ||
| traces | ||
| uload | ||
| zitare/packages/content | ||