Skip to content

Project to-do-list#450

Open
AndreaHedstrom wants to merge 58 commits intoTechnigo:masterfrom
AndreaHedstrom:master
Open

Project to-do-list#450
AndreaHedstrom wants to merge 58 commits intoTechnigo:masterfrom
AndreaHedstrom:master

Conversation

@AndreaHedstrom
Copy link
Copy Markdown

Copy link
Copy Markdown

@fannystenberg fannystenberg left a 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. 🤩👏

Comment on lines +1 to +70
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;
Copy link
Copy Markdown

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!

Comment on lines +80 to +127
{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>
)
})}
Copy link
Copy Markdown

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants