Skip to content

Commit

Permalink
Convert NodeLink to functional component
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanGreene authored and tekton-robot committed Nov 26, 2019
1 parent ab170c2 commit 5eb2f3d
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions packages/components/src/components/Graph/NodeLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
/* istanbul ignore file */
import React, { PureComponent } from 'react';
import React from 'react';
import { path as d3Path } from 'd3-path';

export default class NodeLink extends PureComponent {
render() {
const { link } = this.props;
const sections = link.sections[0];
const path = d3Path();
const NodeLink = ({ link }) => {
const sections = link.sections[0];
const path = d3Path();

const { x: startX, y: startY } = sections.startPoint;
const { x: targetX, y: targetY } = sections.endPoint;
const { x: startX, y: startY } = sections.startPoint;
const { x: targetX, y: targetY } = sections.endPoint;

const percent = 0.5;
path.moveTo(startX, startY);
path.lineTo(startX, startY + (targetY - startY) * percent);
path.lineTo(targetX, startY + (targetY - startY) * percent);
path.lineTo(targetX, targetY);
const percent = 0.5;
path.moveTo(startX, startY);
path.lineTo(startX, startY + (targetY - startY) * percent);
path.lineTo(targetX, startY + (targetY - startY) * percent);
path.lineTo(targetX, targetY);

return (
<path strokeWidth={1} fill="none" strokeOpacity={1} d={path.toString()} />
);
}
}
return (
<path strokeWidth={1} fill="none" strokeOpacity={1} d={path.toString()} />
);
};

export default NodeLink;

0 comments on commit 5eb2f3d

Please sign in to comment.