Skip to content

Commit 993e71a

Browse files
author
Antoine Lelaisant
committed
feat: step 1 - gitcoin + score
1 parent 52c71f8 commit 993e71a

17 files changed

+125
-101
lines changed

jsconfig.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"compilerOptions": {
3+
"baseUrl": "src"
4+
},
5+
"include": [
6+
"src"
7+
],
8+
"paths": {
9+
"assets": ["./assets/*"],
10+
"components": ["./components/*"]
11+
}
12+
}

package.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@testing-library/jest-dom": "^5.11.4",
7-
"@testing-library/react": "^11.1.0",
8-
"@testing-library/user-event": "^12.1.10",
96
"react": "^17.0.1",
107
"react-dom": "^17.0.1",
118
"react-scripts": "4.0.2",
@@ -34,5 +31,10 @@
3431
"last 1 firefox version",
3532
"last 1 safari version"
3633
]
34+
},
35+
"devDependencies": {
36+
"@testing-library/jest-dom": "^5.11.9",
37+
"@testing-library/react": "^11.2.5",
38+
"@testing-library/user-event": "^12.6.3"
3739
}
3840
}

src/App.css

-38
This file was deleted.

src/App.js

-25
This file was deleted.

src/App.test.js

-8
This file was deleted.

src/assets/Github.png

10.5 KB
Loading

src/components/Checkbox.js

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react'
2+
3+
export class Checkbox extends React.Component {
4+
constructor(props) {
5+
super(props)
6+
7+
this.state = {
8+
check: false,
9+
};
10+
}
11+
12+
render() {
13+
const { name, label } = this.props
14+
15+
return (
16+
<div>
17+
<input
18+
name={name}
19+
type="checkbox"
20+
checked={this.state.checked ? 'checked' : ''}
21+
/>
22+
<label>{label}</label>
23+
</div>
24+
);
25+
}
26+
}

src/components/CookieClicker/Game.css

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.game {
2+
display: flex;
3+
flex-direction: column;
4+
align-items: center;
5+
width: 40%;
6+
}

src/components/CookieClicker/Game.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React from 'react'
2+
import './Game.css'
3+
import { Gitcoin } from './Gitcoin'
4+
import { Score } from './Score'
5+
6+
export class Game extends React.Component {
7+
constructor(props) {
8+
super(props)
9+
10+
this.state = {
11+
clicks: 0
12+
}
13+
}
14+
15+
handleClick() {
16+
this.setState({
17+
clicks: this.state.clicks + 1
18+
});
19+
}
20+
21+
render() {
22+
return (
23+
<main className="game">
24+
<Score clicks={this.state.clicks} />
25+
<Gitcoin onClick={this.handleClick.bind(this)} />
26+
</main>
27+
);
28+
}
29+
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.gitcoin {
2+
display: block;
3+
width: 15rem;
4+
height: 15rem;
5+
border: none;
6+
background: transparent;
7+
outline: none;
8+
cursor: pointer;
9+
}
10+
11+
.gitcoin > img {
12+
width: 100%;
13+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
import './Gitcoin.css'
3+
import githubIcon from 'assets/Github.png'
4+
5+
export class Gitcoin extends React.Component {
6+
render() {
7+
const { onClick } = this.props
8+
9+
return (
10+
<button
11+
className="gitcoin"
12+
onClick={onClick}
13+
>
14+
<img src={githubIcon} alt="Gitcoin" />
15+
</button>
16+
);
17+
}
18+
}

src/components/CookieClicker/Score.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
3+
export class Score extends React.Component {
4+
render() {
5+
const { clicks } = this.props
6+
7+
return (
8+
<h3>{clicks} Clicks</h3>
9+
);
10+
}
11+
}

src/index.css

-13
This file was deleted.

src/index.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import './index.css';
4-
import App from './App';
53
import reportWebVitals from './reportWebVitals';
4+
import { Game } from './components/CookieClicker/Game';
65

76
ReactDOM.render(
8-
<React.StrictMode>
9-
<App />
10-
</React.StrictMode>,
7+
<Game />,
118
document.getElementById('root')
129
);
1310

src/logo.svg

-1
This file was deleted.

src/setupTests.js

-5
This file was deleted.

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -1830,7 +1830,7 @@
18301830
lz-string "^1.4.4"
18311831
pretty-format "^26.6.2"
18321832

1833-
"@testing-library/jest-dom@^5.11.4":
1833+
"@testing-library/jest-dom@^5.11.9":
18341834
version "5.11.9"
18351835
resolved "https://registry.yarnpkg.com/@testing-library/jest-dom/-/jest-dom-5.11.9.tgz#e6b3cd687021f89f261bd53cbe367041fbd3e975"
18361836
integrity sha512-Mn2gnA9d1wStlAIT2NU8J15LNob0YFBVjs2aEQ3j8rsfRQo+lAs7/ui1i2TGaJjapLmuNPLTsrm+nPjmZDwpcQ==
@@ -1844,15 +1844,15 @@
18441844
lodash "^4.17.15"
18451845
redent "^3.0.0"
18461846

1847-
"@testing-library/react@^11.1.0":
1847+
"@testing-library/react@^11.2.5":
18481848
version "11.2.5"
18491849
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-11.2.5.tgz#ae1c36a66c7790ddb6662c416c27863d87818eb9"
18501850
integrity sha512-yEx7oIa/UWLe2F2dqK0FtMF9sJWNXD+2PPtp39BvE0Kh9MJ9Kl0HrZAgEuhUJR+Lx8Di6Xz+rKwSdEPY2UV8ZQ==
18511851
dependencies:
18521852
"@babel/runtime" "^7.12.5"
18531853
"@testing-library/dom" "^7.28.1"
18541854

1855-
"@testing-library/user-event@^12.1.10":
1855+
"@testing-library/user-event@^12.6.3":
18561856
version "12.6.3"
18571857
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-12.6.3.tgz#4a77c56a48823cf8adebd0f57670e4a89c24d058"
18581858
integrity sha512-PCmbUKofE4SXA7l8jphZAbvv5H3c4ix34xPZ/GNe99fASX//msJRgiMbHIBP+GwRfgVG9c7zmkODSPu2X2vNRw==

0 commit comments

Comments
 (0)