Skip to content

Commit 94172e9

Browse files
committed
📝🤔Todo
1 parent 7dc21e0 commit 94172e9

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

Todo/app.js

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ const db = getFirestore(app);
1616

1717
const todoHandler = document.getElementById('addTodoBtn');
1818
const todoInput = document.getElementById('todoInput');
19-
const todoList = document.getElementById('todoList');
20-
const li = document.createElement('li')
21-
li.className = "todo-item"
19+
const main = document.getElementById('main');
20+
const ul = document.createElement('ul')
21+
ul.className = "todo-list"
22+
ul.id = "todoList"
2223

2324

2425
todoHandler.addEventListener('click', async () => {
@@ -44,7 +45,7 @@ todoHandler.addEventListener('click', async () => {
4445
async function fetching() {
4546
try {
4647
const querySnapshot = await getDocs(collection(db, 'Todo'));
47-
todoList.innerHTML = ""
48+
main.innerHTML = ""
4849
querySnapshot.forEach((doc) => {
4950
const getId = doc.data().id
5051
const getTodo = doc.data().todo
@@ -59,21 +60,16 @@ async function fetching() {
5960

6061
function append(id, todo) {
6162
todoInput.value = ""
62-
li.innerHTML += `
63+
ul.innerHTML += `
64+
<li class="todo-item">
6365
<input id="${id}" class="inp" value=${todo} type="text" readonly>
64-
<button id="${id}" onclick="edit(this)" class="btn-edit">Edit</button>
66+
<button id="${id}" class="btn-edit">Edit</button>
6567
<button id="${id}" class="btn-delete">Delete</button>
68+
</li>
6669
`
67-
todoList.appendChild(li)
70+
main.appendChild(ul)
6871
console.log(todoList);
6972

7073
}
7174

72-
function edit(button) {
73-
// const getClass = document.querySelector('.btn-edit')
74-
// console.log(getClass);
75-
console.log(button);
76-
77-
}
78-
7975
window.addEventListener("DOMContentLoaded", fetching)

Todo/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ <h2>🔥 Todo App</h2>
1818
<input type="text" id="todoInput" placeholder="Enter your task..." />
1919
<button id="addTodoBtn">Add</button>
2020
</div>
21-
<ul class="todo-list" id="todoList">
22-
23-
</ul>
21+
<div id="main"></div>
2422
</div>
2523
</body>
2624

Todo/style.css

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,16 @@
6868
display: flex;
6969
flex-direction: column;
7070
gap: 10px;
71-
padding: 0;
72-
margin: 0;
7371
}
7472

7573
.todo-item {
7674
background: #f1f1f1;
77-
/* padding: 12px 11px; */
78-
gap: 10px;
75+
padding: 12px;
7976
border-radius: 8px;
80-
/* display: flex; */
81-
/* justify-content: space-around; */
82-
/* align-items: center; */
83-
margin: 10px;
77+
display: flex;
78+
justify-content: space-between;
79+
align-items: center;
80+
transition: background 0.3s ease;
8481
}
8582

8683
.todo-item .btn-edit,

0 commit comments

Comments
 (0)