-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcard.js.jsx
44 lines (39 loc) · 1.07 KB
/
card.js.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
window.CardComponent = React.createClass({
handleClick: function (e) {
var cardValue = e.currentTarget.getAttribute('value');
if (this.clickStatus() === "") {
this.props.handleClick(cardValue);
} else {
this.props.handleUnclick(cardValue);
}
},
clickStatus: function () {
if (this.props.selectedCards.indexOf(this.props.card) !== -1) {
return " on";
} else {
return "";
}
},
render: function () {
var card = this.props.card;
var symbolCount = card[3];
var cardView = [];
for (var i = 0; i < symbolCount; i++) {
cardView.push(<Symbol key={i} card={this.props.card}/>);
}
var fillUrl = "./images/" + card[1] + ".jpg";
var klass = "card-wrapper" + this.clickStatus();
return (
<div className={klass} onClick={this.handleClick} value={card}>
<div className="card">
{
cardView.map(function (cardPortion) {
return cardPortion;
})
}
<img className="fill" src={fillUrl}/>
</div>
</div>
);
}
});