feat(interactive-minimap): add node click handler

This commit is contained in:
moklick
2022-11-01 18:04:29 +01:00
parent d650609cd9
commit 0f855308cc
4 changed files with 26 additions and 2 deletions
@@ -1,7 +1,8 @@
import { memo, CSSProperties } from 'react';
import { memo, CSSProperties, MouseEvent } from 'react';
import cc from 'classcat';
interface MiniMapNodeProps {
id: string;
x: number;
y: number;
width: number;
@@ -13,9 +14,11 @@ interface MiniMapNodeProps {
strokeColor: string;
strokeWidth: number;
style?: CSSProperties;
onClick?: (event: MouseEvent, id: string) => void;
}
const MiniMapNode = ({
id,
x,
y,
width,
@@ -27,6 +30,7 @@ const MiniMapNode = ({
className,
borderRadius,
shapeRendering,
onClick,
}: MiniMapNodeProps) => {
const { background, backgroundColor } = style || {};
const fill = (color || background || backgroundColor) as string;
@@ -44,6 +48,7 @@ const MiniMapNode = ({
stroke={strokeColor}
strokeWidth={strokeWidth}
shapeRendering={shapeRendering}
onClick={onClick ? (event) => onClick(event, id) : undefined}
/>
);
};