From c3ea9467360de290ca90e7feb6208ed4dcb36bf7 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Sun, 18 Apr 2021 21:54:21 -0400 Subject: [PATCH] completed lesson up through handle click --- src/.index.js.swp | Bin 0 -> 12288 bytes src/App.css | 38 -------------- src/App.js | 25 ---------- src/App.test.js | 8 --- src/index.css | 62 ++++++++++++++++++----- src/index.js | 109 ++++++++++++++++++++++++++++++++++++----- src/logo.svg | 1 - src/reportWebVitals.js | 13 ----- src/setupTests.js | 5 -- 9 files changed, 147 insertions(+), 114 deletions(-) create mode 100644 src/.index.js.swp delete mode 100644 src/App.css delete mode 100644 src/App.js delete mode 100644 src/App.test.js delete mode 100644 src/logo.svg delete mode 100644 src/reportWebVitals.js delete mode 100644 src/setupTests.js diff --git a/src/.index.js.swp b/src/.index.js.swp new file mode 100644 index 0000000000000000000000000000000000000000..a2a216c44d9a9f2f460926866a4d67b1c8ddb95b GIT binary patch literal 12288 zcmeI2O>7%Q6vwA1d=x0H=miNu9|p;GsJ%@?X-RC0qyTNB*Y+kRDU?g48Rh3) z&%T*?`+x7vCd$_L96LNi2g+j%Z3kn&w_ZMZeAhA7E-}`!V^4N(*5(&n|MXL~Q#!tH ze9s2PXXS)e$nA!BQN$t$UE8ywuwl8r!_Sl#qYcKIOGW{sz%?iki)QJ-Ha5O@OqJ;U zx%+76ozGmugl4Ewz$jo8FbWt2i~>dhqkvJsC~&dhqkvJsC}0#Y3K#{90@tAew!>I;gt03(!g>7vKmGgv@^;2P10R7) z;5=9aN5Otzfil_!e9Q z?}4|#o1hC00}G6RziwmfPw*4?9=roif*FtlU*F2uyWj#i2c8A<;At=o?gn>(tzdO4 zV_$)b;5G09m;|F>1pIglW1oWe!3E%eDR3`Xy_vC}!4Kd&@D2D9d=5SUZ-7^U4JNDZ= zAaa66yu^J`KE=gj9+#)n?ZZwX9|nQQ7nM!r344i?RojhkN9C(qhh}HWA;%kAVF6wE zu`H@yWzz$?I1uU2o-eYiVma<|jmcBp)^)%p@M;}vl;&p-&C;mVtyt(_=>U1G$VsG0 zBy15!+Gy>>_)ZPaj-n&Dy=v|hK1;6O403~W4O@OXutNuW3@j-ZTsK)=+6~M$%&2!c zxH#d1WW3pBRB~mF2R(eXvm4?VZWbu8OnTPuK(B>xN8I%9hzrC56hx#|R zxyhc4$yNHdCLeVjh>)N>$1qK^juav)eqJpc8q$ zkz`Vq$zf^kSa{!4<#t7<6)oFd%&Q%@iyG2{rFpU;$y3=f_RzoGFKrkHmSkycCm{BULQXbMEt9xfiA_z1v=wWvy^pu$MX6J_YqfEQ>P- z%k`X5EAqi5Ez9;i<#8n9W>eh^cW8l!mF6QK&6*|eSO;B>u9SBnYwh1|rrh&ZsBww^FxVT=ca)glaLNZ%6 zian?LsnPdOPM<7H6EqcucDwLMvD|b$ui(d?ryp3-s=p{aklUzkQQX2)ONo}OuDlK7 z23|%^`lYqrboEZZ;jXKFOFbOWr(z+YMBt}&CD+$`m|DH85-A-=G-ww1Dy1{2t_StX zppeOS%NjPMA4j#;gp5)*Gj8DVr&Z1MGq|GN?{`>M+BIa@hU=?XXwAF*`}{Za*&Yu? zA+K&fU(8H`qFS->3={#??bFEremS{5I_2W@b9d8;q2Pd98!ay!i=9H!OzHm7Qa{yE{8i${Ja lC|^$Am~TW8HsGW;{pF0BVX#Db^_qRj36|Da3|_{izX21?Cffi2 literal 0 HcmV?d00001 diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.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; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js deleted file mode 100644 index 3784575..0000000 --- a/src/App.js +++ /dev/null @@ -1,25 +0,0 @@ -import logo from './logo.svg'; -import './App.css'; - -function App() { - return ( -
-
- logo -

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

- - Learn React - -
-
- ); -} - -export default App; diff --git a/src/App.test.js b/src/App.test.js deleted file mode 100644 index 1f03afe..0000000 --- a/src/App.test.js +++ /dev/null @@ -1,8 +0,0 @@ -import { render, screen } from '@testing-library/react'; -import App from './App'; - -test('renders learn react link', () => { - render(); - const linkElement = screen.getByText(/learn react/i); - expect(linkElement).toBeInTheDocument(); -}); diff --git a/src/index.css b/src/index.css index ec2585e..cadc65d 100644 --- a/src/index.css +++ b/src/index.css @@ -1,13 +1,51 @@ body { - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', - 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', - sans-serif; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; -} - -code { - font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', - monospace; -} + font: 14px "Century Gothic", Futura, sans-serif; + margin: 20px; + } + + ol, ul { + padding-left: 30px; + } + + .board-row:after { + clear: both; + content: ""; + display: table; + } + + .status { + margin-bottom: 10px; + } + + .square { + background: #fff; + border: 1px solid #999; + float: left; + font-size: 24px; + font-weight: bold; + line-height: 34px; + height: 34px; + margin-right: -1px; + margin-top: -1px; + padding: 0; + text-align: center; + width: 34px; + } + + .square:focus { + outline: none; + } + + .kbd-navigation .square:focus { + background: #ddd; + } + + .game { + display: flex; + flex-direction: row; + } + + .game-info { + margin-left: 20px; + } + \ No newline at end of file diff --git a/src/index.js b/src/index.js index ef2edf8..adcb7bc 100644 --- a/src/index.js +++ b/src/index.js @@ -1,17 +1,102 @@ import React from 'react'; import ReactDOM from 'react-dom'; import './index.css'; -import App from './App'; -import reportWebVitals from './reportWebVitals'; -ReactDOM.render( - - - , - document.getElementById('root') -); +class Square extends React.Component { + //constructor(props) { + // super(props); + // this.state = {}; + //} -// If you want to start measuring performance in your app, pass a function -// to log results (for example: reportWebVitals(console.log)) -// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); + render() { + return ( + //we want to bake a function into this JSX so alert isn't called with every render + // + ); + } +} + + class Board extends React.Component { + constructor(props){ + super(props); + this.state = { + squares : Array(9).fill(null) + } + }; + + handleClick(i) { + const squares = this.state.squares.slice(); + squares[i] = 'X'; + this.setState({squares: squares}); + } + + renderSquare(i) { + return ( + //all the stuff passed here are 'props', could be anything + //we have an object and a function reference + this.handleClick(i)} + /> + ); + //return ; + } + + render() { + const status = 'Next player: X'; + + return ( +
+
{status}
+
+ {this.renderSquare(0)} + {this.renderSquare(1)} + {this.renderSquare(2)} +
+
+ {this.renderSquare(3)} + {this.renderSquare(4)} + {this.renderSquare(5)} +
+
+ {this.renderSquare(6)} + {this.renderSquare(7)} + {this.renderSquare(8)} +
+
+ ); + } + } + + class Game extends React.Component { + render() { + return ( +
+
+ +
+
+
{/* status */}
+
    {/* TODO */}
+
+
+ ); + } + } + + // ======================================== + + ReactDOM.render( + , + document.getElementById('root') + ); + diff --git a/src/logo.svg b/src/logo.svg deleted file mode 100644 index 9dfc1c0..0000000 --- a/src/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/src/reportWebVitals.js b/src/reportWebVitals.js deleted file mode 100644 index 5253d3a..0000000 --- a/src/reportWebVitals.js +++ /dev/null @@ -1,13 +0,0 @@ -const reportWebVitals = onPerfEntry => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals; diff --git a/src/setupTests.js b/src/setupTests.js deleted file mode 100644 index 8f2609b..0000000 --- a/src/setupTests.js +++ /dev/null @@ -1,5 +0,0 @@ -// jest-dom adds custom jest matchers for asserting on DOM nodes. -// allows you to do things like: -// expect(element).toHaveTextContent(/react/i) -// learn more: https://github.com/testing-library/jest-dom -import '@testing-library/jest-dom';