Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
lanzela authored Oct 25, 2023
1 parent 34e0fad commit 25679f8
Show file tree
Hide file tree
Showing 6 changed files with 194 additions and 0 deletions.
Binary file added checked.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
123 changes: 123 additions & 0 deletions todo.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@

*{
margin: 0;
padding: 0;
font-family:Arial, Helvetica, sans-serif;
box-sizing: border-box;
}

.container{
width: 100%;
min-height: 100vh;
background: #cde1d1;
padding: 10px;
}

.todo-app{
width: 100%;
max-width: 540px;
background: #fff;
margin: 100px auto 20px;
padding: 40px 30px 70px;
border-radius: 10px;
}

.todo-app h2{
color: #2b322c;
display: flex;
align-items: center;
margin-bottom: 20px;
}

.todo-app h2 img{
width: 38px;
margin-left: 5px;
margin-bottom: 2px;
}

.row{
display: flex;
align-items: center;
justify-content: space-between;
background: #edeef0;
border-radius: 10px;
padding-left: 20px;
margin-bottom: 25px;
margin-top: 0%;
}
.delete{
margin-right: 10px;
display: flex;
align-items: center
background: #edeef0;
border-radius: 50%;
}
input{
flex: 1;
border: none;
outline: none;
background: transparent;
padding: 10px;
font-weight: 14px;
}

button{
border: none;
outline: none;
padding: 16px 50px;
background: #2b322c ;
color: #fff;
font-size: 16px;
cursor: pointer;
border-radius: 10px;
}

ul li{
list-style: none;
font-size: 17px;
padding: 12px 8px 12px 50px;
user-select: none;
cursor: pointer;
position: relative;
}

ul li::before{
content: '';
position: absolute;
height: 28px;
width: 28px;
border-radius: 50%;
background-image: url(unchecked.png) ;
background-size: cover;
background-position: center;
top: 8px;
left: 8px;
}

ul li.checked{
color: #555;
text-decoration: line-through;
}

ul li.checked::before{
background-image: url(checked.jpg);

}

ul li span{
position: absolute;
right: 0;
top: 5px;
width: 40px;
height: 40px;
font-size: 22px;
color: #555;
line-height: 40px;
text-align: center;
border-radius: 50%;
}

ul li span:hover{
background-color: #edeef0;
color: #ff5945;
}
21 changes: 21 additions & 0 deletions todo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="todo.css">
<title> My To-Do List </title>
</head>
<body>
<div class="container">
<div class="todo-app">
<h2> To-Do List<img src="todologo.jpg"> </h2>
<div class="row">
<input type="text" id="input-box" placeholder="Add your task">
<button onclick="addTask()"> Add </button>
</div>
<ul id="list-container"> </ul>
</div>
</div>
<script src="todo.js"> </script>
</body>
</html>
50 changes: 50 additions & 0 deletions todo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const inputBox = document.getElementById("input-box");
const listContainer = document.getElementById("list-container");

// Add a task to the list
function addTask(){
if(inputBox.value === ""){
alert("Please Enter a Task");
}
else{
let li = document.createElement("li");
li.innerHTML = inputBox.value;
listContainer.appendChild(li);
let span = document.createElement("span");
span.innerHTML = "x";
li.appendChild(span);
}
inputBox.value = "";
saveData();
}

listContainer.addEventListener("click", function(event){
if(event.target.tagName === "LI"){
event.target.classList.toggle("checked");
saveData();
}
else if(event.target.tagName === "SPAN"){
event.target.parentElement.remove();
saveData();
}
}, false);

// allow task to be added with "enter" key and "return" key in mac
inputBox.addEventListener("keypress", function (event) {
if (event.key === "Enter") {
event.preventDefault();
addTask();
}
});

// save the data to the local storage
function saveData(){
localStorage.setItem("data", listContainer.innerHTML);
}

// show the data from the local storage
function showData(){
listContainer.innerHTML = localStorage.getItem("data");
}
showData();

Binary file added todologo.jpg
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 unchecked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 25679f8

Please sign in to comment.