fixed minimap styling by props & mask-stroke-width
This commit is contained in:
@@ -49,6 +49,7 @@ function MiniMapComponent({
|
|||||||
// We need to rename the prop to be `CapitalCase` so that JSX will render it as
|
// We need to rename the prop to be `CapitalCase` so that JSX will render it as
|
||||||
// a component properly.
|
// a component properly.
|
||||||
nodeComponent,
|
nodeComponent,
|
||||||
|
bgColor,
|
||||||
maskColor,
|
maskColor,
|
||||||
maskStrokeColor = 'none',
|
maskStrokeColor = 'none',
|
||||||
maskStrokeWidth = 1,
|
maskStrokeWidth = 1,
|
||||||
@@ -130,7 +131,8 @@ function MiniMapComponent({
|
|||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
...style,
|
...style,
|
||||||
'--xy-minimap-mask-color-props': typeof maskColor === 'string' ? maskColor : undefined,
|
'--xy-minimap-background-color-props': typeof bgColor === 'string' ? bgColor : undefined,
|
||||||
|
'--xy-minimap-mask-background-color-props': typeof maskColor === 'string' ? maskColor : undefined,
|
||||||
'--xy-minimap-node-background-color-props': typeof nodeColor === 'string' ? nodeColor : undefined,
|
'--xy-minimap-node-background-color-props': typeof nodeColor === 'string' ? nodeColor : undefined,
|
||||||
'--xy-minimap-node-stroke-color-props': typeof nodeStrokeColor === 'string' ? nodeStrokeColor : undefined,
|
'--xy-minimap-node-stroke-color-props': typeof nodeStrokeColor === 'string' ? nodeStrokeColor : undefined,
|
||||||
'--xy-minimap-node-stroke-width-props': typeof nodeStrokeWidth === 'string' ? nodeStrokeWidth : undefined,
|
'--xy-minimap-node-stroke-width-props': typeof nodeStrokeWidth === 'string' ? nodeStrokeWidth : undefined,
|
||||||
@@ -143,6 +145,7 @@ function MiniMapComponent({
|
|||||||
width={elementWidth}
|
width={elementWidth}
|
||||||
height={elementHeight}
|
height={elementHeight}
|
||||||
viewBox={`${x} ${y} ${width} ${height}`}
|
viewBox={`${x} ${y} ${width} ${height}`}
|
||||||
|
className="react-flow__minimap-svg"
|
||||||
role="img"
|
role="img"
|
||||||
aria-labelledby={labelledBy}
|
aria-labelledby={labelledBy}
|
||||||
ref={svg}
|
ref={svg}
|
||||||
@@ -164,7 +167,7 @@ function MiniMapComponent({
|
|||||||
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`}
|
||||||
fillRule="evenodd"
|
fillRule="evenodd"
|
||||||
stroke={maskStrokeColor}
|
stroke={maskStrokeColor}
|
||||||
strokeWidth={maskStrokeWidth}
|
strokeWidth={maskStrokeWidth * viewScale}
|
||||||
pointerEvents="none"
|
pointerEvents="none"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ export type MiniMapProps<NodeType extends Node = Node> = Omit<HTMLAttributes<SVG
|
|||||||
nodeStrokeWidth?: number;
|
nodeStrokeWidth?: number;
|
||||||
/** Component used to render nodes on minimap */
|
/** Component used to render nodes on minimap */
|
||||||
nodeComponent?: ComponentType<MiniMapNodeProps>;
|
nodeComponent?: ComponentType<MiniMapNodeProps>;
|
||||||
|
/** Background color of minimap */
|
||||||
|
bgColor?: string;
|
||||||
/** Color of mask representing viewport */
|
/** Color of mask representing viewport */
|
||||||
maskColor?: string;
|
maskColor?: string;
|
||||||
/** Stroke color of mask representing viewport */
|
/** Stroke color of mask representing viewport */
|
||||||
|
|||||||
@@ -27,7 +27,7 @@
|
|||||||
export let bgColor: $$Props['bgColor'] = undefined;
|
export let bgColor: $$Props['bgColor'] = undefined;
|
||||||
export let maskColor: $$Props['maskColor'] = undefined;
|
export let maskColor: $$Props['maskColor'] = undefined;
|
||||||
export let maskStrokeColor: $$Props['maskStrokeColor'] = undefined;
|
export let maskStrokeColor: $$Props['maskStrokeColor'] = undefined;
|
||||||
export let maskStrokeWidth: $$Props['maskStrokeWidth'] = undefined;
|
export let maskStrokeWidth: $$Props['maskStrokeWidth'] = 1;
|
||||||
export let width: $$Props['width'] = undefined;
|
export let width: $$Props['width'] = undefined;
|
||||||
export let height: $$Props['height'] = undefined;
|
export let height: $$Props['height'] = undefined;
|
||||||
export let pannable: $$Props['pannable'] = true;
|
export let pannable: $$Props['pannable'] = true;
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
<Panel
|
<Panel
|
||||||
{position}
|
{position}
|
||||||
{style}
|
style={style + `;--xy-minimap-background-color-props:${bgColor}`}
|
||||||
class={cc(['svelte-flow__minimap', className])}
|
class={cc(['svelte-flow__minimap', className])}
|
||||||
data-testid="svelte-flow__minimap"
|
data-testid="svelte-flow__minimap"
|
||||||
>
|
>
|
||||||
@@ -92,12 +92,10 @@
|
|||||||
width={elementWidth}
|
width={elementWidth}
|
||||||
height={elementHeight}
|
height={elementHeight}
|
||||||
viewBox="{x} {y} {viewboxWidth} {viewboxHeight}"
|
viewBox="{x} {y} {viewboxWidth} {viewboxHeight}"
|
||||||
|
class="svelte-flow__minimap-svg"
|
||||||
role="img"
|
role="img"
|
||||||
aria-labelledby={labelledBy}
|
aria-labelledby={labelledBy}
|
||||||
style:--xy-minimap-background-color-props={bgColor}
|
style:--xy-minimap-mask-background-color-props={maskColor}
|
||||||
style:--xy-minimap-mask-color-props={maskColor}
|
|
||||||
style:--xy-minimap-mask-stroke-color-props={maskStrokeColor}
|
|
||||||
style:--xy-minimap-mask-stroke-width-props={maskStrokeWidth}
|
|
||||||
use:interactive={{
|
use:interactive={{
|
||||||
panZoom: $panZoom,
|
panZoom: $panZoom,
|
||||||
viewport,
|
viewport,
|
||||||
@@ -137,6 +135,8 @@
|
|||||||
offset * 2}h{-viewboxWidth - offset * 2}z
|
offset * 2}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-rule="evenodd"
|
fill-rule="evenodd"
|
||||||
|
stroke={maskStrokeColor}
|
||||||
|
stroke-width={maskStrokeWidth ?? 1 * viewScale}
|
||||||
pointer-events="none"
|
pointer-events="none"
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
@@ -310,7 +310,14 @@ svg.xy-flow__connectionline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.xy-flow__minimap {
|
.xy-flow__minimap {
|
||||||
background: var(--xy-minimap-background-color, var(--xy-minimap-background-color-default));
|
background: var(
|
||||||
|
--xy-minimap-background-color,
|
||||||
|
var(--xy-minimap-background-color-props, var(--xy-minimap-background-color-default))
|
||||||
|
);
|
||||||
|
|
||||||
|
&-svg {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
&-mask {
|
&-mask {
|
||||||
fill: var(
|
fill: var(
|
||||||
|
|||||||
Reference in New Issue
Block a user