forked from nicoespeon/gitgraph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBranchPath.tsx
More file actions
33 lines (31 loc) · 995 Bytes
/
BranchPath.tsx
File metadata and controls
33 lines (31 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import * as React from "react";
import { toSvgPath, GitgraphCore, Coordinate, Branch } from "@gitgraph/core";
import { ReactSvgElement } from "./types";
import { ReactElement } from "react";
interface BranchPathProps {
branch: Branch<ReactElement<SVGElement>>;
coordinates: Coordinate[][];
isBezier: boolean;
offset: number;
gitgraph: GitgraphCore<ReactSvgElement>;
getWithCommitOffset: (props: any) => Coordinate;
}
export class BranchPath extends React.Component<BranchPathProps, any> {
public render() {
return (
<path
d={toSvgPath(
this.props.coordinates.map((a) =>
a.map((b) => this.props.getWithCommitOffset(b)),
),
this.props.isBezier,
this.props.gitgraph.isVertical,
)}
fill="none"
stroke={this.props.branch.computedColor}
strokeWidth={this.props.branch.style.lineWidth}
transform={`translate(${this.props.offset}, ${this.props.offset})`}
/>
);
}
}