feat(floor-monitor): Ph1 Access (BASE) — viewport zoom/pan/fit + low-zoom color mode - #380
Conversation
…zoom color mode Item 6 phase 1 on the existing foundation (persisted drag-layout + WS sync + per-table data). The stage transforms; tables keep their persisted posX/posY untouched. - Zoom: wheel (cursor-anchored — the layout point under the cursor stays put), −/+ buttons, clamp 35%..200%, live % readout. - Pan: grab-drag on the empty stage background only — table move-drag keeps working; TableBox drag deltas divide by the live scale so a drag at 50% zoom tracks the cursor 1:1 (and the 20px drag-intent threshold scales too). - Fit: bounding box over the tables → scale + center in the viewport. 1:1 resets. - Low-zoom color mode (<65%): card text collapses to the big table name on the status-colored block — the floor reads as a status map at a glance. Ph2-4 (full-screen MAX gate · per-table modal · decor entity · min-spend /heat/replay) follow as separate slices per the checklist. Tests: FE build 8.04s, vitest 171 passed, hooks-lint 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds zoom and pan controls to the floor plan editor canvas. It introduces viewport state, cursor-centered zoom, background panning, fit-to-tables behavior, drag scaling under zoom, and supporting stage and zoom-bar styling. ChangesFloor Plan Zoom/Pan Viewport
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@frontend/src/admin/pages/restaurant/FloorPlanEditor.jsx`:
- Around line 848-869: The fitToTables useCallback is defined before
mergedTables is initialized, so its dependency reference hits the temporal dead
zone and can throw during render. Move fitToTables below the mergedTables
useMemo in FloorPlanEditor.jsx, and keep the dependency array using mergedTables
after that declaration so the callback is created only after the binding exists.
- Around line 818-822: The viewport zoom handler in onViewportWheel is relying
on a React synthetic wheel event, which cannot reliably prevent native
scrolling. Move the wheel handling to a native listener on viewportRef.current
with passive set to false, keep the existing zoomAt logic and preventDefault
call, and ensure the listener is registered and cleaned up in the
FloorPlanEditor component lifecycle so page scroll is blocked while zooming.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 2e367868-3f34-46ef-b751-4e04dc2c48d4
📒 Files selected for processing (2)
frontend/src/admin/pages/restaurant/FloorPlanEditor.cssfrontend/src/admin/pages/restaurant/FloorPlanEditor.jsx
…on-passive wheel
- fitToTables moved BELOW the mergedTables memo: the useCallback
dependency array is evaluated at definition time, and referencing the
memo binding earlier hits the temporal dead zone → ReferenceError on
every render (esbuild/vitest don't exercise this page, so only runtime
caught it).
- Wheel zoom attached natively with { passive: false } (React 18
synthetic onWheel is passive — preventDefault was a no-op and the page
scrolled while zooming); cleaned up on unmount.
Tests: FE build 8.15s, vitest 171 passed, hooks-lint 0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Summary
Item 6 (Floor Monitor spatial cockpit) Ph1 Access — BASE tier, on the existing foundation (persisted drag-layout + WS sync + spaces + per-table data):
TableBoxdrag deltas divide by the live scale (a drag at 50% zoom tracks the cursor 1:1; the 20px drag-intent threshold scales too).No BE changes, no migration, no packaging gate (Ph1 is BASE per the checklist). Ph2 (full-screen = MAX gate + per-table modal + attention flags + KPI header), Ph3 (decor entity 🗄), Ph4 (min-spend/heat/replay) follow as separate slices.
Mainline Continuity
feat/floor-monitor-ph1offorigin/main(6d69886b— post feat(private-circle): event engine close-loop — floor VIP badges + staff invite delivery #378/feat(fastops): 3#3 User Jail — kiosk exit-gate (D-37) + role-aware step-up (D-38) #379)mainRoute-Nav Continuity
No new routes/nav — existing
/admin/restaurant/floorplansurface only.Artifact Guard
No
dist/orbuild-info.jsonstaged.Test Plan
.floor-board__table; drag clamps (1100/760) unchanged in layout space.🤖 Generated with Claude Code
Summary by CodeRabbit