diff --git a/examples/svelte/src/routes/examples/edges/+page.svelte b/examples/svelte/src/routes/examples/edges/+page.svelte index 18c21a14..7649d63e 100644 --- a/examples/svelte/src/routes/examples/edges/+page.svelte +++ b/examples/svelte/src/routes/examples/edges/+page.svelte @@ -51,6 +51,18 @@ type: 'output', data: { label: 'Output 9' }, position: { x: 675, y: 500 } + }, + { + id: '10', + type: 'output', + data: { label: 'Output 10' }, + position: { x: 825, y: 400 } + }, + { + id: '11', + type: 'output', + data: { label: 'Output 11' }, + position: { x: 825, y: 300 } } ]); @@ -129,6 +141,27 @@ label: 'hi', labelStyle: 'background: red; font-weight: 700; padding: 5px;', style: 'stroke: #ffcc0' + }, + { + id: 'e4-10', + source: '4', + target: '10', + label: 'Explicit Red Color (should override CSS)', + markerEnd: { + type: MarkerType.ArrowClosed, + color: '#ff0000' + } + }, + { + id: 'e4-11', + source: '4', + target: '11', + label: 'No Explicit Color (should use CSS variable)', + markerEnd: { + type: MarkerType.ArrowClosed, + // To use CSS variable, set color to null + color: null + } } ]); @@ -163,3 +196,10 @@ + + diff --git a/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx b/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx index 6b59d04e..974d009e 100644 --- a/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx +++ b/packages/react/src/container/EdgeRenderer/MarkerSymbols.tsx @@ -6,33 +6,21 @@ import { useStoreApi } from '../../hooks/useStore'; type SymbolProps = Omit; const ArrowSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { - return ( - - ); + const style = { + strokeWidth, + ...(color !== 'none' && { stroke: color, fill: color }), + }; + + return ; }; const ArrowClosedSymbol = ({ color = 'none', strokeWidth = 1 }: SymbolProps) => { - return ( - - ); + const style = { + strokeWidth, + ...(color !== 'none' && { stroke: color, fill: color }), + }; + + return ; }; export const MarkerSymbols = { diff --git a/packages/svelte/src/lib/container/EdgeRenderer/MarkerDefinition/Marker.svelte b/packages/svelte/src/lib/container/EdgeRenderer/MarkerDefinition/Marker.svelte index 71412ec0..da670557 100644 --- a/packages/svelte/src/lib/container/EdgeRenderer/MarkerDefinition/Marker.svelte +++ b/packages/svelte/src/lib/container/EdgeRenderer/MarkerDefinition/Marker.svelte @@ -11,6 +11,9 @@ color, strokeWidth }: MarkerProps = $props(); + + // Create inline styles when explicit color is provided + const polylineStyle = color ? `stroke: ${color}; fill: ${color};` : ''; {#if type === MarkerType.Arrow} {:else if type === MarkerType.ArrowClosed} {/if} diff --git a/packages/system/src/styles/init.css b/packages/system/src/styles/init.css index 2d342000..b1a7d14b 100644 --- a/packages/system/src/styles/init.css +++ b/packages/system/src/styles/init.css @@ -165,6 +165,13 @@ user-select: none; } } + +/* Arrowhead marker styles - use CSS custom properties as default */ +.xy-flow__arrowhead polyline { + fill: var(--xy-edge-stroke, var(--xy-edge-stroke-default)); + stroke: var(--xy-edge-stroke, var(--xy-edge-stroke-default)); +} + .xy-flow__connection { pointer-events: none;