mirror of
https://github.com/jhbruhn/respira.git
synced 2026-01-27 10:23:41 +00:00
Create two specialized custom hooks for PatternCanvas: **useCanvasViewport (166 lines)** - Manages canvas zoom, pan, and container resize - Handles wheel zoom and button zoom operations - Tracks container size with ResizeObserver - Calculates initial scale when pattern changes - Returns: stagePos, stageScale, containerSize, zoom handlers **usePatternTransform (179 lines)** - Manages pattern position, rotation, and transform state - Handles drag and transform end events - Syncs local state with global pattern store - Manages transformer attachment/detachment - Returns: offsets, rotation, refs, event handlers Benefits: - Reduced PatternCanvas from 608 to 388 lines (-220 lines, -36%) - Better separation of concerns (viewport vs pattern transform) - Reusable hooks for other canvas components - Easier to test state management logic in isolation - Cleaner component with focused responsibility Combined refactoring impact (Phase 1+2+3): - Original: 786 lines in single file - After Phase 3: 388 lines main + hooks + components - Total reduction: -398 lines (-51%) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| useCanvasViewport.ts | ||
| usePatternTransform.ts | ||