diff --git a/src/App.css b/src/App.css index 92f956e..7825d48 100644 --- a/src/App.css +++ b/src/App.css @@ -1,32 +1,24 @@ -.App { - text-align: center; +*{ + margin: 0; + padding : 0; + box-sizing : border-box; } -.App-logo { - animation: App-logo-spin infinite 20s linear; - height: 40vmin; +#board{ + display : flex; + width : 300px; + flex-wrap : wrap; } -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; +.square{ + width: 100px; + height : 100px; + border : 1px solid black; } -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +#game{ + display: flex; + justify-content : center; + align-items : center; + flex-direction : column; } diff --git a/src/App.js b/src/App.js index 7e261ca..1debab7 100644 --- a/src/App.js +++ b/src/App.js @@ -1,25 +1,48 @@ import React, { Component } from 'react'; import logo from './logo.svg'; +import Board from './Board.jsx'; import './App.css'; class App extends Component { + + constructor(){ + super(); + this.state ={ + turn: 'X', + gameEnded: false, + board : Array(9).fill('') + } + } + + clicked(event){ + + if(this.state.board[event.target.dataset.square] == ''){ + this.state.board[event.target.dataset.square] = this.state.turn; + event.target.innerText = this.state.turn; + this.setState({ + turn: this.state.turn ='X' ? 'O' : 'X', + board : this.state.board + }) + } + console.log(this.state.board); + } + render() { return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+
+ +
this.clicked(e)}> +
+
+
+
+
+
+
+
+
+
); }