-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
194 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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; | ||
} |
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,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> |
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 @@ | ||
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(); | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.