-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #124 from codedex-io/add-todo-list-tutorial-ugc
Publish Shadeira's ToDo app project tutorial
- Loading branch information
Showing
12 changed files
with
818 additions
and
0 deletions.
There are no files selected for viewing
602 changes: 602 additions & 0 deletions
602
...-a-to-do-list-app-with-html-css-js/create-a-to-do-list-app-with-html-css-js.mdx
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file added
BIN
+407 KB
projects/create-a-to-do-list-app-with-html-css-js/finished-todo-list.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.11 MB
projects/create-a-to-do-list-app-with-html-css-js/finished-todo-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+32.1 KB
...ects/create-a-to-do-list-app-with-html-css-js/todo-list-complete-uncomplete.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+230 KB
...ts/create-a-to-do-list-app-with-html-css-js/todo-list-edit-delete-html-only.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+297 KB
projects/create-a-to-do-list-app-with-html-css-js/todo-list-edit-task-html.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+174 KB
projects/create-a-to-do-list-app-with-html-css-js/todo-list-html-only.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions
46
projects/create-a-to-do-list-app-with-html-css-js/todo-list-project/index.html
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,46 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>TO-DO List</title> | ||
<link rel="stylesheet" href="style.css" /> | ||
</head> | ||
<body> | ||
<!-- create a container for the todo list --> | ||
<div id="todo-container"> | ||
<!-- todo list header --> | ||
<div id="header"> | ||
<h1>To Do List</h1> | ||
</div> | ||
|
||
<!-- create input box --> | ||
<div id="todo-form"> | ||
<input | ||
type="text" | ||
class="input-item" | ||
name="input_box" | ||
id="input-box" | ||
placeholder="Add Task" | ||
/> | ||
|
||
<!-- add button --> | ||
<button id="input-button" onclick="addTask()">Add</button> | ||
</div> | ||
|
||
<!-- task list --> | ||
<h2>Task List</h2> | ||
<ul id="list-container"></ul> | ||
|
||
<hr> | ||
|
||
<!-- task list counter --> | ||
<div class="counter-container"> | ||
<div id="task-counters"> | ||
Completed: <span id="completed-counter">0</span> | Uncompleted: | ||
<span id="uncompleted-counter">0</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script type="text/javascript" src="script.js"></script> | ||
</body> | ||
</html> |
74 changes: 74 additions & 0 deletions
74
projects/create-a-to-do-list-app-with-html-css-js/todo-list-project/script.js
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,74 @@ | ||
const inputBox = document.getElementById("input-box"); | ||
const listContainer = document.getElementById("list-container"); | ||
const completedCounter = document.getElementById("completed-counter"); | ||
const uncompletedCounter = document.getElementById("uncompleted-counter"); | ||
|
||
function updateCounters() { | ||
const completedTasks = document.querySelectorAll(".completed").length; | ||
const uncompletedTasks = document.querySelectorAll("li:not(.completed)").length; | ||
|
||
completedCounter.textContent = completedTasks; | ||
uncompletedCounter.textContent = uncompletedTasks; | ||
} | ||
|
||
function addTask() { | ||
const task = inputBox.value.trim(); | ||
if (!task) { | ||
alert("Please write down a task"); | ||
console.log("no task added"); | ||
|
||
return; | ||
} | ||
|
||
const li = document.createElement("li"); | ||
li.innerHTML = ` | ||
<label> | ||
<input type="checkbox"> | ||
<span>${task}</span> | ||
</label> | ||
<span class="edit-btn">Edit</span> | ||
<span class="delete-btn">Delete</span> | ||
`; | ||
|
||
listContainer.appendChild(li); | ||
|
||
// clear the input field | ||
inputBox.value = " "; | ||
|
||
// attach event listeners to the new task | ||
const checkbox = li.querySelector("input"); | ||
const editBtn = li.querySelector(".edit-btn"); | ||
const taskSpan = li.querySelector("span"); | ||
const deleteBtn = li.querySelector(".delete-btn"); | ||
|
||
// strike out the completed task | ||
checkbox.addEventListener("click", function () { | ||
li.classList.toggle("completed", checkbox.checked); | ||
updateCounters(); | ||
}); | ||
|
||
editBtn.addEventListener("click", function () { | ||
const update = prompt("Edit task:", taskSpan.textContent); | ||
if (update !== null) { | ||
taskSpan.textContent = update; | ||
li.classList.remove("completed"); | ||
checkbox.checked = false; | ||
updateCounters(); | ||
} | ||
}); | ||
|
||
deleteBtn.addEventListener("click", function () { | ||
if (confirm("Are you sure you want to delete this task?")) { | ||
li.remove(); | ||
updateCounters(); | ||
} | ||
}); | ||
updateCounters(); | ||
} | ||
|
||
// add task when pressing Enter key | ||
inputBox.addEventListener("keyup", function (event) { | ||
if (event.key === "Enter") { | ||
addTask(); | ||
} | ||
}); |
96 changes: 96 additions & 0 deletions
96
projects/create-a-to-do-list-app-with-html-css-js/todo-list-project/style.css
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,96 @@ | ||
body{ | ||
background: rgb(0,0,0); | ||
background: radial-gradient(circle, rgba(0,0,0,0.028124999999999956) 0%, rgba(253,187,45,1) 100%); | ||
font-family: Arial, sans-serif; | ||
text-align: center; | ||
margin-top: 50px; | ||
} | ||
|
||
.todo-container{ | ||
background: rgb(41, 33, 33); | ||
width: 400px; | ||
margin: 0 auto; | ||
border: 2px solid #0033ff; | ||
padding: 20px; | ||
color: white; | ||
border-radius: 15px; | ||
} | ||
|
||
#input-box{ | ||
width: 200px; | ||
padding: 10px; | ||
border: 1px solid #ccc; | ||
border-radius: 5px; | ||
margin-right: 5px; | ||
font-size: 20px; | ||
} | ||
|
||
#input-button{ | ||
font-size: 20px; | ||
cursor: pointer; | ||
transition: 0.4s; | ||
padding: 10px; | ||
border: none; | ||
border-radius: 5px; | ||
background-color: #2e60ea; | ||
} | ||
|
||
.task button{ | ||
background: rgb(12, 124, 251); | ||
border-radius: 5px; | ||
margin: 0px 5px; | ||
padding: 3px 5px; | ||
border: none; | ||
cursor: pointer; | ||
color: white; | ||
float: right; | ||
} | ||
|
||
hr{ | ||
border: 1px solid #0033ff; | ||
} | ||
|
||
#header{ | ||
margin: 5px; | ||
font-size: 20px; | ||
text-align: center; | ||
} | ||
|
||
h1{ | ||
margin-bottom: 20px; | ||
} | ||
|
||
#input-button:hover { | ||
background-color: #9eb7fd; | ||
} | ||
|
||
ul{ | ||
list-style: none; | ||
padding: 0; | ||
margin-top: 20px; | ||
text-align:left; | ||
} | ||
|
||
li { | ||
border: 1px solid white; | ||
border-radius: 5px; | ||
margin-bottom: 10px; | ||
padding: 10px; | ||
margin-top: 10px; | ||
} | ||
|
||
.edit-btn, .delete-btn, .complete-btn{ | ||
float: right; | ||
color:crimson; | ||
cursor: pointer; | ||
margin: 3px 5px; | ||
border: none; | ||
padding: 3px 5px; | ||
background: none; | ||
} | ||
|
||
.completed { | ||
text-decoration: line-through; | ||
color: gray; | ||
border: 1px solid gray; | ||
} |
Binary file added
BIN
+255 KB
projects/create-a-to-do-list-app-with-html-css-js/todo-list-remove-task-html.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+121 KB
projects/create-a-to-do-list-app-with-html-css-js/todo-list-vs-code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.