-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 58ad7ab
Showing
16 changed files
with
8,132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "react-todo", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"react": "^16.4.1", | ||
"react-dom": "^16.4.1", | ||
"react-scripts": "1.1.4" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React To Do</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, Helvetica, Arial, sans-serif; | ||
background: linear-gradient(#aeffae, #3d99ff); | ||
height: 100vh; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.Logo { | ||
width: 50px; | ||
position: relative; | ||
top: 50px; | ||
} | ||
|
||
.ToDo { | ||
text-align: center; | ||
border: 1px solid white; | ||
width: 80vw; | ||
height: 80vh; | ||
box-shadow: 2px 3px 15px rgba(0, 0, 0, 0.5); | ||
background: #f6f6f6; | ||
} | ||
|
||
.ToDo-Header { | ||
color: black; | ||
font-family: -apple-system, BlinkMacSystemFont, Helvetica Neue, Helvetica, Arial, sans-serif; | ||
font-weight: 400; | ||
text-transform: uppercase; | ||
margin: 70px auto 30px; | ||
} | ||
|
||
.ToDo-Add { | ||
color: white; | ||
font-size: 2em; | ||
width: 0.5em; | ||
height: 0.5em; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 15px; | ||
cursor: pointer; | ||
background: #73ff73; | ||
border-radius: 10px; | ||
box-shadow: 1px 1px 1px #47a947; | ||
margin: 20px auto 0; | ||
} | ||
|
||
.ToDo-Add:hover { | ||
box-shadow: none; | ||
margin-top: 21px; | ||
margin-left: calc(auto + 1px); | ||
} | ||
|
||
.ToDo-Container { | ||
width: 80%; | ||
margin: 0 auto; | ||
} | ||
|
||
input { | ||
width: 60%; | ||
padding: 10px; | ||
font-size: 1em; | ||
margin: 10px auto; | ||
box-shadow: 1px 3px 20px 0px rgba(0, 0, 0, 0.3) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import React, {Component} from 'react'; | ||
import './ToDo.css'; | ||
import ToDoItem from './components/ToDoItem'; | ||
import Logo from './assets/logo.png'; | ||
|
||
class ToDo extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = { | ||
// this is where the data goes | ||
list: [ | ||
{ | ||
'todo': 'clean the house' | ||
}, | ||
{ | ||
'todo': 'buy milk' | ||
} | ||
], | ||
editMode: false | ||
}; | ||
}; | ||
|
||
createNewToDoItem = () => { | ||
let newList = this.state.list; | ||
let input = document.querySelector('input'); | ||
newList.push( | ||
{ | ||
'number': 'item' + newList.length, | ||
'todo': input.value} | ||
); | ||
this.setState({ | ||
list: newList | ||
}); | ||
input.value = null; | ||
}; | ||
|
||
handleKeyPress = (e) => { | ||
if (e.key === 'Enter') { | ||
this.createNewToDoItem(); | ||
} | ||
}; | ||
|
||
|
||
deleteItem = (indexToDelete) => { | ||
// this is now being emitted back to the parent from the child component | ||
let array = this.state.list; // make a separate copy of the array | ||
console.log(indexToDelete); | ||
array.splice(indexToDelete, 1); // remove that item from the array | ||
this.setState({list: array}); // set new state of array with indexed item deleted | ||
}; | ||
|
||
// updateItem = (e) => { | ||
// console.log('updating'); | ||
// this.setState({editMode: true}) | ||
// let list = [...this.state.list]; // make a separate copy of the array | ||
// let itemToEdit = list.indexOf(e.target.value); //get the location of the item in the array that we want to remove | ||
// itemToEdit.style.display = 'none'; | ||
// | ||
// console.log(itemToEdit); | ||
// | ||
// }; | ||
|
||
render() { | ||
return ( | ||
<div className="ToDo"> | ||
<img className="Logo" src={Logo} alt="React logo"/> | ||
<h1 className="ToDo-Header">React To Do</h1> | ||
<div className="ToDo-Container"> | ||
<div className="ToDo-Content"> | ||
|
||
{this.state.list.map((item, key) => { | ||
return <ToDoItem | ||
key={key} | ||
item={item.todo} | ||
number={key} | ||
deleteItem={this.deleteItem.bind(this, key)} | ||
// updateItem={this.updateItem.bind(this)} | ||
/> | ||
} | ||
)} | ||
|
||
</div> | ||
<input type="text" onKeyPress={this.handleKeyPress}/> | ||
<div className="ToDo-Add" onClick={this.createNewToDoItem}>+</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ToDo; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.ToDoItem { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.ToDoItem-Text { | ||
width: 90%; | ||
background-color: white; | ||
border: 1px solid lightgrey; | ||
box-shadow: 1px 1px 1px lightgrey; | ||
padding: 12px; | ||
margin-right: 10px; | ||
} | ||
|
||
.ToDoItem-Delete { | ||
width: 20px; | ||
padding: 5px; | ||
height: 20px; | ||
cursor: pointer; | ||
background: #ff7373; | ||
border-radius: 10px; | ||
box-shadow: 1px 1px 1px #c70202; | ||
color: white; | ||
font-size: 18px; | ||
margin-right: 5px; | ||
} | ||
|
||
.ToDoItem-Delete:hover { | ||
box-shadow: none; | ||
margin-top: 1px; | ||
margin-left: 1px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, {Component} from 'react'; | ||
import './ToDoItem.css'; | ||
|
||
class ToDoItem extends Component { | ||
// constructor(props) { | ||
// super(props); | ||
// // this.state = { | ||
// // item: this.props.item | ||
// // } | ||
// } | ||
|
||
|
||
render() { | ||
return ( | ||
<div className="ToDoItem"> | ||
<p className="ToDoItem-Text">{this.props.item}</p> | ||
<div className="ToDoItem-Delete" onClick={this.props.deleteItem}>-</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default ToDoItem; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import './index.css'; | ||
import ToDo from './ToDo'; | ||
|
||
ReactDOM.render(<ToDo />, document.getElementById('root')); |
Oops, something went wrong.