forked from nicoespeon/gitgraph.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.tsx
More file actions
48 lines (42 loc) · 1.13 KB
/
Message.tsx
File metadata and controls
48 lines (42 loc) · 1.13 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import * as React from "react";
import { ReactSvgElement } from "./types";
import { Commit } from "@gitgraph/core";
interface MessageProps {
commit: Commit<ReactSvgElement>;
messageX: number;
}
export const Message = React.forwardRef<SVGGElement, MessageProps>(
(props, ref) => {
const { commit, messageX } = props;
if (commit.renderMessage) {
return (
<g ref={ref} transform={`translate(${messageX}, 0)`}>
{commit.renderMessage(commit)}
</g>
);
}
let body = null;
if (commit.body) {
body = (
<foreignObject width="600" x="10">
<p>{commit.body}</p>
</foreignObject>
);
}
// Use commit dot radius to align text with the middle of the dot.
const y = commit.style.dot.size;
return (
<g ref={ref} transform={`translate(${messageX}, ${y})`}>
<text
alignmentBaseline="central"
fill={commit.style.message.color}
style={{ font: commit.style.message.font }}
onClick={commit.onMessageClick}
>
{commit.message}
</text>
{body}
</g>
);
},
);