diff --git a/src/dev-toolbar/reactivity/index.tsx b/src/dev-toolbar/reactivity/index.tsx index 73f6494..8da9d74 100644 --- a/src/dev-toolbar/reactivity/index.tsx +++ b/src/dev-toolbar/reactivity/index.tsx @@ -7,6 +7,7 @@ import { Text } from '../../ui/Text.js'; import { FitIcon, GraphIcon, PauseIcon, PlayIcon } from '../icons.js'; import { formatValue, typeName } from './format.js'; import { + ARROW_SIZE, edgePath, layoutGraph, NODE_HEIGHT, @@ -526,31 +527,51 @@ export default function ReactivityViewer(props: ReactivityViewerProps): JSX.Elem - + + + + - {(edge) => ( - - {(from) => ( - - {(to) => ( - - )} - - )} - - )} + {(edge) => { + const role = () => edgeRoleOf(edge); + return ( + + {(from) => ( + + {(to) => ( + + )} + + )} + + ); + }} diff --git a/src/dev-toolbar/reactivity/layout.test.ts b/src/dev-toolbar/reactivity/layout.test.ts index cc3ebe8..ecefd36 100644 --- a/src/dev-toolbar/reactivity/layout.test.ts +++ b/src/dev-toolbar/reactivity/layout.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest'; import { + ARROW_SIZE, edgePath, layoutGraph, LAYER_GAP, @@ -125,14 +126,15 @@ describe('layoutGraph', () => { }); describe('edgePath', () => { - it('starts at the right edge of the source and ends at the left edge of the target', () => { + it('starts at the right edge of the source and ends arrow-size before the left edge of the target', () => { const from = { id: 'a', layer: 0, index: 0, x: 0, y: 0 }; const to = { id: 'b', layer: 1, index: 0, x: 280, y: 0 }; const middle = NODE_HEIGHT / 2; - const curve = Math.max((to.x - NODE_WIDTH) * 0.5, 40); + const endX = to.x - ARROW_SIZE; + const curve = Math.max((endX - NODE_WIDTH) * 0.5, 40); expect(edgePath(from, to)).toBe( - `M ${NODE_WIDTH} ${middle} C ${NODE_WIDTH + curve} ${middle}, ${to.x - curve} ${middle}, ${to.x} ${middle}`, + `M ${NODE_WIDTH} ${middle} C ${NODE_WIDTH + curve} ${middle}, ${endX - curve} ${middle}, ${endX} ${middle}`, ); }); diff --git a/src/dev-toolbar/reactivity/layout.ts b/src/dev-toolbar/reactivity/layout.ts index a2d176b..ff5d78c 100644 --- a/src/dev-toolbar/reactivity/layout.ts +++ b/src/dev-toolbar/reactivity/layout.ts @@ -5,6 +5,7 @@ export const NODE_HEIGHT = 44; export const LAYER_GAP = 76; export const ROW_GAP = 14; export const PADDING = 24; +export const ARROW_SIZE = 8; export interface LayoutInput { id: string; @@ -270,7 +271,7 @@ export function placeHoverCard(input: HoverCardInput): HoverCardPlacement { export function edgePath(from: LayoutNode, to: LayoutNode): string { const startX = from.x + NODE_WIDTH; const startY = from.y + NODE_HEIGHT / 2; - const endX = to.x; + const endX = to.x - ARROW_SIZE; const endY = to.y + NODE_HEIGHT / 2; const distance = Math.max(Math.abs(endX - startX) * 0.5, 40); return `M ${startX} ${startY} C ${startX + distance} ${startY}, ${endX - distance} ${endY}, ${endX} ${endY}`; diff --git a/src/dev-toolbar/reactivity/styles.css b/src/dev-toolbar/reactivity/styles.css index 3e00873..a02a2ee 100644 --- a/src/dev-toolbar/reactivity/styles.css +++ b/src/dev-toolbar/reactivity/styles.css @@ -183,6 +183,7 @@ fill: none; stroke: var(--start-dt-border); stroke-width: 1.5; + stroke-linecap: round; } [data-solid-reactivity-edge='muted'] {