1.8 KiB
1.8 KiB
| id | title | status | assignee | created_date | updated_date | labels | dependencies | priority | |||
|---|---|---|---|---|---|---|---|---|---|---|---|
| task-8 | Port shared hooks as FolkJS utilities | Done | 2026-01-02 16:10 | 2026-01-02 18:45 |
|
high |
Description
Convert canvas-website React hooks to FolkJS-compatible utilities:
-
useMaximize → maximizeShape(shape) utility
- Store original dimensions
- Animate to viewport fill
- Restore on toggle
-
usePinnedToView → PinnedViewManager class
- Keep shape fixed as camera moves
- Support multiple pin positions
- Zero-lag with requestAnimationFrame
-
Shape serialization - toJSON/fromJSON pattern
- Already implemented in folk-markdown
- Standardize across all shapes
These utilities enable the StandardizedToolWrapper features (maximize, pin, close) across all FolkJS shapes.
Acceptance Criteria
- #1 maximizeShape utility working
- #2 PinnedViewManager class working
- #3 All shapes have consistent toJSON/fromJSON
Notes
Implementation Complete
Created three utility implementations:
-
maximize.ts -
maximizeShape(),restoreShape(),toggleMaximize(),isMaximized()- Uses WeakMap to store original dimensions
- Animates with 0.3s CSS transitions
- Accounts for canvas transforms
-
pinned-view.ts -
PinnedViewManagerclass- 9 preset positions + 'current' for in-place pinning
- RequestAnimationFrame for zero-lag viewport tracking
- Compensates for canvas pan/zoom transforms
- Singleton pattern via
getPinnedViewManager()
-
folk-shape.ts - Base
toJSON()method- Returns type, id, x, y, width, height, rotation
- Subclasses override and extend
All utilities exported from lib/index.ts.