Skip to content

Split Canvas and PivotCanvas into focused hooks and share one classNames helper - #377

Merged
woksin merged 7 commits into
mainfrom
refactor/canvas-pivot-split
Sep 29, 2026
Merged

woksin merged 7 commits into
mainfrom
refactor/canvas-pivot-split

Conversation

@woksin

@woksin woksin commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

Canvas and PivotCanvas, the two largest components, are split into focused hooks, and one shared classNames helper replaces fourteen copies. Nothing a consumer can observe changes, so this PR publishes nothing.

Changed

  • Canvas.tsx (1334 lines) is split into these hooks, called in the original effect order:
    • the Pixi application;
    • the camera transform;
    • wheel and Safari gesture zoom;
    • pointer, touch and pinch gestures;
    • Pixi item sync;
    • navigation and the imperative handle;
    • the item registry.
  • A new Storybook browser test covers the camera input paths: wheel pan, Ctrl+wheel zoom toward the pointer, the zoom controls, background drag, and the imperative handle. It passed on the previous implementation and fails on a planted change.
  • PivotCanvas.tsx (882 lines) is split into stage, color, group background, sprite sync, selection and scroll sync hooks, and its dead code is removed.
    • Rendered pixels in collection view, grouped view and after scrolling matched the previous implementation.
    • The pan-start callback ref now follows the latest callback, like the others. The only caller's callback is already stable, so nothing changes today.
  • ClassNames/classNames.ts replaces the local copies. It sits in its own CSS-free folder so it does not add another area's stylesheet to the per-area CSS.
  • The API surface snapshot and the parts inventory are unchanged, and every spec and Storybook check passes.

Closes #376.

Wheel pan, Ctrl+wheel zoom toward the pointer, the zoom controls, a
background drag, the imperative handle and measured item bounds, asserted
through onTransformChange. A planted change to the wheel zoom intensity
fails it.
Canvas.tsx keeps its props contract and composes useLatestRef,
useCanvasItemRegistry, usePixiApplication, useCanvasCamera,
useCanvasWheelZoom, useCanvasPointerGestures, usePixiItems and
useCanvasNavigation, called in the original order so effects run as
before. The exported types move to their own files and are re-exported
from Canvas.tsx. The write-only itemsRef is removed. The camera story test,
the Canvas specs and the API surface snapshot are unchanged.
PivotCanvas composes usePivotStage (Pixi init, canvas overlay, resize),
usePivotCardColors, usePivotGroupBackgrounds, usePivotSpriteSync,
usePivotSelectionHighlight and usePivotScrollSync in the original effect
order. Dead code is removed: the never-assigned spacer ref and its branch,
commented-out listeners and camera effect, unused helpers kept alive with
void, and a write-only scroll record. onPanStartRef now follows the latest
onPanStart like the other callback refs; the only caller's callback is
already stable, so nothing changes today. Rendered pixels in collection
view, grouped view and after scrolling match the previous implementation.
Thirteen components and the DataTables modules each defined the same
class-joining helper. Common/classNames.ts replaces them, accepts false as
ComboBox's copy did, and is registered as a kernel module since it is pure.
Per-area stylesheets follow the source directories a subpath reaches, so
importing a pure helper from Common/ pulled Common's CSS into the Chat and
TimeMachine areas and broke their budgets. The helper now lives in its own
CSS-free ClassNames/ folder, as QueryStatus/ does for its helper.
CanvasItemRegistryEntry moved to its own declaration file, which the build
does not rewrite. CanvasProps is still declared in the rewritten Canvas.d.ts,
so the check keeps testing navigation through a rewritten declaration.
@woksin woksin added the no-release Merging publishes no package, image, release, or deployment label Sep 29, 2026
@woksin woksin self-assigned this Sep 29, 2026
@woksin
woksin merged commit e993f7a into main Sep 29, 2026
52 of 53 checks passed
@woksin
woksin deleted the refactor/canvas-pivot-split branch September 29, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-release Merging publishes no package, image, release, or deployment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Split Canvas and PivotCanvas into focused hooks and share one classNames helper

1 participant