Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions build-dev/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>React + Express</title>
<style>
body{
background-color:pink;
}
.row{
background-color:grey;
margin:5px;
padding:5px;
}
.boo{
background-color:white;
}
</style>
</head>
<body>
<h1>Wow, react</h1>
<div id="app"></div>
<script type="text/javascript" src="/main.js"></script></body>
</html>
1 change: 1 addition & 0 deletions build/client/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html> <html lang=en> <head> <meta charset=utf-8> <meta name=viewport content="width=device-width,initial-scale=1"> <title>React + Express</title> <style>body{background-color:pink}.row{background-color:grey;margin:5px;padding:5px}.boo{background-color:#fff}</style> <link href="/main.css?dc70ee4d34339c83954d" rel="stylesheet"></head> <body> <h1>Wow, react</h1> <div id=app></div> <script type="text/javascript" src="/main.js?dc70ee4d34339c83954d"></script></body> </html>
1 change: 1 addition & 0 deletions build/client/main 2.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
html,body{background-color:white;min-width:700px;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif}body{padding:20px}p{color:red}
1 change: 1 addition & 0 deletions build/client/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
html,body{background-color:white;min-width:700px;font-family:"Helvetica Neue", Helvetica, Arial, sans-serif}body{padding:20px}p{color:red}._1NKRTSXmRsNUlAqIQNrbOJ{padding:30px}
759 changes: 759 additions & 0 deletions build/client/main.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"webpack-merge": ">=4.2.1"
},
"dependencies": {
"bootstrap": "^4.5.0",
"classnames": "^2.2.6",
"express": ">=4.16.4",
"react": "^16.8.2",
Expand Down
37 changes: 28 additions & 9 deletions src/client/components/board/board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,35 @@ class Board extends React.Component {

this.state = {
board: [
['i','i','i'],
['i','i','i'],
['i','i','i']
]
["","",""],
["","",""],
["","",""]
],
lastMove: []
}

}

squareClick(something, something2){
console.log( something, something2 );
squareClick(colIndex, rowIndex){
console.log( colIndex, rowIndex );

let lastMove = this.state.lastMove;
let currentBoard= this.state.board;

//check current player and prevents clicking on already clicked box

if (lastMove.length === 0) {
currentBoard[rowIndex][colIndex] = "O";
lastMove.push("O");
} else if (lastMove[lastMove.length - 1] === "O" && currentBoard[rowIndex][colIndex] === "") {
currentBoard[rowIndex][colIndex] = "X";
lastMove.push("X");
} else if (lastMove[lastMove.length - 1] === "X" && currentBoard[rowIndex][colIndex] === "") {
currentBoard[rowIndex][colIndex] = "O";
lastMove.push("O");
}

this.setState({ board: currentBoard, lastMove: lastMove });
}

render() {
Expand All @@ -29,16 +48,16 @@ class Board extends React.Component {

// make each column
return (
<p
<span
className="boo"
key={colIndex}
onClick={()=>{
this.squareClick(colIndex, rowIndex);
}}

>
{col} : {colIndex} : {rowIndex}
</p>
[ {col} ]
</span>
);

});
Expand Down
4 changes: 4 additions & 0 deletions src/client/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@ body{
}
p{
color:red;
}

.boo {
padding : 30px;
}