diff --git a/README.md b/README.md index 8f92214..c206a26 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,22 @@ TO-DO-LIST (Made using HTML5 CSS3 and JavaScript) -You can see the website live at: https://5codeman.github.io/TO-DO-LIST/ +[Live Demo](https://5codeman.github.io/TO-DO-LIST/) -ABOUT THIS PROJECT-: +## ABOUT THIS PROJECT-: - 1. In this project i have created a simple to-do app using HTML CSS and JavaScript. + 1. In this project which I have created is a simple to-do app using HTML CSS and JavaScript. 2. Built a To-Do List application to make a list of daily works written down in one place. - 3. Implemented functionalities like add task, remove task, filter tasks and also mark tasks as done. + 3. Implemented functionalities like add task, edit task, remove task, filter tasks and also mark tasks as done. +## Getting Started +To run this project locally, follow these steps: + 1. Clone the repository: + ```bash + git clone https://github.com/5codeman/TO-DO-LIST.git + ``` + + 2. Open the 'index.html' file in you web browser. + 3. Start managing you to-do list efficiently! + +Happy task management! 🚀 \ No newline at end of file diff --git a/index.html b/index.html index b84ae52..acc6893 100644 --- a/index.html +++ b/index.html @@ -49,6 +49,16 @@

Todo List

