-
Notifications
You must be signed in to change notification settings - Fork 0
/
react-custom-rating.jsx
69 lines (58 loc) · 1.39 KB
/
react-custom-rating.jsx
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var React = require('react');
var Chart = React.createClass({
render: function () {
var imageBar = {
clear: "both",
width: "100%",
display: "WebkitFlex", /* Safari */
display: "flex",
};
var shadedImageDiv = {
opacity: "0.3",
height: "inherit",
WebkitFlex: "0.5", /* Safari 6.1+ */
msFlex: "0.5", /* IE 10 */
flex: "0.5",
};
var imageDiv = {
height: "inherit",
WebkitFlex: "0.5", /* Safari 6.1+ */
msFlex: "0.5", /* IE 10 */
flex: "0.5",
};
var imageTag = {
height: "100%",
width: "100%",
};
var chartProps = {
image: this.props.image,
maxRating: this.props.maxRating,
rating: this.props.rating,
animation: this.props.animation
};
var image = this.props.image;
var maxRating = this.props.maxRating;
var rating = this.props.rating;
var arr = [];
for (i=0; i<maxRating; i++){
if (i < rating) {
arr[i] = imageDiv;
} else {
arr[i] = shadedImageDiv;
}
}
var printImages = arr.map(function(el,i){
return (
<div style = {el} >
<img key={'image'+i} style={imageTag} src={image}></img>
</div>
);
});
return (
<div style = {imageBar}>
{printImages}
</div>
)
}
});
module.exports = Chart;