forked from ivacf/ivanc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppCard.js
executable file
·51 lines (45 loc) · 1.44 KB
/
AppCard.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
44
45
46
47
48
49
50
51
var React = require('react');
var AppCard = React.createClass({
// Convert date to format -> Jun 2015
dateToMonthYearString: function(date) {
var monthNames = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
var monthIndex = date.getMonth();
var year = date.getFullYear();
return monthNames[monthIndex] + ' ' + year;
},
// Return a period string like Jun 2012 - Oct 2013
buildPeriodString: function() {
var data = this.props.data;
var startDateString = this.dateToMonthYearString(data.start_date);
var endDateString = 'Present';
if (data.end_date) {
endDateString = this.dateToMonthYearString(data.end_date);
}
return startDateString + ' - ' + endDateString;
},
render: function() {
var data = this.props.data;
var footerColorStyle = {
background: data.color
};
return (
<div className="card">
<a target="_blank" href={data.url} title={data.title}>
<img className="cardImage" src={data.image} />
<div className="cardFooter" style={footerColorStyle}>
<h1 className="cardTitle">
{data.title}
</h1>
<p className="cardText">
{this.buildPeriodString()}
</p>
<img className="cardIcon" src={data.platform.icon} alt={data.platform.name} />
</div>
</a>
</div>
);
}
});
module.exports = AppCard;