This repository was archived by the owner on Dec 18, 2024. It is now read-only.
generated from CodeYourFuture/Module-Template
-
-
Notifications
You must be signed in to change notification settings - Fork 40
NW6 | Orlando_Morales | JS2_Module_Todo-List | Week3 #213
Open
OrlandoMoralesKuan
wants to merge
10
commits into
CodeYourFuture:main
Choose a base branch
from
OrlandoMoralesKuan:JS2-Week3-todolist
base: main
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
595e3d5
Changing the title in HTML
OrlandoMoralesKuan 8e6e438
Changing title in quote-generator app
OrlandoMoralesKuan f40fd6f
quotes.js is finished
OrlandoMoralesKuan 714f173
Merge branch 'main' of https://github.com/OrlandoMoralesKuan/Module-J…
OrlandoMoralesKuan 611b280
Changing the title in HTML
OrlandoMoralesKuan 1bc9e0b
Merge branch 'main' of https://github.com/OrlandoMoralesKuan/Module-J…
OrlandoMoralesKuan e1fed69
changing title in HTML todolist exercise
OrlandoMoralesKuan 02c9f23
todo-list app is done
OrlandoMoralesKuan eb82683
erasing title in alarmclock exercise
OrlandoMoralesKuan 8a97169
erasing title and javascript code in quote-generator
OrlandoMoralesKuan 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
This file contains hidden or 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 hidden or 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 |
---|---|---|
|
@@ -3,25 +3,29 @@ | |
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Title here</title> | ||
<title>To_do-list</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" | ||
/> | ||
</head> | ||
<body> | ||
<form> | ||
<div> | ||
<input type="text" placeholder="New todo..." /> | ||
<div class="wrapper"> | ||
<header>Todo-List</header> | ||
<div class="inputField"> | ||
<input type="text" placeholder="Add your new Todo" /> | ||
<button><i class="fas fa-plus"></i></button> | ||
</div> | ||
<div> | ||
<button type="submit">Add Todo</button> | ||
<button | ||
type="button" | ||
id="remove-all-completed" | ||
class="btn btn-primary mb-3" | ||
> | ||
Remove all completed | ||
</button> | ||
<ul class="todoList"> | ||
<!-- data are comes from local storage --> | ||
</ul> | ||
<div class="footer"> | ||
<span>You have <span class="pendingTasks"></span> pending tasks</span> | ||
<button>Clear All</button> | ||
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. we don't need a clear all button from the requirements, we need a "Clear Completed Todo" button/feature |
||
</div> | ||
</form> | ||
</div> | ||
|
||
<script src="script.js"></script> | ||
</body> | ||
</html> |
This file contains hidden or 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,25 +1,66 @@ | ||
function populateTodoList(todos) { | ||
let list = document.getElementById("todo-list"); | ||
// Write your code to create todo list elements with completed and delete buttons here, all todos should display inside the "todo-list" element. | ||
} | ||
const inputBox = document.querySelector(".inputField input"); | ||
const addBtn = document.querySelector(".inputField button"); | ||
const todoList = document.querySelector(".todoList"); | ||
const deleteAllBtn = document.querySelector(".footer button"); | ||
|
||
inputBox.onkeyup = () => { | ||
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. this is good |
||
let userEnteredValue = inputBox.value; | ||
if (userEnteredValue.trim() != 0) { | ||
addBtn.classList.add("active"); | ||
} else { | ||
addBtn.classList.remove("active"); | ||
} | ||
}; | ||
|
||
// These are the same todos that currently display in the HTML | ||
// You will want to remove the ones in the current HTML after you have created them using JavaScript | ||
let todos = [ | ||
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. by default, these tasks should be displayed on the home page |
||
{ task: "Wash the dishes", completed: false }, | ||
{ task: "Do the shopping", completed: false }, | ||
]; | ||
showTasks(); | ||
|
||
populateTodoList(todos); | ||
addBtn.onclick = () => { | ||
let userEnteredValue = inputBox.value; | ||
let getLocalStorageData = localStorage.getItem("New Todo"); | ||
if (getLocalStorageData == null) { | ||
listArray = []; | ||
} else { | ||
listArray = JSON.parse(getLocalStorageData); | ||
} | ||
listArray.push(userEnteredValue); | ||
localStorage.setItem("New Todo", JSON.stringify(listArray)); | ||
|
||
// This function will take the value of the input field and add it as a new todo to the bottom of the todo list. These new todos will need the completed and delete buttons adding like normal. | ||
function addNewTodo(event) { | ||
// The code below prevents the page from refreshing when we click the 'Add Todo' button. | ||
event.preventDefault(); | ||
// Write your code here... and remember to reset the input field to be blank after creating a todo! | ||
showTasks(); | ||
addBtn.classList.remove("active"); | ||
}; | ||
|
||
function showTasks() { | ||
let getLocalStorageData = localStorage.getItem("New Todo"); | ||
if (getLocalStorageData == null) { | ||
listArray = []; | ||
} else { | ||
listArray = JSON.parse(getLocalStorageData); | ||
} | ||
const pendingTasksNumb = document.querySelector(".pendingTasks"); | ||
pendingTasksNumb.textContent = listArray.length; | ||
if (listArray.length > 0) { | ||
deleteAllBtn.classList.add("active"); | ||
} else { | ||
deleteAllBtn.classList.remove("active"); | ||
} | ||
let newLiTag = ""; | ||
listArray.forEach((element, index) => { | ||
newLiTag += `<li>${element}<span class="icon" onclick="deleteTask(${index})"><i class="fas fa-trash"></i></span> </li>`; | ||
}); | ||
todoList.innerHTML = newLiTag; | ||
inputBox.value = ""; | ||
} | ||
|
||
// Advanced challenge: Write a fucntion that checks the todos in the todo list and deletes the completed ones (we can check which ones are completed by seeing if they have the line-through styling applied or not). | ||
function deleteAllCompletedTodos() { | ||
// Write your code here... | ||
function deleteTask(index) { | ||
let getLocalStorageData = localStorage.getItem("New Todo"); | ||
listArray = JSON.parse(getLocalStorageData); | ||
listArray.splice(index, 1); | ||
localStorage.setItem("New Todo", JSON.stringify(listArray)); | ||
showTasks(); | ||
} | ||
|
||
deleteAllBtn.onclick = () => { | ||
listArray = []; | ||
localStorage.setItem("New Todo", JSON.stringify(listArray)); | ||
showTasks(); | ||
}; |
This file contains hidden or 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 +1,148 @@ | ||
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap"); | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
font-family: "Poppins", sans-serif; | ||
} | ||
|
||
::selection { | ||
color: #ffff; | ||
background-color: rgb(142, 73, 232); | ||
} | ||
|
||
body { | ||
width: 100%; | ||
height: 100vh; | ||
padding: 10px; | ||
background-color: #ddd; | ||
} | ||
|
||
.wrapper { | ||
background-color: #fff; | ||
max-width: 400px; | ||
width: 100%; | ||
margin: 120px auto; | ||
padding: 25px; | ||
border-radius: 5px; | ||
box-shadow: 0px 10px 15px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.wrapper header { | ||
font-size: 30px; | ||
font-weight: 600; | ||
} | ||
|
||
.wrapper .inputField { | ||
margin: 20px 0; | ||
width: 100%; | ||
display: flex; | ||
height: 45px; | ||
} | ||
|
||
.inputField input { | ||
width: 85%; | ||
height: 100%; | ||
outline: none; | ||
border-radius: 3px; | ||
border: 1px solid #ccc; | ||
font-size: 17px; | ||
padding-left: 15px; | ||
} | ||
|
||
.inputField input:focus { | ||
border-color: #8e49e8; | ||
} | ||
|
||
.inputField button { | ||
width: 50px; | ||
height: 100%; | ||
border: none; | ||
color: #fff; | ||
margin-left: 5px; | ||
font-size: 21px; | ||
outline: none; | ||
background: #8e49e8; | ||
cursor: pointer; | ||
border-radius: 3px; | ||
opacity: 0.6; | ||
pointer-events: none; | ||
transition: all 0, 3s ease; | ||
} | ||
|
||
.inputField button:hover, | ||
.footer button:hover { | ||
background: #721ce3; | ||
} | ||
|
||
.inputField button.active { | ||
opacity: 1; | ||
pointer-events: auto; | ||
} | ||
|
||
.wrapper .todoList { | ||
math-height: 250px; | ||
overflow-y: auto; | ||
} | ||
|
||
.todoList li { | ||
position: relative; | ||
list-style: none; | ||
margin-bottom: 8px; | ||
background: #f2f2f2; | ||
border-radius: 3px; | ||
padding: 10px 15px; | ||
cursor: default; | ||
overflow: hidden; | ||
word-wrap: break-word; | ||
} | ||
|
||
.todoList li .icon { | ||
position: absolute; | ||
height: 100%; | ||
right: -50px; | ||
top: 0%; | ||
transform: traslateY(-50%); | ||
background: #e74c3c; | ||
width: 45px; | ||
text-align: center; | ||
color: #fff; | ||
padding: 10px 15px; | ||
border-radius: 0 3px 3px 0; | ||
cursor: pointer; | ||
transition: all 0.2s ease; | ||
} | ||
|
||
.todoList li:hover .icon { | ||
right: 0px; | ||
} | ||
|
||
.wrapper .footer { | ||
display: flex; | ||
width: 100%; | ||
margin-top: 20px; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
|
||
.footer button { | ||
padding: 6px 10px; | ||
border-radius: 3px; | ||
border: none; | ||
outline: none; | ||
color: #fff; | ||
font-weight: 400; | ||
font-size: 16px; | ||
margin-left: 5px; | ||
background: #8e49e8; | ||
cursor: pointer; | ||
user-select: none; | ||
opacity: 0.6; | ||
pointer-events: none; | ||
transition: all 0.3s ease; | ||
} | ||
|
||
.footer button.active { | ||
opacity: 1; | ||
pointer-events: auto; | ||
} |
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.
user's should enter the todo, and also set the deadline date, the date input field is missing