Skip to content

Commit e595922

Browse files
author
ibrahimabarry01
committed
init
1 parent b2dc4fa commit e595922

File tree

11 files changed

+128
-28
lines changed

11 files changed

+128
-28
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"@testing-library/jest-dom": "^4.2.4",
77
"@testing-library/react": "^9.4.1",
88
"@testing-library/user-event": "^7.2.1",
9+
"bootstrap": "^4.4.1",
910
"react": "^16.13.0",
1011
"react-dom": "^16.13.0",
1112
"react-scripts": "3.4.0"

src/App.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
import React from 'react';
2-
import logo from './logo.svg';
1+
import React, { Component } from 'react';
32
import './App.css';
3+
import Goku from './Goku';
4+
import Vegeta from './Vegeta';
45

5-
function App() {
6-
return (
7-
<div className="App">
8-
<header className="App-header">
9-
<img src={logo} className="App-logo" alt="logo" />
10-
<p>
11-
Edit <code>src/App.js</code> and save to reload.
12-
</p>
13-
<a
14-
className="App-link"
15-
href="https://reactjs.org"
16-
target="_blank"
17-
rel="noopener noreferrer"
18-
>
19-
Learn React
20-
</a>
21-
</header>
22-
</div>
23-
);
6+
class App extends Component{
7+
8+
state = {
9+
Goku: 100,
10+
Vegeta: 100
11+
}
12+
13+
render(){
14+
return (
15+
<div className="container text-center ">
16+
<h1> Goku VS Vegeta </h1>
17+
<hr />
18+
Quand je finis apres tu peux regarder !
19+
<div className='row'>
20+
<Goku name= "Goku" life={this.state.Goku} />
21+
<Vegeta name= "Vegeta" life={this.state.Vegeta} />
22+
</div>
23+
24+
</div>
25+
);
26+
}
2427
}
2528

2629
export default App;

src/Goku.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React , {Component} from 'react';
2+
import goku from './goku.png';
3+
import countHits from './countHits';
4+
5+
class Goku extends Component {
6+
7+
render(){
8+
const { stateFonc , addOne , name , life } = this.props
9+
10+
return (
11+
<div className="col-md-6">
12+
<img className="img-fluid img-thumbnail" src={goku} alt="Goku" />
13+
<br />
14+
<button onClick={addOne} className='btn btn-success'> {name} Frappe</button>
15+
<table className="table table-striped">
16+
<thead>
17+
<tr>
18+
<td> Coups </td>
19+
<td> Vie </td>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
<tr>
24+
<td> {stateFonc.hits} </td>
25+
<td> {life} % </td>
26+
</tr>
27+
</tbody>
28+
</table>
29+
</div>
30+
)
31+
}
32+
}
33+
34+
export default countHits(Goku);

src/Vegeta.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React , {Component} from 'react';
2+
import vegeta from './vegeta.png';
3+
import countHits from './countHits';
4+
5+
class Vegeta extends Component {
6+
7+
render(){
8+
const { stateFonc , addOne , name , life } = this.props
9+
10+
return (
11+
<div className="col-md-6">
12+
<img className="img-fluid img-thumbnail " src={vegeta} alt="Vegeta" />
13+
<br />
14+
<button onClick={addOne} className='btn btn-success' style={{ marginTop: '40px' }}> {name} Frappe</button>
15+
<table className="table table-striped">
16+
<thead>
17+
<tr>
18+
<td> Coups </td>
19+
<td> Vie </td>
20+
</tr>
21+
</thead>
22+
<tbody>
23+
<tr>
24+
<td> {stateFonc.hits} </td>
25+
<td> {life} % </td>
26+
</tr>
27+
</tbody>
28+
</table>
29+
</div>
30+
)
31+
}
32+
}
33+
34+
export default countHits(Vegeta);

src/countHits.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React , {Component} from 'react';
2+
3+
const countHits = (WrappedComponent) => {
4+
5+
class CountHits extends Component {
6+
7+
state = {
8+
hits : 0
9+
}
10+
11+
addOne = ()=> {
12+
this.setState( (prevState)=>{
13+
return {
14+
hits: prevState.hits +1
15+
}
16+
} )
17+
}
18+
19+
render()
20+
{
21+
return <WrappedComponent stateFonc={this.state} addOne={this.addOne} {... this.props} />
22+
}
23+
}
24+
25+
return CountHits;
26+
}
27+
28+
export default countHits;

src/goku.png

772 KB
Loading

src/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ code {
1111
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
1212
monospace;
1313
}
14+

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
33
import './index.css';
4+
import 'bootstrap/dist/css/bootstrap.min.css';
45
import App from './App';
56
import * as serviceWorker from './serviceWorker';
67

src/logo.svg

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)