2
0
Files
bot/apps/builder/components/board/graph/BlockNode/StepNode/SourceEndpoint.tsx

29 lines
614 B
TypeScript
Raw Normal View History

2021-12-16 10:43:49 +01:00
import { Box, BoxProps } from '@chakra-ui/react'
2022-01-12 09:10:59 +01:00
import { ConnectingSourceIds, useGraph } from 'contexts/GraphContext'
2021-12-16 10:43:49 +01:00
import React, { MouseEvent } from 'react'
export const SourceEndpoint = ({
2022-01-12 09:10:59 +01:00
source,
2021-12-16 10:43:49 +01:00
...props
}: BoxProps & {
2022-01-12 09:10:59 +01:00
source: ConnectingSourceIds
2021-12-16 10:43:49 +01:00
}) => {
2022-01-12 09:10:59 +01:00
const { setConnectingIds } = useGraph()
2021-12-16 10:43:49 +01:00
const handleMouseDown = (e: MouseEvent<HTMLDivElement>) => {
e.stopPropagation()
2022-01-12 09:10:59 +01:00
setConnectingIds({ source })
2021-12-16 10:43:49 +01:00
}
return (
<Box
boxSize="15px"
rounded="full"
bgColor="gray.500"
onMouseDown={handleMouseDown}
cursor="pointer"
{...props}
/>
)
}