+ +
+ +
diff --git a/index.js b/index.js index 6da3c24..3550b6e 100644 --- a/index.js +++ b/index.js @@ -6,6 +6,7 @@ var todoInput = document.getElementById("todo-input") var deleteAllButton = document.getElementById("delete-all") var allTodos = document.getElementById("all-todos"); var deleteSButton = document.getElementById("delete-selected") +let CurrentSelectedItem; //event listners for add and delete @@ -14,13 +15,16 @@ deleteAllButton.addEventListener("click", deleteAll) deleteSButton.addEventListener("click", deleteS) -//event listeners for filtersk +//event listeners for filters document.addEventListener('click', (e) => { if (e.target.className.split(' ')[0] == 'complete' || e.target.className.split(' ')[0] == 'ci') { completeTodo(e); } if (e.target.className.split(' ')[0] == 'delete' || e.target.className.split(' ')[0] == 'di') { - deleteTodo(e) + deleteTodo(e); + } + if (e.target.className.split(' ')[0] === 'edit' || e.target.className.split(' ')[0] === 'ed') { + editEntry(e); } if (e.target.id == "all") { viewAll(); @@ -33,6 +37,7 @@ document.addEventListener('click', (e) => { } }) + //event listner for enter key todoInput.addEventListener('keypress', (e) => { if (e.key === 'Enter') { @@ -40,6 +45,56 @@ todoInput.addEventListener('keypress', (e) => { } }); +// Edition functionality provider fucntions +function editEntry(entry) { + const listItem = entry.target.closest('li'); + const itemId = listItem.getAttribute('id'); + + CurrentSelectedItem = todoList.find(e => e.id == itemId); + + const taskTitle = CurrentSelectedItem.task; + openEditModal(taskTitle); +} + +function openEditModal(taskTitle) { + const editModal = document.getElementById('editModal'); + const overlay = document.getElementById('overlay'); + const oldTitle = document.getElementById('oldTitle'); + + // Set the current task title in the input field + oldTitle.innerText += taskTitle; + + // Display the modal and overlay + editModal.style.display = 'block'; + overlay.style.display = 'block'; +} + +function closeEditModal() { + const editModal = document.getElementById('editModal'); + const overlay = document.getElementById('overlay'); + const oldTitle = document.getElementById('oldTitle'); + const editTaskInput = document.getElementById('editTaskInput'); + + // Reset the text of oldTitle label and editTaskInput textbox + oldTitle.innerText = "Old: "; + editTaskInput.value = ""; + + // Hide the modal and overlay + editModal.style.display = 'none'; + overlay.style.display = 'none'; + + addinmain(todoList); +} + +function updateTaskTitle() { + const editTaskInput = document.getElementById('editTaskInput'); + const taskTitle = editTaskInput.value; + + CurrentSelectedItem.task = taskTitle; + + // Close the edit modal + closeEditModal(); +} //updates the all the remaining, completed and main list function update() { @@ -81,17 +136,21 @@ function addinmain(todoList) { allTodos.innerHTML = "" todoList.forEach(element => { var x = `
  • -

    ${element.complete ? `${element.task}` : element.task}

    -
    - - - -
    -
  • ` +

    ${element.complete ? `${element.task}` : element.task}

    +
    + + + + + +
    + ` allTodos.innerHTML += x }); } @@ -163,6 +222,7 @@ function viewRemaining() { addinmain(remList); } + function viewAll() { addinmain(todoList); } \ No newline at end of file diff --git a/style.css b/style.css index a9325e4..84be36e 100644 --- a/style.css +++ b/style.css @@ -1,276 +1,302 @@ -@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;800;900&display=swap'); +@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;800;900&display=swap"); /* for whole documents */ * { - margin: 0; - padding: 0; - box-sizing: border-box; - font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif; + margin: 0; + padding: 0; + box-sizing: border-box; + font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif; } /* for hide scroll bar */ ::-webkit-scrollbar { - display: none; + display: none; } -body{ - position: relative; - height: 100vh; - display: flex; - justify-content: center; - align-items: center; - background-color: rgb(4, 4, 35); +body { + position: relative; + height: 100vh; + display: flex; + justify-content: center; + align-items: center; + background-color: rgb(4, 4, 35); } - - .container { - display: flex; - align-items: center; - justify-content: center; - flex-direction: column; - margin: 0 400px; - min-width: 500px; - max-width: 1000px; - background-image: linear-gradient(aqua, rgb(249, 146, 164)); - border-radius: 20px; - padding: 20px; + display: flex; + align-items: center; + justify-content: center; + flex-direction: column; + margin: 0 400px; + min-width: 500px; + max-width: 1000px; + background-image: linear-gradient(aqua, rgb(249, 146, 164)); + border-radius: 20px; + padding: 20px; } /* header */ .container header { - display: flex; - justify-content: center; - align-items: center; - flex-direction: column; - width: 100%; - margin-bottom: 20px; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + width: 100%; + margin-bottom: 20px; } header h1 { - font-size: 30px; - font-weight: bolder; - margin-bottom: 10px; - letter-spacing: 1px; - word-spacing: 5px; + font-size: 30px; + font-weight: bolder; + margin-bottom: 10px; + letter-spacing: 1px; + word-spacing: 5px; } - /* input-section */ header .input-section { - width: 100%; - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - width: 100%; - height: 100%; + width: 100%; + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + width: 100%; + height: 100%; } .input-section input { - margin-right: 10px; - max-width: 100%; + margin-right: 10px; + max-width: 100%; } .max-w-xs { - max-width: 20rem; + max-width: 20rem; } .w-full { - width: 100%; + width: 100%; } .input { - border-radius: 0.5rem; - height: 3rem; - border-width: 2px black solid; - flex-shrink: 1; - padding: 0rem 1rem; - font-size: 1.2rem; - line-height: 2; + border-radius: 0.5rem; + height: 3rem; + border-width: 2px black solid; + flex-shrink: 1; + padding: 0rem 1rem; + font-size: 1.2rem; + line-height: 2; } /* todofilters */ -.todos-filter, .filters { - display: flex; - justify-content: space-between; - align-items: center; - width: 100%; - height: 100%; - margin-bottom: 10px; +.todos-filter, +.filters { + display: flex; + justify-content: space-between; + align-items: center; + width: 100%; + height: 100%; + margin-bottom: 10px; } .filters { margin-top: 10px; } - .todos-list { - display: flex; - flex-direction: column; - justify-content: space-between; - align-items: center; - min-height: 100%; - max-height: 54vh; - overflow-y: scroll; - width: 100%; + display: flex; + flex-direction: column; + justify-content: space-between; + align-items: center; + min-height: 100%; + max-height: 54vh; + overflow-y: scroll; + width: 100%; } -.todos-list .todo-item{ - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; - padding: 10px; - width: 100%; +.todos-list .todo-item { + display: flex; + flex-direction: row; + justify-content: space-between; + align-items: center; + padding: 10px; + width: 100%; } -.todo-item{ - background-color: wheat; - border-radius: 12px; - margin-bottom: 5px; +.todo-item { + background-color: wheat; + border-radius: 12px; + margin-bottom: 5px; } -.todo-item p{ - margin-right: 10px; - font-size: 1.4rem; +.todo-item p { + margin-right: 10px; + font-size: 1.4rem; } .todo-item .todo-actions { - display: flex; - flex-direction: row; - align-items: center; - justify-content: end; - width: 100%; - height: 100%; + display: flex; + flex-direction: row; + align-items: center; + justify-content: end; + width: 100%; + height: 100%; } -.todo-actions button:not(:last-child){ - margin-right: 10px; +.todo-actions button:not(:last-child) { + margin-right: 10px; } -.di, .ci{ - pointer-events: none; +.di, +.ci { + pointer-events: none; } +.line { + text-decoration: line-through; +} -.line{ - text-decoration: line-through; +/*buttons styling*/ +.btn { + cursor: pointer; + user-select: none; + border: none; + outline: none; + text-align: center; + border-radius: 0.5rem; + height: 3rem; + min-height: 3rem; + text-transform: uppercase; + border-width: 1px; + animation: button-pop var(--animation-btn, 0.25s) ease-in-out; + flex-wrap: wrap; + flex-shrink: 0; + justify-content: center; + align-items: center; + padding-left: 1rem; + padding-right: 1rem; + font-size: 0.875rem; + font-weight: 600; + line-height: 1em; + text-decoration-line: none; + transition: 0.2s all cubic-bezier(0.4, 0, 0.2, 1); + display: inline-flex; } +.btn:hover { + background-color: rgb(108, 109, 110); + color: white; +} -/*buttons styling*/ -.btn{ - cursor: pointer; - user-select: none; - border: none; - outline: none; - text-align: center; - border-radius: 0.5rem; - height: 3rem; - min-height: 3rem; - text-transform: uppercase; - border-width:1px; - animation: button-pop var(--animation-btn,.25s)ease-in-out; - flex-wrap: wrap; - flex-shrink: 0; - justify-content: center; - align-items: center; - padding-left: 1rem; - padding-right: 1rem; - font-size: .875rem; - font-weight: 600; - line-height: 1em; - text-decoration-line: none; - transition: .2s all cubic-bezier(.4,0,.2,1); - display: inline-flex; -} - -.btn:hover{ - background-color: rgb(108, 109, 110); - color: white; -} - - -.btn-add{ - background-color: green; - color: white -} -.btn-add:hover{ - background-color: white; - color:rgb(255, 221, 0); -} - -.btn-success{ - opacity: 1; - background-color:rgb(50, 177, 50); - color: white -} - -.btn-success:hover{ - background-color: white; - color:rgb(50, 177, 50); -} - -.btn-error{ - opacity: 1; - background-color:rgb(246, 77, 4); - color: white -} -.btn-error:hover{ - background-color: white; - color:rgb(246, 77, 4); +.btn-add { + background-color: green; + color: white; +} +.btn-add:hover { + background-color: white; + color: rgb(255, 221, 0); +} + +.btn-success { + opacity: 1; + background-color: rgb(50, 177, 50); + color: white; +} + +.btn-success:hover { + background-color: white; + color: rgb(50, 177, 50); +} + +.btn-error { + opacity: 1; + background-color: rgb(246, 77, 4); + color: white; +} +.btn-error:hover { + background-color: white; + color: rgb(246, 77, 4); } /* dropdown*/ .dropbtn { - background-color: green; - color: white; - padding: 10px 16px; - font-size: 16px; - border: none; - cursor: pointer; - border-radius: 5px; - } - - .dropdown { - position: relative; - display: inline-block; - } - - .dropdown-content { - display: none; - position: absolute; - background-color: #f9f9f9; - min-width: 160px; - box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); - z-index: 1; - } - - .dropdown-content a { - color: black; - padding: 12px 16px; - text-decoration: none; - display: block; - } - - .dropdown-content a:hover {background-color: #f1f1f1} - - .dropdown:hover .dropdown-content { - display: block; - } - - .dropdown:hover .dropbtn { - background-color: white; - color: yellowgreen; - } + background-color: green; + color: white; + padding: 10px 16px; + font-size: 16px; + border: none; + cursor: pointer; + border-radius: 5px; +} + +.dropdown { + position: relative; + display: inline-block; +} + +.dropdown-content { + display: none; + position: absolute; + background-color: #f9f9f9; + min-width: 160px; + box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); + z-index: 1; +} + +.dropdown-content a { + color: black; + padding: 12px 16px; + text-decoration: none; + display: block; +} + +.dropdown-content a:hover { + background-color: #f1f1f1; +} + +.dropdown:hover .dropdown-content { + display: block; +} + +.dropdown:hover .dropbtn { + background-color: white; + color: yellowgreen; +} +.modal { + display: none; + position: fixed; + top: 40%; + left: 2%; + padding: 20px; + background-color: white; + border: 1px solid #ccc; + z-index: 1000; +} +.overlay { + display: none; + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0, 0, 0, 0.5); + z-index: 999; +} + +.modal label { + display: flex; + justify-content: left; + align-items: left; + flex-direction: row; + width: 100%; + margin-bottom: 20px; +} /* Responsive */ @media only screen and (max-width: 530px) { - .container { - margin: 0 20px; - max-width: 96%; - min-width: 96%; - } + .container { + margin: 0 20px; + max-width: 96%; + min-width: 96%; + } }