-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
7 changed files
with
258 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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
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 |
---|---|---|
@@ -1,15 +1,93 @@ | ||
import React from 'react' | ||
import Motion from "../Motion"; | ||
import chart from '../../assets/time.png' | ||
import './to-do.css' | ||
import Items from '../To-do/ItemsList'; | ||
import { library } from '@fortawesome/fontawesome-svg-core' | ||
import { faTrash } from '@fortawesome/free-solid-svg-icons' | ||
|
||
const CalenderComponent = () => { | ||
library.add(faTrash) | ||
|
||
class ToDoAppComponent extends React.Component { | ||
constructor(props){ | ||
super(props); | ||
this.state = { | ||
items:[], | ||
currentItem:{ | ||
text:'', | ||
key:'' | ||
} | ||
} | ||
this.addItem = this.addItem.bind(this); | ||
this.handleInput = this.handleInput.bind(this); | ||
this.deleteItem = this.deleteItem.bind(this); | ||
this.setUpdate = this.setUpdate.bind(this); | ||
} | ||
addItem(e){ | ||
e.preventDefault(); | ||
const newItem = this.state.currentItem; | ||
if(newItem.text !==""){ | ||
const items = [...this.state.items, newItem]; | ||
this.setState({ | ||
items: items, | ||
currentItem:{ | ||
text:'', | ||
key:'' | ||
} | ||
}) | ||
} | ||
} | ||
handleInput(e){ | ||
this.setState({ | ||
currentItem:{ | ||
text: e.target.value, | ||
key: Date.now() | ||
} | ||
}) | ||
} | ||
deleteItem(key){ | ||
const filteredItems= this.state.items.filter(item => | ||
item.key!==key); | ||
this.setState({ | ||
items: filteredItems | ||
}) | ||
|
||
} | ||
setUpdate(text,key){ | ||
console.log("items:"+this.state.items); | ||
const items = this.state.items; | ||
items.map(item=>{ | ||
if(item.key===key){ | ||
console.log(item.key +" "+key) | ||
item.text= text; | ||
} | ||
}) | ||
this.setState({ | ||
items: items | ||
}) | ||
|
||
|
||
} | ||
render(){ | ||
return ( | ||
<> | ||
<img src={chart} className="chart-img"/> | ||
<div> | ||
<header> | ||
<form id="to-do-form" onSubmit={this.addItem}> | ||
<input type="text" placeholder="Enter task" value= {this.state.currentItem.text} onChange={this.handleInput}></input> | ||
<button type="submit">Add</button> | ||
</form> | ||
<p>{this.state.items.text}</p> | ||
|
||
<Items items={this.state.items} deleteItem={this.deleteItem} setUpdate={this.setUpdate}/> | ||
|
||
</header> | ||
</div> | ||
</> | ||
) | ||
}; | ||
|
||
const Calender = Motion(CalenderComponent); | ||
); | ||
} | ||
} | ||
const ToDoApp = Motion(ToDoAppComponent); | ||
|
||
export default Calender; | ||
export default ToDoApp; |
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,31 @@ | ||
import React from 'react'; | ||
import '../To-do/to-do.css'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import FlipMove from 'react-flip-move'; | ||
|
||
function Items(props){ | ||
const items = props.items; | ||
const listItems = items.map(item => | ||
{ | ||
return <div className="list" key={item.key}> | ||
<p> | ||
<input type="text" id={item.key} value={item.text} onChange={(e)=>{ | ||
props.setUpdate(e.target.value,item.key)}}/> | ||
<span> | ||
|
||
<FontAwesomeIcon className="faicons" onClick={() => { | ||
props.deleteItem(item.key) | ||
}} icon="trash" /> | ||
</span> | ||
</p> | ||
|
||
</div>}) | ||
return <div> | ||
<FlipMove duration={300} easing="ease-in-out"> | ||
{listItems} | ||
</FlipMove> | ||
|
||
</div>; | ||
} | ||
|
||
export default Items; |
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 |
---|---|---|
@@ -1,5 +1,98 @@ | ||
.chart-img{ | ||
width: 500px; | ||
top:20%; | ||
left:1115% | ||
.chart-img { | ||
display: block; | ||
margin-left: 0px; | ||
margin-right: 500px; | ||
margin-left: 400px; | ||
width: 450px; | ||
position: fixed; | ||
} | ||
|
||
#to-do-form input { | ||
background-color: rgba(27, 112, 137, 1); | ||
border: 0; | ||
color: #fff; | ||
width: 200px; | ||
height: 50px; | ||
margin: 20px; | ||
padding: 0 20px; | ||
font-size: 18px; | ||
border-radius: 10px; | ||
} | ||
|
||
#to-do-form input::placeholder { | ||
color: rgba(255, 255, 255, 0.5); | ||
} | ||
|
||
#to-do-form input:focus { | ||
outline: none; | ||
} | ||
|
||
#to-do-form button { | ||
height: 50px; | ||
width: 80px; | ||
background: #c96c2f; | ||
border: 0; | ||
box-shadow: -14px 16px 27px rgba(0, 0, 0, 0.25), inset 5px -6px 10px rgba(212, 121, 16, 0.25), inset -5px 5px 8px #f38444; | ||
border-radius: 20px; | ||
cursor: pointer; | ||
} | ||
|
||
#to-do-form button:focus { | ||
outline: none; | ||
} | ||
|
||
.list { | ||
color: #000; | ||
width: 300px; | ||
margin: 20px auto; | ||
height: 50px; | ||
background: #DEE0F8; | ||
box-shadow: -14px 16px 27px rgba(0, 0, 0, 0.25), inset 5px -6px 10px rgba(0, 0, 0, 0.25), inset -5px 5px 8px #DEE0F9; | ||
border-radius: 20px; | ||
} | ||
|
||
.list p { | ||
padding: 10px 0px 10px 30px; | ||
position: relative; | ||
transition: ease-in-out; | ||
} | ||
|
||
.list p input { | ||
background-color: transparent; | ||
border: 0; | ||
color: #000; | ||
font-size: 18px; | ||
} | ||
|
||
.list p input:focus { | ||
outline: none; | ||
} | ||
|
||
.list p span { | ||
position: absolute; | ||
right: 10px; | ||
} | ||
|
||
.faicons { | ||
margin: 0 5px; | ||
font-size: 15px; | ||
cursor: pointer; | ||
} | ||
|
||
.itemsAnim-enter { | ||
opacity: 0.01; | ||
} | ||
|
||
.itemsAnim-enter .itemsAnim-enter-active { | ||
opacity: 1; | ||
transition: opacity 300ms ease-in | ||
} | ||
|
||
.itemsAnim-leave { | ||
opacity: 1; | ||
} | ||
|
||
.itemsAnim-leave .itemsAnim-leave-active { | ||
opacity: 0.01; | ||
transition: opacity 300ms ease-in | ||
} |