Skip to content

Share edge line rendering between the preview and details panel#2002

Draft
kmcginnes wants to merge 1 commit into
derive-arrow-iconsfrom
share-edge-line-rendering
Draft

Share edge line rendering between the preview and details panel#2002
kmcginnes wants to merge 1 commit into
derive-arrow-iconsfrom
share-edge-line-rendering

Conversation

@kmcginnes

Copy link
Copy Markdown
Collaborator

Stacked on #1983 — this PR targets derive-arrow-icons, not main. Rebase onto main once #1983 merges.

Description

The edge details sidebar hand-rolled its own vertical connector (arrow icons stacked around a gradient CSS line), which misaligned with the arrow heads. Extracted the edge style preview's line + arrow-head machinery into a shared, orientation-aware EdgeLinePreview that renders:

  • The line, inset by cytoscape's gap at each end
  • Source/target arrow heads, rotated to point along the edge and pinned by their tip at cytoscape's spacing inset
  • An optional centered label

…in "horizontal" (style preview) or "vertical" (details connector) orientation.

EdgePreview now composes EdgeLinePreview; EdgeDetail uses it vertically, dropping the hand-rolled connector and its styleForLineStyle gradient helper.

How to read

  1. EdgeLinePreview.tsx — the shared, orientation-aware line + arrow heads + label
  2. EdgePreview.tsx — now composes EdgeLinePreview + node placeholders
  3. EdgeDetail.tsx — vertical EdgeLinePreview, old switch + gradient helper removed

Validation

  • pnpm checks passes (types, lint, format); pnpm test passes
  • New tests: EdgeLinePreview.test.tsx — render smoke over every arrow pair × orientation, label overlay in both orientations, rotatedBbox unit tests
  • Both preview orientations verified in the running app

Related Issues

Check List

  • I confirm that my contribution is made under the terms of the Apache 2.0 license.
  • I have verified pnpm checks passes with no errors.
  • I have verified pnpm test passes with no failures.
  • I have covered new added functionality with unit tests if necessary.
  • I have updated documentation if necessary.

The edge details sidebar hand-rolled its own vertical connector (arrow
icons stacked around a gradient CSS line), which misaligned with the arrow
heads. Extract the edge style preview's proven line+arrowhead machinery into
a shared, orientation-aware EdgeLinePreview so both the horizontal style
preview and the vertical details connector draw from the same cytoscape
geometry.

- Add EdgeLinePreview: line + source/target arrow heads + optional centered
  label, in "horizontal" or "vertical" orientation. Arrow heads are rotated
  to point along the edge and pinned by their tip at cytoscape's spacing/gap
  insets, so the line meets each head correctly in either orientation.
- Extract ArrowPrimitiveShape as the shared primitive renderer.
- EdgePreview now composes EdgeLinePreview (label included) + node
  placeholders; geometry resolves once instead of per-arrow-plus-label.
- EdgeDetail renders EdgeLinePreview vertically, replacing the hand-rolled
  connector and its styleForLineStyle gradient helper. It gains an aria-label
  since the arrows are otherwise visual-only.
- Rename DEFAULT_EDGE_PREVIEW_ZOOM to EDGE_PREVIEW_SCALE (mirrors the vertex
  preview's PREVIEW_SCALE) and separate it from the CSS-zoom fit control.
- Add tests: render smoke over every arrow pair x orientation, the label
  overlay in both orientations, and rotatedBbox unit tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant