Skip to content

Commit c3113f3

Browse files
authored
ListTodo-Component-Created
1 parent 3e369ca commit c3113f3

File tree

18 files changed

+17209
-0
lines changed

18 files changed

+17209
-0
lines changed

ListTodo-Component-Created/frontend/todo-app/package-lock.json

Lines changed: 16545 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "todo-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"react": "^16.8.4",
7+
"react-dom": "^16.8.4",
8+
"react-router-dom": "^4.3.1",
9+
"react-scripts": "2.1.8"
10+
},
11+
"scripts": {
12+
"start": "react-scripts start",
13+
"build": "react-scripts build",
14+
"test": "react-scripts test",
15+
"eject": "react-scripts eject"
16+
},
17+
"eslintConfig": {
18+
"extends": "react-app"
19+
},
20+
"browserslist": [
21+
">0.2%",
22+
"not dead",
23+
"not ie <= 11",
24+
"not op_mini all"
25+
]
26+
}
3.78 KB
Binary file not shown.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
6+
<meta
7+
name="viewport"
8+
content="width=device-width, initial-scale=1, shrink-to-fit=no"
9+
/>
10+
<meta name="theme-color" content="#000000" />
11+
<!--
12+
manifest.json provides metadata used when your web app is installed on a
13+
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
14+
-->
15+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
16+
<!--
17+
Notice the use of %PUBLIC_URL% in the tags above.
18+
It will be replaced with the URL of the `public` folder during the build.
19+
Only files inside the `public` folder can be referenced from the HTML.
20+
21+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
22+
work correctly both with client-side routing and a non-root public URL.
23+
Learn how to configure a non-root public URL by running `npm run build`.
24+
-->
25+
<title>My Todo Application</title>
26+
</head>
27+
<body>
28+
<noscript>You need to enable JavaScript to run this app.</noscript>
29+
<div id="root"></div>
30+
<!--
31+
This HTML file is a template.
32+
If you open it directly in the browser, you will see an empty page.
33+
34+
You can add webfonts, meta tags, or analytics to this file.
35+
The build step will place the bundled scripts into the <body> tag.
36+
37+
To begin the development, run `npm start` or `yarn start`.
38+
To create a production bundle, use `npm run build` or `yarn build`.
39+
-->
40+
</body>
41+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "64x64 32x32 24x24 16x16",
8+
"type": "image/x-icon"
9+
}
10+
],
11+
"start_url": ".",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
animation: App-logo-spin infinite 20s linear;
7+
height: 40vmin;
8+
pointer-events: none;
9+
}
10+
11+
.App-header {
12+
background-color: #282c34;
13+
min-height: 100vh;
14+
display: flex;
15+
flex-direction: column;
16+
align-items: center;
17+
justify-content: center;
18+
font-size: calc(10px + 2vmin);
19+
color: white;
20+
}
21+
22+
.App-link {
23+
color: #61dafb;
24+
}
25+
26+
@keyframes App-logo-spin {
27+
from {
28+
transform: rotate(0deg);
29+
}
30+
to {
31+
transform: rotate(360deg);
32+
}
33+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React, { Component } from 'react';
2+
import FirstComponent from './components/learning-examples/FirstComponent'
3+
import SecondComponent from './components/learning-examples/SecondComponent'
4+
import ThirdComponent from './components/learning-examples/ThirdComponent'
5+
import Counter from './components/counter/Counter'
6+
import TodoApp from './components/todo/TodoApp'
7+
import './App.css';
8+
9+
class App extends Component {
10+
render() {
11+
return (
12+
<div className="App">
13+
{/*<Counter/>*/}
14+
<TodoApp/>
15+
</div>
16+
);
17+
}
18+
}
19+
20+
class LearningComponents extends Component {
21+
render() {
22+
return (
23+
<div className="LearningComponents">
24+
My Hello World
25+
<FirstComponent></FirstComponent>
26+
<SecondComponent></SecondComponent>
27+
<ThirdComponent></ThirdComponent>
28+
</div>
29+
);
30+
}
31+
}
32+
33+
export default App;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div');
7+
ReactDOM.render(<App />, div);
8+
ReactDOM.unmountComponentAtNode(div);
9+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
button {
2+
background-color: green;
3+
font-size : 16px;
4+
padding : 15px 30px;
5+
color : white;
6+
width : 100px;
7+
}
8+
9+
.count {
10+
font-size : 50px;
11+
padding : 15px 30px;
12+
}
13+
14+
.reset {
15+
background-color: red;
16+
width : 200px;
17+
}
18+
19+
body {
20+
padding : 15px 30px;
21+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
import React, {Component} from 'react'
2+
import PropTypes from 'prop-types'
3+
import './Counter.css'
4+
5+
class Counter extends Component {
6+
7+
constructor() {
8+
9+
super(); //Error 1
10+
11+
this.state = {
12+
counter : 0
13+
}
14+
15+
this.increment = this.increment.bind(this);
16+
this.decrement = this.decrement.bind(this);
17+
this.reset = this.reset.bind(this);
18+
}
19+
20+
render() {
21+
return (
22+
<div className="counter">
23+
<CounterButton by={1} incrementMethod={this.increment} decrementMethod={this.decrement}/>
24+
<CounterButton by={5} incrementMethod={this.increment} decrementMethod={this.decrement}/>
25+
<CounterButton by={10} incrementMethod={this.increment} decrementMethod={this.decrement}/>
26+
<span className="count">{this.state.counter}</span>
27+
<div><button className="reset" onClick={this.reset}>Reset</button></div>
28+
</div>
29+
);
30+
}
31+
32+
reset() {
33+
this.setState( {counter: 0});
34+
}
35+
36+
increment(by) {
37+
//console.log(`increment from child - ${by}`)
38+
this.setState(
39+
(prevState) => {
40+
return {counter: prevState.counter + by}
41+
}
42+
);
43+
}
44+
45+
decrement(by) {
46+
//console.log(`increment from child - ${by}`)
47+
this.setState(
48+
(prevState) => {
49+
return {counter: prevState.counter - by}
50+
}
51+
);
52+
}
53+
54+
}
55+
56+
class CounterButton extends Component {
57+
//Define the initial state in a constructor
58+
//state => counter 0
59+
constructor() {
60+
super(); //Error 1
61+
62+
// this.state = {
63+
// counter : 0
64+
// }
65+
66+
// this.increment = this.increment.bind(this);
67+
// this.decrement = this.decrement.bind(this);
68+
}
69+
70+
render() {
71+
//render = () => {
72+
//const style = {fontSize : "50px", padding : "15px 30px"};
73+
return (
74+
<div className="counter">
75+
<button onClick={() => this.props.incrementMethod(this.props.by)} >+{this.props.by}</button>
76+
<button onClick={() => this.props.decrementMethod(this.props.by)} >-{this.props.by}</button>
77+
{/*<span className="count"
78+
>{this.state.counter}</span>*/}
79+
</div>
80+
)
81+
}
82+
83+
// increment() { //Update state - counter++
84+
// //console.log('increment');
85+
// //this.state.counter++; //Bad Practice
86+
// this.setState({
87+
// counter: this.state.counter + this.props.by
88+
// });
89+
90+
// this.props.incrementMethod(this.props.by);
91+
// }
92+
93+
// decrement () {
94+
// this.setState({
95+
// counter: this.state.counter - this.props.by
96+
// });
97+
98+
// this.props.decrementMethod(this.props.by);
99+
// }
100+
}
101+
102+
CounterButton.defaultProps = {
103+
by : 1
104+
}
105+
106+
CounterButton.propTypes = {
107+
by : PropTypes.number
108+
}
109+
110+
export default Counter

0 commit comments

Comments
 (0)