feat(svelte): cleanup styling, use css variables
This commit is contained in:
@@ -130,8 +130,8 @@ function MiniMap({
|
|||||||
|
|
||||||
const onSvgClick = onClick
|
const onSvgClick = onClick
|
||||||
? (event: MouseEvent) => {
|
? (event: MouseEvent) => {
|
||||||
const rfCoord = minimapInstance.current?.pointer(event);
|
const [x, y] = minimapInstance.current?.pointer(event) || [0, 0];
|
||||||
onClick(event, { x: rfCoord?.[0] ?? 0, y: rfCoord?.[1] ?? 0 });
|
onClick(event, { x, y });
|
||||||
}
|
}
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
type $$Props = BaseEdgeProps;
|
type $$Props = BaseEdgeProps;
|
||||||
|
|
||||||
export let id: $$Props['id'] = undefined;
|
export let id: $$Props['id'] = undefined;
|
||||||
export let path: $$Props['path'] = '';
|
export let path: $$Props['path'];
|
||||||
export let label: $$Props['label'] = undefined;
|
export let label: $$Props['label'] = undefined;
|
||||||
export let labelX: $$Props['labelX'] = undefined;
|
export let labelX: $$Props['labelX'] = undefined;
|
||||||
export let labelY: $$Props['labelY'] = undefined;
|
export let labelY: $$Props['labelY'] = undefined;
|
||||||
@@ -19,19 +19,19 @@
|
|||||||
<path
|
<path
|
||||||
d={path}
|
d={path}
|
||||||
{id}
|
{id}
|
||||||
fill="none"
|
|
||||||
class="svelte-flow__edge-path"
|
class="svelte-flow__edge-path"
|
||||||
marker-start={markerStart}
|
marker-start={markerStart}
|
||||||
marker-end={markerEnd}
|
marker-end={markerEnd}
|
||||||
|
fill="none"
|
||||||
{style}
|
{style}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{#if interactionWidth}
|
{#if interactionWidth}
|
||||||
<path
|
<path
|
||||||
d={path}
|
d={path}
|
||||||
fill="none"
|
|
||||||
stroke-opacity={0}
|
stroke-opacity={0}
|
||||||
stroke-width={interactionWidth}
|
stroke-width={interactionWidth}
|
||||||
|
fill="none"
|
||||||
class="svelte-flow__edge-interaction"
|
class="svelte-flow__edge-interaction"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
<EdgeLabelRenderer>
|
<EdgeLabelRenderer>
|
||||||
<div
|
<div
|
||||||
class="svelte-flow__edge-label"
|
class="svelte-flow__edge-label"
|
||||||
style:transform={`translate(-50%, -50%) translate(${labelX}px,${labelY}px)`}
|
style:transform="translate(-50%, -50%) translate({labelX}px,{labelY}px)"
|
||||||
style={labelStyle}
|
style={labelStyle}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
@@ -53,4 +53,24 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
background: white;
|
background: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.svelte-flow__edge-path {
|
||||||
|
stroke: var(--edge-color);
|
||||||
|
stroke-width: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.selected) .svelte-flow__edge-path {
|
||||||
|
stroke: var(--edge-color-selected);
|
||||||
|
}
|
||||||
|
|
||||||
|
:global(.animated) .svelte-flow__edge-path {
|
||||||
|
stroke-dasharray: 5;
|
||||||
|
animation: dashdraw 0.5s linear infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes dashdraw {
|
||||||
|
from {
|
||||||
|
stroke-dashoffset: 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
.svelte-flow__edge-path,
|
.svelte-flow__edge-path,
|
||||||
.svelte-flow__connection-path {
|
.svelte-flow__connection-path {
|
||||||
stroke: #b1b1b7;
|
stroke: var(--connection-line-color);
|
||||||
stroke-width: 1;
|
stroke-width: 1;
|
||||||
fill: none;
|
fill: none;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,25 +81,4 @@
|
|||||||
pointer-events: visibleStroke;
|
pointer-events: visibleStroke;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.svelte-flow__edge :global(.svelte-flow__edge-path) {
|
|
||||||
stroke: #ccc;
|
|
||||||
stroke-width: 1;
|
|
||||||
fill: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selected :global(.svelte-flow__edge-path) {
|
|
||||||
stroke: #555;
|
|
||||||
}
|
|
||||||
|
|
||||||
.animated :global(.svelte-flow__edge-path) {
|
|
||||||
stroke-dasharray: 5;
|
|
||||||
animation: dashdraw 0.5s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes dashdraw {
|
|
||||||
from {
|
|
||||||
stroke-dashoffset: 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
data-handleid={handleId}
|
data-handleid={handleId}
|
||||||
data-nodeid={nodeId}
|
data-nodeid={nodeId}
|
||||||
data-handlepos={position}
|
data-handlepos={position}
|
||||||
data-id={`${nodeId}-${id}-${type}`}
|
data-id="{nodeId}-{id}-{type}"
|
||||||
class={cc([
|
class={cc([
|
||||||
'svelte-flow__handle',
|
'svelte-flow__handle',
|
||||||
`svelte-flow__handle-${position}`,
|
`svelte-flow__handle-${position}`,
|
||||||
@@ -108,8 +108,8 @@
|
|||||||
min-height: 5px;
|
min-height: 5px;
|
||||||
width: 6px;
|
width: 6px;
|
||||||
height: 6px;
|
height: 6px;
|
||||||
background: #1a192b;
|
background: var(--handle-background-color);
|
||||||
border: 1px solid white;
|
border: 1px solid var(--handle-border-color);
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{#if selectedNodes && $selectionRectMode === 'nodes'}
|
{#if selectedNodes && $selectionRectMode === 'nodes'}
|
||||||
<div
|
<div
|
||||||
class="selection-wrapper nopan"
|
class="selection-wrapper nopan"
|
||||||
style={`width: ${rect.width}px; height: ${rect.height}px; transform: translate(${rect.x}px, ${rect.y}px)`}
|
style="width: {rect.width}px; height: {rect.height}px; transform: translate({rect.x}px, {rect.y}px)"
|
||||||
use:drag={{ disabled: false, store }}
|
use:drag={{ disabled: false, store }}
|
||||||
/>
|
/>
|
||||||
<Selection
|
<Selection
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
class:draggable
|
class:draggable
|
||||||
class:connectable
|
class:connectable
|
||||||
class:parent={isParent}
|
class:parent={isParent}
|
||||||
style:transform={`translate(${positionOrigin?.x ?? 0}px, ${positionOrigin?.y ?? 0}px)`}
|
style:transform="translate({positionOrigin?.x ?? 0}px, {positionOrigin?.y ?? 0}px)"
|
||||||
{style}
|
{style}
|
||||||
on:click={onSelectNodeHandler}
|
on:click={onSelectNodeHandler}
|
||||||
on:mouseenter={() => dispatchEvent('node:mouseenter')}
|
on:mouseenter={() => dispatchEvent('node:mouseenter')}
|
||||||
@@ -116,12 +116,12 @@
|
|||||||
<style>
|
<style>
|
||||||
.svelte-flow__node {
|
.svelte-flow__node {
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
color: #222;
|
color: var(--node-color);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border-width: 1px;
|
border-width: 1px;
|
||||||
border-style: solid;
|
border-style: solid;
|
||||||
border-color: #1a192b;
|
border-color: var(--node-border-color);
|
||||||
background-color: white;
|
background-color: var(--node-background-color);
|
||||||
position: absolute;
|
position: absolute;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
@@ -134,7 +134,7 @@
|
|||||||
|
|
||||||
.selected {
|
.selected {
|
||||||
outline: none;
|
outline: none;
|
||||||
box-shadow: 0 0 0 0.5px #1a192b;
|
box-shadow: 0 0 0 0.5px var(--node-shadow-color-selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dragging {
|
.dragging {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{#if isVisible}
|
{#if isVisible}
|
||||||
<div
|
<div
|
||||||
class="svelte-flow__selection"
|
class="svelte-flow__selection"
|
||||||
style={`width: ${width}px; height: ${height}px; transform: translate(${x}px, ${y}px)`}
|
style="width: {width}px; height: {height}px; transform: translate({x}px, {y}px)"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
@@ -167,6 +167,8 @@
|
|||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
|
|
||||||
|
background-color: var(--background-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.svelte-flow :global(.svelte-flow__node-default),
|
.svelte-flow :global(.svelte-flow__node-default),
|
||||||
@@ -182,4 +184,33 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--background-color: #fff;
|
||||||
|
--background-pattern-color: #eee;
|
||||||
|
|
||||||
|
--minimap-background-color: #fff;
|
||||||
|
--minimap-mask-color: rgb(240, 240, 240, 0.6);
|
||||||
|
--minimap-mask-stroke-color: none;
|
||||||
|
--minimap-mask-stroke-width: 1;
|
||||||
|
|
||||||
|
--controls-button-background-color: #fefefe;
|
||||||
|
--controls-button-background-color-hover: #f4f4f4;
|
||||||
|
--controls-button-color: inherit;
|
||||||
|
--controls-button-color-hover: inherit;
|
||||||
|
--controls-button-border-color: #eee;
|
||||||
|
|
||||||
|
--edge-color: #cfcfcf;
|
||||||
|
--edge-color-selected: #555;
|
||||||
|
|
||||||
|
--node-color: inherit;
|
||||||
|
--node-border-color: #1a192b;
|
||||||
|
--node-background-color: #fff;
|
||||||
|
--node-shadow-color-selected: #1a192b;
|
||||||
|
|
||||||
|
--handle-background-color: #1a192b;
|
||||||
|
--handle-border-color: #fff;
|
||||||
|
|
||||||
|
--connection-line-color: #b1b1b7;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
<script labg="ts" context="module">
|
<script labg="ts" context="module">
|
||||||
const defaultColor = {
|
|
||||||
[BackgroundVariant.Dots]: '#91919a',
|
|
||||||
[BackgroundVariant.Lines]: '#eee',
|
|
||||||
[BackgroundVariant.Cross]: '#e2e2e2'
|
|
||||||
};
|
|
||||||
|
|
||||||
const defaultSize = {
|
const defaultSize = {
|
||||||
[BackgroundVariant.Dots]: 1,
|
[BackgroundVariant.Dots]: 1,
|
||||||
[BackgroundVariant.Lines]: 1,
|
[BackgroundVariant.Lines]: 1,
|
||||||
@@ -26,13 +20,12 @@
|
|||||||
export let gap: $$Props['gap'] = 20;
|
export let gap: $$Props['gap'] = 20;
|
||||||
export let size: $$Props['size'] = 1;
|
export let size: $$Props['size'] = 1;
|
||||||
export let lineWidth: $$Props['lineWidth'] = 1;
|
export let lineWidth: $$Props['lineWidth'] = 1;
|
||||||
export let color: $$Props['color'] = '#ccc';
|
export let bgColor: $$Props['bgColor'] = undefined;
|
||||||
export let style: $$Props['style'] = '';
|
export let patternColor: $$Props['patternColor'] = undefined;
|
||||||
let className: $$Props['class'] = '';
|
let className: $$Props['class'] = '';
|
||||||
export { className as class };
|
export { className as class };
|
||||||
|
|
||||||
const { transform, flowId } = useStore();
|
const { transform, flowId } = useStore();
|
||||||
const patternColor = color || defaultColor[variant!];
|
|
||||||
const patternSize = size || defaultSize[variant!];
|
const patternSize = size || defaultSize[variant!];
|
||||||
const isDots = variant === BackgroundVariant.Dots;
|
const isDots = variant === BackgroundVariant.Dots;
|
||||||
const isCross = variant === BackgroundVariant.Cross;
|
const isCross = variant === BackgroundVariant.Cross;
|
||||||
@@ -49,8 +42,8 @@
|
|||||||
|
|
||||||
<svg
|
<svg
|
||||||
class={cc(['svelte-flow__background', className])}
|
class={cc(['svelte-flow__background', className])}
|
||||||
{style}
|
|
||||||
data-testid="svelte-flow__background"
|
data-testid="svelte-flow__background"
|
||||||
|
style:--background-color-props={bgColor}
|
||||||
>
|
>
|
||||||
<pattern
|
<pattern
|
||||||
id={patternId}
|
id={patternId}
|
||||||
@@ -79,5 +72,6 @@
|
|||||||
left: 0;
|
left: 0;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
|
background-color: var(--background-color-props, 'transparent');
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let radius = 5;
|
export let radius = 5;
|
||||||
export let color = '#000';
|
export let color: string | undefined = undefined;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<circle cx={radius} cy={radius} r={radius} fill={color} />
|
<circle cx={radius} cy={radius} r={radius} style:--pattern-color-props={color} />
|
||||||
|
|
||||||
|
<style>
|
||||||
|
circle {
|
||||||
|
fill: var(--pattern-color-props, var(--background-pattern-color));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
export let lineWidth = 1;
|
export let lineWidth = 1;
|
||||||
export let color = '#777';
|
export let color: string | undefined = undefined;
|
||||||
export let dimensions: [number, number];
|
export let dimensions: [number, number];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<path
|
<path
|
||||||
stroke={color}
|
|
||||||
stroke-width={lineWidth}
|
stroke-width={lineWidth}
|
||||||
d={`M${dimensions[0] / 2} 0 V${dimensions[1]} M0 ${dimensions[1] / 2} H${dimensions[0]}`}
|
d={`M${dimensions[0] / 2} 0 V${dimensions[1]} M0 ${dimensions[1] / 2} H${dimensions[0]}`}
|
||||||
|
style:--pattern-color-props={color}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
path {
|
||||||
|
stroke: var(--pattern-color-props, var(--background-pattern-color));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ export enum BackgroundVariant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export type BackgroundProps = {
|
export type BackgroundProps = {
|
||||||
color?: string;
|
bgColor?: string;
|
||||||
|
patternColor?: string;
|
||||||
class?: string;
|
class?: string;
|
||||||
gap?: number | [number, number];
|
gap?: number | [number, number];
|
||||||
size?: number;
|
size?: number;
|
||||||
lineWidth?: number;
|
lineWidth?: number;
|
||||||
variant?: BackgroundVariant;
|
variant?: BackgroundVariant;
|
||||||
style?: string;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
import cc from 'classcat';
|
import cc from 'classcat';
|
||||||
|
|
||||||
let className: string;
|
let className: string;
|
||||||
|
let bgColor: string | undefined = undefined;
|
||||||
|
let bgColorHover: string | undefined = undefined;
|
||||||
|
let color: string | undefined = undefined;
|
||||||
|
let colorHover: string | undefined = undefined;
|
||||||
|
let borderColor: string | undefined = undefined;
|
||||||
|
|
||||||
export { className as class };
|
export { className as class };
|
||||||
</script>
|
</script>
|
||||||
@@ -10,6 +15,11 @@
|
|||||||
type="button"
|
type="button"
|
||||||
on:click
|
on:click
|
||||||
class={cc(['svelte-flow__controls-button', className])}
|
class={cc(['svelte-flow__controls-button', className])}
|
||||||
|
style:--controls-button-background-color-props={bgColor}
|
||||||
|
style:--controls-button-background-color-hover-props={bgColorHover}
|
||||||
|
style:--controls-button-color-props={color}
|
||||||
|
style:--controls-button-color-hover-props={colorHover}
|
||||||
|
style:--controls-button-border-color-props={borderColor}
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
>
|
>
|
||||||
<slot class="button-svg" />
|
<slot class="button-svg" />
|
||||||
@@ -18,8 +28,13 @@
|
|||||||
<style>
|
<style>
|
||||||
.svelte-flow__controls-button {
|
.svelte-flow__controls-button {
|
||||||
border: none;
|
border: none;
|
||||||
background: #fefefe;
|
background: var(
|
||||||
border-bottom: 1px solid #eee;
|
--controls-button-background-color-props,
|
||||||
|
var(--controls-button-background-color)
|
||||||
|
);
|
||||||
|
border-bottom: 1px solid
|
||||||
|
var(--controls-button-border-color-props, var(--controls-button-border-color));
|
||||||
|
color: var(--controls-button-color-props, var(--controls-button-color));
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
@@ -32,7 +47,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.svelte-flow__controls-button:hover {
|
.svelte-flow__controls-button:hover {
|
||||||
background: #f4f4f4;
|
background: var(
|
||||||
|
--controls-button-background-color-hover-props,
|
||||||
|
var(--controls-button-background-color-hover)
|
||||||
|
);
|
||||||
|
color: var(--controls-button-color-hover-props, var(--controls-button-hover-color));
|
||||||
}
|
}
|
||||||
|
|
||||||
.svelte-flow__controls-button :global(svg) {
|
.svelte-flow__controls-button :global(svg) {
|
||||||
|
|||||||
@@ -16,6 +16,11 @@
|
|||||||
export let showZoom: $$Props['showZoom'] = true;
|
export let showZoom: $$Props['showZoom'] = true;
|
||||||
export let showFitView: $$Props['showFitView'] = true;
|
export let showFitView: $$Props['showFitView'] = true;
|
||||||
export let showInteractive: $$Props['showInteractive'] = true;
|
export let showInteractive: $$Props['showInteractive'] = true;
|
||||||
|
export let buttonBgColor: $$Props['buttonBgColor'] = undefined;
|
||||||
|
export let buttonBgColorHover: $$Props['buttonBgColorHover'] = undefined;
|
||||||
|
export let buttonColor: $$Props['buttonColor'] = undefined;
|
||||||
|
export let buttonColorHover: $$Props['buttonColorHover'] = undefined;
|
||||||
|
export let buttonBorderColor: $$Props['buttonColorHover'] = undefined;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
zoomIn,
|
zoomIn,
|
||||||
@@ -29,6 +34,14 @@
|
|||||||
elementsSelectable
|
elementsSelectable
|
||||||
} = useStore();
|
} = useStore();
|
||||||
|
|
||||||
|
const buttonProps = {
|
||||||
|
bgColor: buttonBgColor,
|
||||||
|
bgColorHover: buttonBgColorHover,
|
||||||
|
color: buttonColor,
|
||||||
|
colorHover: buttonColorHover,
|
||||||
|
borderColor: buttonBorderColor
|
||||||
|
};
|
||||||
|
|
||||||
$: isInteractive = $nodesDraggable || $nodesConnectable || $elementsSelectable;
|
$: isInteractive = $nodesDraggable || $nodesConnectable || $elementsSelectable;
|
||||||
$: minZoomReached = $transform[2] <= $minZoom;
|
$: minZoomReached = $transform[2] <= $minZoom;
|
||||||
$: maxZoomReached = $transform[2] >= $maxZoom;
|
$: maxZoomReached = $transform[2] >= $maxZoom;
|
||||||
@@ -62,40 +75,41 @@
|
|||||||
title="zoom in"
|
title="zoom in"
|
||||||
aria-label="zoom in"
|
aria-label="zoom in"
|
||||||
disabled={maxZoomReached}
|
disabled={maxZoomReached}
|
||||||
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
</ControlButton>
|
</ControlButton>
|
||||||
<svelte:component
|
<ControlButton
|
||||||
this={ControlButton}
|
|
||||||
on:click={onZoomOutHandler}
|
on:click={onZoomOutHandler}
|
||||||
class="svelte-flow__controls-zoomout"
|
class="svelte-flow__controls-zoomout"
|
||||||
title="zoom out"
|
title="zoom out"
|
||||||
aria-label="zoom out"
|
aria-label="zoom out"
|
||||||
disabled={minZoomReached}
|
disabled={minZoomReached}
|
||||||
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
<MinusIcon />
|
<MinusIcon />
|
||||||
</svelte:component>
|
</ControlButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if showFitView}
|
{#if showFitView}
|
||||||
<svelte:component
|
<ControlButton
|
||||||
this={ControlButton}
|
|
||||||
class="svelte-flow__controls-fitview"
|
class="svelte-flow__controls-fitview"
|
||||||
on:click={onFitViewHandler}
|
on:click={onFitViewHandler}
|
||||||
title="fit view"
|
title="fit view"
|
||||||
aria-label="fit view"
|
aria-label="fit view"
|
||||||
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
<FitViewIcon />
|
<FitViewIcon />
|
||||||
</svelte:component>
|
</ControlButton>
|
||||||
{/if}
|
{/if}
|
||||||
{#if showInteractive}
|
{#if showInteractive}
|
||||||
<svelte:component
|
<ControlButton
|
||||||
this={ControlButton}
|
|
||||||
class="svelte-flow__controls-interactive"
|
class="svelte-flow__controls-interactive"
|
||||||
on:click={onToggleInteractivity}
|
on:click={onToggleInteractivity}
|
||||||
title="toggle interactivity"
|
title="toggle interactivity"
|
||||||
aria-label="toggle interactivity"
|
aria-label="toggle interactivity"
|
||||||
|
{...buttonProps}
|
||||||
>
|
>
|
||||||
{#if isInteractive}<UnlockIcon />{:else}<LockIcon />{/if}
|
{#if isInteractive}<UnlockIcon />{:else}<LockIcon />{/if}
|
||||||
</svelte:component>
|
</ControlButton>
|
||||||
{/if}
|
{/if}
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|||||||
@@ -5,4 +5,8 @@ export type ControlsProps = {
|
|||||||
showZoom?: boolean;
|
showZoom?: boolean;
|
||||||
showFitView?: boolean;
|
showFitView?: boolean;
|
||||||
showInteractive?: boolean;
|
showInteractive?: boolean;
|
||||||
|
buttonBgColor?: string;
|
||||||
|
buttonBgColorHover?: string;
|
||||||
|
buttonColor?: string;
|
||||||
|
buttonColorHover?: string;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,24 +17,23 @@
|
|||||||
|
|
||||||
type $$Props = MiniMapProps;
|
type $$Props = MiniMapProps;
|
||||||
|
|
||||||
let position: $$Props['position'] = 'bottom-right';
|
export let position: $$Props['position'] = 'bottom-right';
|
||||||
let ariaLabel: $$Props['ariaLabel'] = 'Mini map';
|
export let ariaLabel: $$Props['ariaLabel'] = 'Mini map';
|
||||||
let style: $$Props['style'] = '';
|
export let nodeStrokeColor: $$Props['nodeStrokeColor'] = 'transparent';
|
||||||
let nodeStrokeColor: $$Props['nodeStrokeColor'] = 'transparent';
|
export let nodeColor: $$Props['nodeColor'] = '#e2e2e2';
|
||||||
let nodeColor: $$Props['nodeColor'] = '#e2e2e2';
|
export let nodeClassName: $$Props['nodeClassName'] = '';
|
||||||
let nodeClassName: $$Props['nodeClassName'] = '';
|
export let nodeBorderRadius: $$Props['nodeBorderRadius'] = 5;
|
||||||
let nodeBorderRadius: $$Props['nodeBorderRadius'] = 5;
|
export let nodeStrokeWidth: $$Props['nodeStrokeWidth'] = 2;
|
||||||
let nodeStrokeWidth: $$Props['nodeStrokeWidth'] = 2;
|
export let bgColor: $$Props['bgColor'] = undefined;
|
||||||
let bgColor: $$Props['bgColor'] = '#fff';
|
export let maskColor: $$Props['maskColor'] = undefined;
|
||||||
let maskColor: $$Props['maskColor'] = 'rgb(240, 240, 240, 0.6)';
|
export let maskStrokeColor: $$Props['maskStrokeColor'] = undefined;
|
||||||
let maskStrokeColor: $$Props['maskStrokeColor'] = 'none';
|
export let maskStrokeWidth: $$Props['maskStrokeWidth'] = undefined;
|
||||||
let maskStrokeWidth: $$Props['maskStrokeWidth'] = 1;
|
export let width: $$Props['width'] = undefined;
|
||||||
let width: $$Props['width'] = undefined;
|
export let height: $$Props['height'] = undefined;
|
||||||
let height: $$Props['height'] = undefined;
|
export let pannable: $$Props['pannable'] = true;
|
||||||
let pannable: $$Props['pannable'] = true;
|
export let zoomable: $$Props['zoomable'] = true;
|
||||||
let zoomable: $$Props['zoomable'] = true;
|
export let inversePan: $$Props['inversePan'] = undefined;
|
||||||
let inversePan: $$Props['inversePan'] = undefined;
|
export let zoomStep: $$Props['zoomStep'] = undefined;
|
||||||
let zoomStep: $$Props['zoomStep'] = undefined;
|
|
||||||
|
|
||||||
let className: $$Props['class'] = '';
|
let className: $$Props['class'] = '';
|
||||||
export { className as class };
|
export { className as class };
|
||||||
@@ -84,16 +83,19 @@
|
|||||||
<Panel
|
<Panel
|
||||||
{position}
|
{position}
|
||||||
class={cc(['svelte-flow__minimap', className])}
|
class={cc(['svelte-flow__minimap', className])}
|
||||||
style={`background-color: ${bgColor}; ${style}`}
|
|
||||||
data-testid="svelte-flow__minimap"
|
data-testid="svelte-flow__minimap"
|
||||||
>
|
>
|
||||||
{#if $panZoom}
|
{#if $panZoom}
|
||||||
<svg
|
<svg
|
||||||
width={elementWidth}
|
width={elementWidth}
|
||||||
height={elementHeight}
|
height={elementHeight}
|
||||||
viewBox={`${x} ${y} ${viewboxWidth} ${viewboxHeight}`}
|
viewBox="{x} {y} {viewboxWidth} {viewboxHeight}"
|
||||||
role="img"
|
role="img"
|
||||||
aria-labelledby={labelledBy}
|
aria-labelledby={labelledBy}
|
||||||
|
style:--minimap-background-color-props={bgColor}
|
||||||
|
style:--minimap-mask-color-props={maskColor}
|
||||||
|
style:--minimap-mask-stroke-color-props={maskStrokeColor}
|
||||||
|
style:--minimap-mask-stroke-width-props={maskStrokeWidth}
|
||||||
use:interactive={{
|
use:interactive={{
|
||||||
panZoom: $panZoom,
|
panZoom: $panZoom,
|
||||||
transform,
|
transform,
|
||||||
@@ -123,22 +125,29 @@
|
|||||||
strokeWidth={nodeStrokeWidth}
|
strokeWidth={nodeStrokeWidth}
|
||||||
{shapeRendering}
|
{shapeRendering}
|
||||||
class={nodeClassNameFunc(node)}
|
class={nodeClassNameFunc(node)}
|
||||||
style={{}}
|
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
<path
|
<path
|
||||||
class="svelte-flow__minimap-mask"
|
class="svelte-flow__minimap-mask"
|
||||||
d={`M${x - offset},${y - offset}h${viewboxWidth + offset * 2}v${
|
d="M{x - offset},{y - offset}h{viewboxWidth + offset * 2}v{viewboxHeight +
|
||||||
viewboxHeight + offset * 2
|
offset * 2}h{-viewboxWidth - offset * 2}z
|
||||||
}h${-viewboxWidth - offset * 2}z
|
M{viewBB.x},{viewBB.y}h{viewBB.width}v{viewBB.height}h{-viewBB.width}z"
|
||||||
M${viewBB.x},${viewBB.y}h${viewBB.width}v${viewBB.height}h${-viewBB.width}z`}
|
|
||||||
fill={maskColor}
|
|
||||||
fill-rule="evenodd"
|
fill-rule="evenodd"
|
||||||
stroke={maskStrokeColor}
|
|
||||||
stroke-width={maskStrokeWidth}
|
|
||||||
pointer-events="none"
|
pointer-events="none"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
{/if}
|
{/if}
|
||||||
</Panel>
|
</Panel>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
svg {
|
||||||
|
background-color: var(--minimap-background-color-props, var(--minimap-background-color));
|
||||||
|
}
|
||||||
|
|
||||||
|
.svelte-flow__minimap-mask {
|
||||||
|
fill: var(--minimap-mask-color-props, var(--minimap-mask-color));
|
||||||
|
stroke: var(--minimap-mask-stroke-color-props, var(--minimap-mask-stroke-color));
|
||||||
|
stroke-width: var(--minimap-mask-stroke-width-props, var(--minimap-mask-stroke-width));
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -10,12 +10,8 @@
|
|||||||
export let shapeRendering: string;
|
export let shapeRendering: string;
|
||||||
export let strokeColor: string;
|
export let strokeColor: string;
|
||||||
export let strokeWidth: number = 2;
|
export let strokeWidth: number = 2;
|
||||||
export let style: Record<string, string>;
|
|
||||||
let className: string = '';
|
let className: string = '';
|
||||||
export { className as class };
|
export { className as class };
|
||||||
|
|
||||||
const { background, backgroundColor } = style || {};
|
|
||||||
const fill = (color || background || backgroundColor) as string;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<rect
|
<rect
|
||||||
@@ -26,7 +22,7 @@
|
|||||||
ry={borderRadius}
|
ry={borderRadius}
|
||||||
{width}
|
{width}
|
||||||
{height}
|
{height}
|
||||||
{fill}
|
fill={color}
|
||||||
stroke={strokeColor}
|
stroke={strokeColor}
|
||||||
stroke-width={strokeWidth}
|
stroke-width={strokeWidth}
|
||||||
shape-rendering={shapeRendering}
|
shape-rendering={shapeRendering}
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ export type MiniMapProps = {
|
|||||||
maskStrokeWidth?: number;
|
maskStrokeWidth?: number;
|
||||||
position?: PanelPosition;
|
position?: PanelPosition;
|
||||||
class?: string;
|
class?: string;
|
||||||
style?: string;
|
|
||||||
ariaLabel?: string | null;
|
ariaLabel?: string | null;
|
||||||
width?: number;
|
width?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
|
|||||||
@@ -90,7 +90,8 @@
|
|||||||
id: '2-4',
|
id: '2-4',
|
||||||
type: 'custom',
|
type: 'custom',
|
||||||
source: '2',
|
source: '2',
|
||||||
target: '4'
|
target: '4',
|
||||||
|
animated: true
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
@@ -151,4 +152,15 @@
|
|||||||
background: #ff5050;
|
background: #ff5050;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
--background-color: #ffffdd;
|
||||||
|
--background-pattern-color: #5050ff;
|
||||||
|
|
||||||
|
--minimap-background-color: #f5f6f7;
|
||||||
|
--minimap-mask-color: rgb(255, 255, 240, 0.6);
|
||||||
|
|
||||||
|
--controls-button-background-color: #ddd;
|
||||||
|
--controls-button-background-color-hover: #ccc;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user