-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Project to-do-list #450
base: master
Are you sure you want to change the base?
Project to-do-list #450
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Your todo app looks amazing and everything works, I really liked that you made two different categories that the todo's jump between depending on if it's checked or not. 🤩👏
import React, { useState } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import tasks from 'components/reducers/tasks'; | ||
import styled from 'styled-components'; | ||
|
||
const InnerWrapper = styled.div` | ||
display: flex; | ||
flex-directon: row; | ||
justify-content: center; | ||
align-items: center; | ||
` | ||
const Label = styled.div` | ||
font-size: 20px; | ||
` | ||
|
||
const Input = styled.input` | ||
width: 200px; | ||
height: 30px; | ||
border-radius: 5px; | ||
border: solid rgb(86, 113, 143); | ||
margin-right: 10px; | ||
font-size: 18x; | ||
` | ||
|
||
const SubmitBtn = styled.button` | ||
width: 50px; | ||
height: 40px; | ||
margin-left: -9px; | ||
border-style: none; | ||
background-color: rgb(187, 205, 226); | ||
font-size: 15px; | ||
color: rgb(86, 113, 143); | ||
position: absolute; | ||
` | ||
const AddTask = () => { | ||
const [inputValue, setInputValue] = useState('') | ||
const dispatch = useDispatch() | ||
const onFormSubmit = (event) => { | ||
event.preventDefault(); | ||
const newTask = { | ||
id: Date.now().toString(), | ||
text: inputValue, | ||
complete: false | ||
} | ||
dispatch(tasks.actions.addTask(newTask)); | ||
setInputValue(''); | ||
} | ||
|
||
return ( | ||
<InnerWrapper> | ||
<form onSubmit={onFormSubmit}> | ||
<Label htmlFor="addInput"> | ||
<Input | ||
value={inputValue} | ||
type="text" | ||
placeholder="Don't forget to bring..." | ||
onChange={(event) => setInputValue(event.target.value)} | ||
id="addInput" /> | ||
<SubmitBtn type="submit" disabled={inputValue.length === 0}> | ||
<span className="material-symbols-outlined"> | ||
local_mall | ||
</span> | ||
</SubmitBtn> | ||
</Label> | ||
</form> | ||
</InnerWrapper> | ||
) | ||
} | ||
|
||
export default AddTask; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well structured and easy to read!
{completedTask.map((task) => { | ||
return ( | ||
<InnerWrapper> | ||
<label htmlFor={task.id}> | ||
<input | ||
key={task.id} | ||
type="checkbox" | ||
checked={task.isChecked} | ||
onChange={() => dispatch(tasks.actions.toggleItem(task))} /> | ||
</label> | ||
<TaskText> | ||
{task.text} | ||
</TaskText> | ||
<DeleteBtn | ||
type="button" | ||
onClick={() => dispatch(tasks.actions.deleteTask(task))}> | ||
<span className="material-symbols-outlined"> | ||
local_laundry_service | ||
</span> | ||
</DeleteBtn> | ||
</InnerWrapper> | ||
) | ||
})} | ||
<ListHeaderHome><h2>Home</h2> | ||
</ListHeaderHome> | ||
{taskToDo.map((task) => { | ||
return ( | ||
<InnerWrapper> | ||
<label htmlFor={task.id}> | ||
<input | ||
type="checkbox" | ||
checked={task.isChecked} | ||
key={task.id} | ||
onChange={() => dispatch(tasks.actions.toggleItem(task))} /> | ||
</label> | ||
<TaskText> | ||
{task.text} | ||
</TaskText> | ||
<DeleteBtn | ||
type="button" | ||
onClick={() => dispatch(tasks.actions.deleteTask(task))}> | ||
<span className="material-symbols-outlined"> | ||
local_laundry_service | ||
</span> | ||
</DeleteBtn> | ||
</InnerWrapper> | ||
) | ||
})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe the return from mapping of completedTask and TaskToDo could have been a reusable component since they return the same type of content?
Link to project: https://backandforthlist.netlify.app/