Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2951] Set ConnectionLine color to palette.selected
Bug: #2951 Signed-off-by: Michaël Charfadi <michael.charfadi@obeosoft.com>
- Loading branch information
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...agrams/frontend/sirius-components-diagrams-reactflow/src/renderer/edge/ConnectionLine.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
import { Theme, useTheme } from '@material-ui/core/styles'; | ||
import React, { memo } from 'react'; | ||
import { ConnectionLineComponentProps, getSmoothStepPath } from 'reactflow'; | ||
|
||
const connectionLineStyle = (theme: Theme): React.CSSProperties => { | ||
return { | ||
stroke: theme.palette.selected, | ||
strokeWidth: theme.spacing(0.2), | ||
}; | ||
}; | ||
|
||
export const ConnectionLine = memo( | ||
({ fromX, fromY, toX, toY, fromPosition, toPosition }: ConnectionLineComponentProps) => { | ||
const theme = useTheme(); | ||
|
||
const [edgePath] = getSmoothStepPath({ | ||
sourceX: fromX, | ||
sourceY: fromY, | ||
sourcePosition: fromPosition, | ||
targetX: toX, | ||
targetY: toY, | ||
targetPosition: toPosition, | ||
}); | ||
|
||
return ( | ||
<g> | ||
<path fill="none" className="animated" d={edgePath} style={connectionLineStyle(theme)} /> | ||
</g> | ||
); | ||
} | ||
); |