[PR #101] [CLOSED] feat(game): lockable draggable HUD panels + layout/drag-lag fixes #4464

Closed
opened 2026-10-22 04:07:49 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/101
Author: @LukaTheHero
Created: 4/19/2026
Status: ❌ Closed

Base: main ← Head: feat/game-hud-lock-drag


📝 Commits (1)

  • 5514533 feat(game): lockable draggable HUD panels + fix column reshuffle/drag lag

📊 Changes

4 files changed (+160 additions, -18 deletions)

View changed files

➕ packages/client/src/components/game/DraggablePanel.tsx (+104 -0)
📝 packages/client/src/components/game/GameMap.tsx (+28 -6)
📝 packages/client/src/components/game/GameSurface.tsx (+2 -5)
📝 packages/client/src/components/game/GameWidgetPanel.tsx (+26 -7)

📄 Description

Summary

  • Adds a small lock icon next to the collapse toggle on every Game Mode HUD panel (map, Bonds, Leads, Mana Stability, Exposure Risk). Panels are locked by default; clicking the lock swaps it to an open padlock, draws a faint ring around the card, and makes it free-draggable via framer-motion. Lock state and {x, y} position persist per panel in localStorage under marinara-game-panel:*.
  • Fixes a pre-existing layout bug where expanding a widget on one side visibly shifted the panels on the opposite column.
  • Fixes drag feeling laggy / non-smooth on widget cards.

What changed

New: packages/client/src/components/game/DraggablePanel.tsx

  • useDraggablePanel(id) hook — returns { locked, toggleLocked, x, y, handleDragEnd } backed by motion values and localStorage.
  • PanelLockButton — lucide Lock/Unlock toggle styled to match the existing text-white/30 hover:text-white/70 chevron/collapse indicators, with stopPropagation so it doesn't fire the header's collapse click.

Updated: GameWidgetPanel.tsx, GameMap.tsx

  • WidgetCard and GameMapPanel render as motion.div with drag={!locked}, dragMomentum={false}, dragElastic={0}.
  • Header <button>s became role="button" divs so the lock toggle can nest without invalid HTML, while preserving keyboard (Enter/Space) toggle behavior.
  • Map card styling (w-52, border, bg, shadow, blur) moved from the GameSurface wrapper onto GameMapPanel's draggable root, so the whole visual card translates together when dragged.

Updated: GameSurface.tsx

  • HUD flex container: items-start → items-end. The container is anchored at bottom-24 with no fixed height, so under items-start, growing the left column pushed the container's top upward and carried the top-aligned right column up with it. With items-end both columns bottom-align and grow independently upward.
  • Removed the now-duplicated map card classes (width/border/bg/shadow) from the desktop minimap wrapper; GameMapPanel owns them now.

Drag lag fix: WidgetCard previously used transition-all, which made the browser tween every transform update framer-motion pushed during drag. Narrowed to transition-colors so only color state animates; transform updates are immediate.

Test plan

  • pnpm check passes (client build + typecheck clean)
  • Manually tested in dev build at http://localhost:7820
    • All five panels (map, Bonds, Leads, Mana Stability, Exposure Risk) show a lock icon and are locked by default
    • Clicking lock → open padlock + ring outline + grab cursor; panel can be dragged anywhere
    • Clicking lock again → re-locks and disables drag
    • Collapse/expand button still works when locked and unlocked
    • Lock state and drag position persist across reload
    • Expanding/collapsing a widget on the left no longer shifts the right column (and vice versa)
    • Dragging is smooth — no visible lag from CSS transitions
  • Map and widgets keep styling consistent with the rest of the HUD

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/101 **Author:** [@LukaTheHero](https://github.com/LukaTheHero) **Created:** 4/19/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `feat/game-hud-lock-drag` --- ### 📝 Commits (1) - [`5514533`](https://github.com/Pasta-Devs/Marinara-Engine/commit/5514533a374ddcf1a22161002b8499e63fa57057) feat(game): lockable draggable HUD panels + fix column reshuffle/drag lag ### 📊 Changes **4 files changed** (+160 additions, -18 deletions) <details> <summary>View changed files</summary> ➕ `packages/client/src/components/game/DraggablePanel.tsx` (+104 -0) 📝 `packages/client/src/components/game/GameMap.tsx` (+28 -6) 📝 `packages/client/src/components/game/GameSurface.tsx` (+2 -5) 📝 `packages/client/src/components/game/GameWidgetPanel.tsx` (+26 -7) </details> ### 📄 Description ## Summary - Adds a small lock icon next to the collapse toggle on every Game Mode HUD panel (map, Bonds, Leads, Mana Stability, Exposure Risk). Panels are locked by default; clicking the lock swaps it to an open padlock, draws a faint ring around the card, and makes it free-draggable via `framer-motion`. Lock state and `{x, y}` position persist per panel in `localStorage` under `marinara-game-panel:*`. - Fixes a pre-existing layout bug where expanding a widget on one side visibly shifted the panels on the opposite column. - Fixes drag feeling laggy / non-smooth on widget cards. ## What changed **New:** `packages/client/src/components/game/DraggablePanel.tsx` - `useDraggablePanel(id)` hook — returns `{ locked, toggleLocked, x, y, handleDragEnd }` backed by motion values and localStorage. - `PanelLockButton` — lucide `Lock`/`Unlock` toggle styled to match the existing `text-white/30 hover:text-white/70` chevron/collapse indicators, with `stopPropagation` so it doesn't fire the header's collapse click. **Updated:** `GameWidgetPanel.tsx`, `GameMap.tsx` - `WidgetCard` and `GameMapPanel` render as `motion.div` with `drag={!locked}`, `dragMomentum={false}`, `dragElastic={0}`. - Header `<button>`s became `role="button"` divs so the lock toggle can nest without invalid HTML, while preserving keyboard (Enter/Space) toggle behavior. - Map card styling (`w-52`, border, bg, shadow, blur) moved from the `GameSurface` wrapper onto `GameMapPanel`'s draggable root, so the whole visual card translates together when dragged. **Updated:** `GameSurface.tsx` - HUD flex container: `items-start` → `items-end`. The container is anchored at `bottom-24` with no fixed height, so under `items-start`, growing the left column pushed the container's top upward and carried the top-aligned right column up with it. With `items-end` both columns bottom-align and grow independently upward. - Removed the now-duplicated map card classes (width/border/bg/shadow) from the desktop minimap wrapper; `GameMapPanel` owns them now. **Drag lag fix:** `WidgetCard` previously used `transition-all`, which made the browser tween every transform update `framer-motion` pushed during drag. Narrowed to `transition-colors` so only color state animates; transform updates are immediate. ## Test plan - [x] `pnpm check` passes (client build + typecheck clean) - [x] Manually tested in dev build at http://localhost:7820 - [x] All five panels (map, Bonds, Leads, Mana Stability, Exposure Risk) show a lock icon and are locked by default - [x] Clicking lock → open padlock + ring outline + grab cursor; panel can be dragged anywhere - [x] Clicking lock again → re-locks and disables drag - [x] Collapse/expand button still works when locked and unlocked - [x] Lock state and drag position persist across reload - [x] Expanding/collapsing a widget on the left no longer shifts the right column (and vice versa) - [x] Dragging is smooth — no visible lag from CSS transitions - [x] Map and widgets keep styling consistent with the rest of the HUD --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:07:49 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#4464
No description provided.