Skip to content

Derive edge arrow icons and share the edge line rendering#1983

Draft
kmcginnes wants to merge 2 commits into
mainfrom
derive-arrow-icons
Draft

Derive edge arrow icons and share the edge line rendering#1983
kmcginnes wants to merge 2 commits into
mainfrom
derive-arrow-icons

Conversation

@kmcginnes

@kmcginnes kmcginnes commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Description

Two related changes that make the edge previews draw from cytoscape's own arrow geometry instead of hand-maintained copies.

1 — Derive arrow icons from cytoscape geometry. The 11 hand-drawn Arrow* SVG icons (ArrowTriangle, ArrowVee, ArrowCircle, ArrowDiamond, ArrowSquare, ArrowTee, ArrowNone, ArrowTriangleTee, ArrowTriangleCross, ArrowTriangleCircle, ArrowTriangleBackCurve) were a second, hand-maintained copy of geometry that arrowShapes.ts already derives (a verbatim port of cytoscape's arrow shapes). Replaced all 11 with a single ArrowStyleIcon that renders the resolved geometry for any ArrowStyle, so the picker glyphs are guaranteed to match the canvas. The 11 icon files and their barrel exports are deleted.

2 — Share the edge line rendering between the preview and the details panel. 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. It renders the line, source/target arrow heads (rotated to point along the edge and pinned by their tip at cytoscape's spacing/gap insets), and an optional centered label, in "horizontal" (style preview) or "vertical" (details connector) orientation. EdgeDetail now uses it vertically, dropping the hand-rolled connector and its styleForLineStyle gradient helper.

Supporting: ArrowPrimitiveShape (the polygon/path/circle renderer) is extracted so EdgePreview, ArrowStyleIcon, and EdgeLinePreview share one primitive renderer; EDGE_PREVIEW_SCALE is renamed from DEFAULT_EDGE_PREVIEW_ZOOM to mirror the vertex preview's PREVIEW_SCALE and separate the model→px scale from the CSS-zoom fit control.

How to read

  1. ArrowStyleIcon.tsx — the picker/detail icon, drawn from resolveArrowGeometry
  2. EdgeLinePreview.tsx — the shared, orientation-aware line + arrow heads + label
  3. ArrowPrimitiveShape.tsx — the extracted shared primitive renderer
  4. EdgePreview.tsx — now composes EdgeLinePreview + node placeholders
  5. EdgeDetail.tsx — vertical EdgeLinePreview, old Arrow switch + gradient helper removed
  6. arrowsStyling.tsx — picker rewired to pass ArrowStyle values

Validation

  • pnpm checks passes (types, lint, format); pnpm test passes
  • New tests: ArrowStyleIcon.test.tsx (shared viewBox, shaft, per-style head counts, tip-shift math) and EdgeLinePreview.test.tsx (render smoke over every arrow pair × orientation, label overlay in both orientations, rotatedBbox unit tests)
  • Arrow glyphs and 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.

@kmcginnes
kmcginnes force-pushed the derive-arrow-icons branch from f156e02 to 6bc0a0e Compare July 21, 2026 22:56
The 11 hand-drawn Arrow* icons duplicated the arrow-head geometry that
arrowShapes.ts already ports verbatim from cytoscape. Replace them with a
single ArrowStyleIcon that renders the resolved geometry for any ArrowStyle,
so the picker and edge details always match what the canvas draws.

- Add ArrowStyleIcon: a short edge line ending in the arrow head, with a
  shared viewBox so line thickness and zoom are constant and head trailing
  edges align across styles; line length varies with head depth.
- Extract ArrowPrimitiveShape from EdgePreview as the shared primitive
  renderer for both the preview and the icon.
- Rewire the arrow-style picker and EdgeDetail to ArrowStyleIcon; delete the
  11 Arrow* icon files and their barrel exports.
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.
@kmcginnes
kmcginnes force-pushed the derive-arrow-icons branch from 6bc0a0e to 8fc7405 Compare July 24, 2026 17:14
@kmcginnes kmcginnes changed the title Derive edge arrow icons from cytoscape arrow geometry Derive edge arrow icons and share the edge line rendering Jul 24, 2026
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.

Derive edge arrow-style icons from cytoscape arrow geometry

1 participant