Adjust SvelteFlow and allow for null to use CSS variable

This commit is contained in:
Alessandro
2025-08-11 13:59:38 +02:00
parent 4c389117b7
commit d060c3fa87
5 changed files with 44 additions and 5 deletions
@@ -63,6 +63,18 @@
type: 'output', type: 'output',
data: { label: 'Output 11' }, data: { label: 'Output 11' },
position: { x: 825, y: 300 } position: { x: 825, y: 300 }
},
{
id: '12',
type: 'output',
data: { label: 'Output 12' },
position: { x: 900, y: 200 }
},
{
id: '13',
type: 'output',
data: { label: 'Output 13' },
position: { x: 825, y: 100 }
} }
]); ]);
@@ -158,13 +170,38 @@
id: 'e4-11', id: 'e4-11',
source: '4', source: '4',
target: '11', target: '11',
label: 'Marker No Prop Color (should use CSS variable)', label: 'Marker explicitly undefined Color (defaults to none)',
className: 'css-variable-edge',
markerEnd: { markerEnd: {
type: MarkerType.ArrowClosed, type: MarkerType.ArrowClosed,
color: undefined, color: undefined,
width: 40, width: 40,
height: 40 height: 40
} }
},
{
id: 'e4-12',
source: '4',
target: '12',
label: 'Marker null Color (should use `--xy-edge-stroke` CSS variable)',
markerEnd: {
type: MarkerType.ArrowClosed,
color: null,
width: 40,
height: 40
}
},
{
id: 'e4-13',
source: '4',
target: '13',
label: 'Marker implicitly undefined Color (defaults to defaultMarkerColor)',
className: 'css-variable-edge',
markerEnd: {
type: MarkerType.ArrowClosed,
width: 40,
height: 40
}
} }
]); ]);
@@ -204,6 +241,7 @@
id: getEdgeId(connection) id: getEdgeId(connection)
}; };
}} }}
defaultMarkerColor={'purple'}
> >
<Controls /> <Controls />
<Background variant={BackgroundVariant.Dots} /> <Background variant={BackgroundVariant.Dots} />
@@ -5,7 +5,7 @@ import { useStore } from '../../hooks/useStore';
import { useMarkerSymbol } from './MarkerSymbols'; import { useMarkerSymbol } from './MarkerSymbols';
type MarkerDefinitionsProps = { type MarkerDefinitionsProps = {
defaultColor: string; defaultColor: string | null;
rfId?: string; rfId?: string;
}; };
@@ -8,7 +8,7 @@
height = 12.5, height = 12.5,
markerUnits = 'strokeWidth', markerUnits = 'strokeWidth',
orient = 'auto-start-reverse', orient = 'auto-start-reverse',
color, color = 'none',
strokeWidth strokeWidth
}: MarkerProps = $props(); }: MarkerProps = $props();
@@ -230,9 +230,10 @@ export type SvelteFlowProps<
*/ */
snapGrid?: SnapGrid; snapGrid?: SnapGrid;
/** Color of edge markers /** Color of edge markers
* You can pass `null` to use the CSS variable `--xy-edge-stroke` for the marker color.
* @example "#b1b1b7" * @example "#b1b1b7"
*/ */
defaultMarkerColor?: string; defaultMarkerColor?: string | null;
/** /**
* Controls if all nodes should be draggable * Controls if all nodes should be draggable
* @default true * @default true
+1 -1
View File
@@ -26,7 +26,7 @@ export function createMarkerIds(
defaultMarkerEnd, defaultMarkerEnd,
}: { }: {
id?: string | null; id?: string | null;
defaultColor?: string; defaultColor?: string | null;
defaultMarkerStart?: EdgeMarkerType; defaultMarkerStart?: EdgeMarkerType;
defaultMarkerEnd?: EdgeMarkerType; defaultMarkerEnd?: EdgeMarkerType;
} }