feat(Minimap): add nodeComponent prop
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
<script lang="ts">
|
||||
import type { ClassValue } from 'svelte/elements';
|
||||
import type { Component } from 'svelte';
|
||||
import type { MiniMapNodeProps } from './types';
|
||||
|
||||
let {
|
||||
x,
|
||||
@@ -12,7 +14,8 @@
|
||||
strokeColor,
|
||||
strokeWidth = 2,
|
||||
selected,
|
||||
class: className
|
||||
class: className,
|
||||
nodeComponent
|
||||
}: {
|
||||
x: number;
|
||||
y: number;
|
||||
@@ -25,20 +28,39 @@
|
||||
strokeWidth?: number;
|
||||
selected?: boolean;
|
||||
class?: ClassValue;
|
||||
nodeComponent?: Component<MiniMapNodeProps>;
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<rect
|
||||
class={['svelte-flow__minimap-node', className]}
|
||||
class:selected
|
||||
{x}
|
||||
{y}
|
||||
rx={borderRadius}
|
||||
ry={borderRadius}
|
||||
{width}
|
||||
{height}
|
||||
style:fill={color}
|
||||
style:stroke={strokeColor}
|
||||
style:stroke-width={strokeWidth}
|
||||
shape-rendering={shapeRendering}
|
||||
/>
|
||||
{#if nodeComponent}
|
||||
{@const CustomComponent = nodeComponent}
|
||||
|
||||
<CustomComponent
|
||||
{x}
|
||||
{y}
|
||||
{width}
|
||||
{height}
|
||||
{borderRadius}
|
||||
class={className}
|
||||
{color}
|
||||
{shapeRendering}
|
||||
{strokeColor}
|
||||
{strokeWidth}
|
||||
{selected}
|
||||
/>
|
||||
{:else}
|
||||
<rect
|
||||
class={['svelte-flow__minimap-node', className]}
|
||||
class:selected
|
||||
{x}
|
||||
{y}
|
||||
rx={borderRadius}
|
||||
ry={borderRadius}
|
||||
{width}
|
||||
{height}
|
||||
style:fill={color}
|
||||
style:stroke={strokeColor}
|
||||
style:stroke-width={strokeWidth}
|
||||
shape-rendering={shapeRendering}
|
||||
/>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user