mirror of
https://github.com/danbee/chess
synced 2025-03-04 08:39:06 +00:00
37 lines
710 B
JavaScript
37 lines
710 B
JavaScript
import React from "react";
|
|
|
|
import ChessBoardSquare from "components/chess-board-square";
|
|
|
|
class ChessBoard extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
}
|
|
|
|
chessBoardRows() {
|
|
const { store } = this.props;
|
|
return store.getState().board;
|
|
}
|
|
|
|
chessBoardRow(row, i) {
|
|
return (
|
|
<div className="board-rank" key={i}>
|
|
{row.map(
|
|
(square, j) => (
|
|
<ChessBoardSquare key={j} rank={i} file={j} square={square} />
|
|
)
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<div className="board">
|
|
{this.chessBoardRows().map((row, i) => this.chessBoardRow(row, i))}
|
|
</div>
|
|
);
|
|
}
|
|
}
|
|
|
|
export default ChessBoard;
|