-
Notifications
You must be signed in to change notification settings - Fork 424
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
Ylvas ToDo-project Week 11 #446
Open
YlvaKarlsson
wants to merge
28
commits into
Technigo:master
Choose a base branch
from
YlvaKarlsson:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3091043
Initial commit
YlvaKarlsson 6e14c67
Some kind of a working to do list - yey
YlvaKarlsson e4d1c0a
Some more things are working and some are still in progress
YlvaKarlsson 34edb37
Changes and some styling
YlvaKarlsson 120290c
Changes in styling, updating font etc
YlvaKarlsson 85f805c
Trying some more
YlvaKarlsson d6cad35
Not working anymore
YlvaKarlsson aa1d9ea
Not working!
YlvaKarlsson cab2f17
Fixed a border
YlvaKarlsson eda39f5
All working - some styling left
YlvaKarlsson ae0753a
Fixed some bugs
YlvaKarlsson cc5bf0b
Added OG-tags and updated readme
YlvaKarlsson 13fd172
Changed to a dropdown for categories - might delete tagsinput and use…
YlvaKarlsson bf671dc
Fixed header-image and header-title
YlvaKarlsson c6539f0
Fixes in the styling
YlvaKarlsson e4c4602
Edited Netlify-link
YlvaKarlsson eab3522
New commit since auto-build to Netlify didn't work
YlvaKarlsson 31ad477
Trying to fix this shit!
YlvaKarlsson ca4fc8b
Removed some unnecessary code - trying to make the deploy to Netlify …
YlvaKarlsson edb122a
Trying again...
YlvaKarlsson 3c47163
Try with comment
YlvaKarlsson f2c16cb
Trying again
YlvaKarlsson 6341ee8
Try again
YlvaKarlsson b12aa08
Trying to rename
YlvaKarlsson 5c8a108
Renaming to force update in GitHub
YlvaKarlsson 4395c59
Renaming again to get changes in folders published on Netlify
YlvaKarlsson 96fc33e
Added link to favicon
YlvaKarlsson d8c7c22
Fixed the issue with categories
YlvaKarlsson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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,32 +1,68 @@ | ||
/* eslint-disable jsx-a11y/label-has-associated-control */ | ||
/* eslint-disable no-undef */ | ||
import React, { useState } from 'react'; | ||
import { useDispatch } from 'react-redux'; | ||
import todos from 'redux/reducers/todos'; | ||
import { todos } from 'redux/reducers/todos'; | ||
import styled from 'styled-components'; | ||
|
||
const AddToDo = () => { | ||
const NewToDo = styled.form` | ||
line-height: 0.5rem; | ||
padding-bottom: 0.8rem; | ||
`; | ||
|
||
const Input = styled.input` | ||
background: #a83256; | ||
border: none; | ||
padding: 8px; | ||
font-size: 18px; | ||
font-family: 'Baloo 2', cursive; | ||
border-bottom: 2px dashed; | ||
:focus { | ||
outline: none; | ||
} | ||
`; | ||
|
||
const AddButton = styled.button` | ||
font-family: 'Baloo 2', cursive; | ||
font-size: 18px; | ||
border: none; | ||
background: transparent; | ||
cursor: pointer; | ||
`; | ||
|
||
export const AddToDo = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice that you like using styled-components! if you like different ways of styling you can read more about Sass or tailwind css :) Maybe you can also try to switch to rems, ems instead of px. |
||
const [inputValue, setInputValue] = useState(''); | ||
const dispatch = useDispatch(); | ||
const onFormSubmit = (event) => { | ||
event.preventDefault(); | ||
|
||
const newToDo = { | ||
id: Date.now().toString(), | ||
name: inputValue.charAt(0).toUpperCase() + inputValue.slice(1), | ||
isNew: false | ||
createdAt: new Date(), | ||
text: inputValue.charAt(0).toUpperCase() + inputValue.slice(1), | ||
isDone: false | ||
}; | ||
dispatch(todos.actions.addToDo(newToDo)); | ||
dispatch(todos.actions.addItem(newToDo)); | ||
setInputValue(''); | ||
// https://www.random.org | ||
} | ||
}; | ||
|
||
return ( | ||
<section> | ||
<form onSubmit={onFormSubmit}> | ||
<label htmlFor="addToDoTaskInput"> | ||
Add Your new To Do task here! | ||
<input value={inputValue} onChange={(event) => setInputValue(event.target.value)} id="addToDoInput" type="text" /> | ||
<NewToDo onSubmit={onFormSubmit}> | ||
<label> | ||
{/* htmlFor={`new-todo-input${newToDo.id}`} */} | ||
<p>New to do:</p> | ||
<Input | ||
type="text" | ||
value={inputValue} | ||
onChange={(event) => setInputValue(event.target.value)} /> | ||
{/* id={`new-todo-input${newToDo.id}`} /> */} | ||
</label> | ||
<button type="submit"> Add new To Do now</button> | ||
</form> | ||
<AddButton type="submit" disabled={inputValue.length === 0}> | ||
Add new To Do now | ||
</AddButton> | ||
</NewToDo> | ||
</section> | ||
) | ||
} | ||
|
||
export default AddToDo; | ||
); | ||
}; |
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,50 @@ | ||
import { createGlobalStyle } from 'styled-components/macro'; | ||
import styled from 'styled-components'; | ||
|
||
export const GlobalStyle = createGlobalStyle` | ||
body { | ||
background-color: linear-gradient(to bottom, #3366ff 0%, #ff00ff 100%); | ||
/* opacity: 50%; */ | ||
font-family: 'DynaPuff', cursive; | ||
font-size: 20px; | ||
display: flex; | ||
justify-content: center; | ||
} | ||
`; | ||
|
||
export const Wrapper = styled.div` | ||
background: #3483eb; | ||
width: 80vw; | ||
text-align: center; | ||
padding: 10px; | ||
margin: 20px auto; | ||
margin-bottom: 40px; | ||
border-radius: 25px; | ||
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.2); | ||
|
||
@media (min-width: 668px) { | ||
width: 55vw; | ||
} | ||
`; | ||
|
||
export const SingleTodo = styled.div` | ||
margin: 10px; | ||
border-bottom: 1px solid black; | ||
padding-bottom: 15px; | ||
line-height: 1em; | ||
`; | ||
|
||
export const Button = styled.button` | ||
font-size: 18px; | ||
padding: 4px 13px; | ||
margin: 8px; | ||
font-family: 'Baloo 2', cursive; | ||
background: #edca7f; | ||
color: #fff; | ||
border: solid 2px red; | ||
border-radius: 30px; | ||
cursor: pointer; | ||
/* :hover { | ||
opacity: 70%; | ||
} */ | ||
`; |
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,42 @@ | ||
import React from 'react'; | ||
import moment from 'moment'; | ||
import styled from 'styled-components'; | ||
import { SingleTodo } from './GlobalStyle'; | ||
|
||
const ToDoText = styled.div` | ||
cursor: pointer; | ||
text-decoration: ${(props) => (props.isDone ? 'line-through' : 'none')}; | ||
font-size: 24px; | ||
`; | ||
|
||
const DateText = styled.div` | ||
font-style: italic; | ||
font-size: 14px; | ||
margin: 7px; | ||
opacity: 50%; | ||
`; | ||
|
||
const DeleteButton = styled.button` | ||
background: #a83256; | ||
border: none; | ||
font-family: 'DynaPuff', cursive; | ||
font-size: 18px; | ||
cursor: pointer; | ||
border-radius: 50%; | ||
padding: 0px 9px; | ||
`; | ||
|
||
export const ToDoItem = ({ todo, index, onDelete, onDone }) => { | ||
return ( | ||
<SingleTodo> | ||
<ToDoText onClick={() => onDone(todo.id)} key={todo.id} isDone={todo.isDone}> | ||
<p>{todo.text}</p> | ||
<DateText>Added {moment(todo.createdAt).format('HH:mm on MMM D, YYYY')}</DateText> | ||
</ToDoText> | ||
<DeleteButton onClick={() => onDelete(index)} type="button" title="Delete task"> | ||
{' '} | ||
X | ||
</DeleteButton> | ||
</SingleTodo> | ||
); | ||
}; |
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,17 +1,76 @@ | ||
/* eslint-disable no-undef */ | ||
/* eslint-disable import/named */ | ||
/* eslint-disable no-unused-vars */ | ||
import React from 'react'; | ||
import { useSelector } from 'react-redux'; | ||
import { useSelector, useDispatch } from 'react-redux'; | ||
import { todos } from 'redux/reducers/todos'; | ||
import { ToDoItem } from './ToDoItem'; | ||
import { AddToDo } from './AddToDo'; | ||
|
||
export const ToDoList = () => { | ||
const dispatch = useDispatch(); | ||
const allTodos = useSelector((store) => store.todos.items); | ||
|
||
const onDone = (id) => { | ||
dispatch(todos.actions.deleteItem(todoIndex)); | ||
}; | ||
|
||
const onDelete = (todoIndex) => { | ||
dispatch(todos.actions.deleteItem(todoIndex)); | ||
}; | ||
|
||
const onCompleteAll = () => { | ||
allTodos.forEach((todo) => { | ||
if (!todo.isDone) { | ||
dispatch(todos.actions.toggleItem(todo.id)); | ||
} | ||
}); | ||
}; | ||
|
||
const onClearAll = () => { | ||
if (window.confirm('Do you really want to delete all to-dos?')) { | ||
dispatch(todos.actions.clearAll()); | ||
} | ||
}; | ||
|
||
const todosTodo = allTodos.filter((todo) => !todo.isDone); | ||
const doneTodos = allTodos.filter((todo) => todo.isDone); | ||
|
||
const ToDoList = () => { | ||
const todoList = useSelector((store) => store.todos.items) | ||
return ( | ||
<section> | ||
<ul> | ||
{/* <ul> | ||
{allTodos.map((singleToDo) => { | ||
return <li key={singleToDo.id}>{singleToDo.name}</li> | ||
})} | ||
</ul> */} | ||
<h2>To-do ({todosTodo.length})</h2> | ||
|
||
{todosTodo.lenghth === 0 && <p>All done - great job! ✨</p>} | ||
|
||
{todosTodo.map((todo, index) => ( | ||
<ToDoItem todo={todo} index={index} key={todo.id} onDelete={onDelete} onDone={onDone} /> | ||
))} | ||
|
||
<AddToDo /> | ||
|
||
<h2>Done ({doneTodos.lenght})</h2> | ||
|
||
<button type="button" onClick={onCompleteAll}> | ||
Complete all to-dos | ||
</button> | ||
|
||
<button type="button" onClick={onClearAll}> | ||
Clear all to-dos | ||
</button> | ||
|
||
{doneTodos.map((todo, index) => ( | ||
<ToDoItem todo={todo} index={index} key={todo.id} onDelete={onDelete} onDone={onDone} /> | ||
))} | ||
{/* <ul> | ||
{todoList.map((singleToDo) => { | ||
return <li key={singleToDo.id}>{singleToDo.name}</li> | ||
})} | ||
</ul> | ||
</ul> */} | ||
</section> | ||
) | ||
} | ||
|
||
export default ToDoList; | ||
); | ||
}; |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this is such a great thing to add credits in the html, commented out.