-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHighlight.js
43 lines (39 loc) · 989 Bytes
/
Highlight.js
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
import React, { Component } from "react";
import "../style/Highlight.css";
class Highlight extends Component {
render() {
const {
position,
onClick,
onMouseOver,
onMouseOut,
comment,
isScrolledTo
} = this.props;
const {
rects,
boundingRect
} = position;
// appending opacity
rects.map((rect) => rect.opacity = comment.classifier_score);
return React.createElement("div", {
className: `Highlight ${isScrolledTo ? "Highlight--scrolledTo" : ""}`
}, comment ? React.createElement("div", {
className: "Highlight__emoji",
style: {
left: 20,
top: boundingRect.top
}
}, comment.emoji) : null, React.createElement("div", {
className: "Highlight__parts"
}, rects.map((rect, index) => React.createElement("div", {
onMouseOver: onMouseOver,
onMouseOut: onMouseOut,
onClick: onClick,
key: index,
style: rect,
className: `Highlight__part ${comment.text.replace(/\s/g, '')}`
}))));
}
}
export default Highlight;