-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameContainer.jsx
50 lines (43 loc) · 1.22 KB
/
GameContainer.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
var react = require('react'),
cx = require('react-classset'),
_ = require('lodash');
var GameRow = require('./GameRow.jsx');
var SettingsContainer = require('./SettingsContainer.jsx');
var GameBoard = react.createClass({
createRows: function(){
var hasWon = this.props.hasWon;
var hasLost = this.props.hasLost;
return _.map(_.groupBy(this.props.boardCells, 'yPos'), function(row, index, rows){
var size = (1 / _.size(rows)) * 100;
return (<GameRow
row = {row}
key = {index}
size = {size}
hasWon = {hasWon}
hasLost = {hasLost}
>
</GameRow>)
}, this);
},
getGameStatusClasses: function(){
var classes = {
"board_container": true
};
return cx(classes);
},
render: function(){
return (
<div className="game_container">
<SettingsContainer
className = "settings_container"
hasWon = {this.props.hasWon}
hasLost = {this.props.hasLost}
/>
<div className={this.getGameStatusClasses()}>
{this.createRows()}
</div>
</div>
)
}
});
module.exports = GameBoard;