mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-07 12:00:46 +00:00
feat(web): Unified frontend code style (#1923)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: 谨欣 <echo.cmy@antgroup.com> Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com> Co-authored-by: yanzhiyong <932374019@qq.com>
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
import React from 'react';
|
||||
import { getBezierPath, EdgeProps, BaseEdge, useReactFlow } from 'reactflow';
|
||||
import { BaseEdge, EdgeProps, getBezierPath, useReactFlow } from 'reactflow';
|
||||
|
||||
const ButtonEdge: React.FC<EdgeProps> = ({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, style = {}, data, markerEnd }) => {
|
||||
const ButtonEdge: React.FC<EdgeProps> = ({
|
||||
id,
|
||||
sourceX,
|
||||
sourceY,
|
||||
targetX,
|
||||
targetY,
|
||||
sourcePosition,
|
||||
targetPosition,
|
||||
style = {},
|
||||
markerEnd,
|
||||
}) => {
|
||||
const [edgePath, edgeCenterX, edgeCenterY] = getBezierPath({
|
||||
sourceX,
|
||||
sourceY,
|
||||
@@ -14,7 +24,7 @@ const ButtonEdge: React.FC<EdgeProps> = ({ id, sourceX, sourceY, targetX, target
|
||||
|
||||
function onEdgeClick(event: React.MouseEvent, id: string) {
|
||||
event.stopPropagation();
|
||||
reactFlow.setEdges(reactFlow.getEdges().filter((edge) => edge.id !== id));
|
||||
reactFlow.setEdges(reactFlow.getEdges().filter(edge => edge.id !== id));
|
||||
}
|
||||
return (
|
||||
<>
|
||||
@@ -24,12 +34,12 @@ const ButtonEdge: React.FC<EdgeProps> = ({ id, sourceX, sourceY, targetX, target
|
||||
height={40}
|
||||
x={edgeCenterX - 40 / 2}
|
||||
y={edgeCenterY - 40 / 2}
|
||||
className="bg-transparent w-10 h-10 relative"
|
||||
requiredExtensions="http://www.w3.org/1999/xhtml"
|
||||
className='bg-transparent w-10 h-10 relative'
|
||||
requiredExtensions='http://www.w3.org/1999/xhtml'
|
||||
>
|
||||
<button
|
||||
className="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-stone-400 dark:bg-zinc-700 cursor-pointer text-sm"
|
||||
onClick={(event) => onEdgeClick(event, id)}
|
||||
className='absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 w-5 h-5 rounded-full bg-stone-400 dark:bg-zinc-700 cursor-pointer text-sm'
|
||||
onClick={event => onEdgeClick(event, id)}
|
||||
>
|
||||
×
|
||||
</button>
|
||||
|
Reference in New Issue
Block a user