Skip to content

Commit 95cf200

Browse files
committed
project 1 - to do app
0 parents  commit 95cf200

File tree

3 files changed

+91
-0
lines changed

3 files changed

+91
-0
lines changed

01_to-do-app/index.html

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
7+
<title>Document</title>
8+
</head>
9+
<body class="bg-gray-900">
10+
<div class="flex flex-col items-center justify-center h-screen">
11+
<h1 class="text-2xl font-bold text-white">TO-DO-LIST</h1>
12+
13+
<div class="p-8">
14+
<input
15+
type="text"
16+
id="taskInput"
17+
placeholder="Enter task"
18+
class="flex-grow p-2 border border-gray-600 rounded-lg text-white"
19+
>
20+
<button
21+
id="addTaskBtn"
22+
class="text-white bg-gray-600 p-2 rounded-lg"
23+
>Add</button>
24+
</div>
25+
26+
<div
27+
id="taskList"
28+
class="flex flex-col gap-2 space-y-1"
29+
>
30+
31+
</div>
32+
33+
</div>
34+
35+
36+
<script src="script.js"></script>
37+
38+
</body>
39+
</html>

01_to-do-app/script.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
const taskInput = document.getElementById('taskInput');
3+
const addTaskBtn = document.getElementById('addTaskBtn');
4+
const taskList = document.getElementById('taskList');
5+
6+
addTaskBtn.addEventListener('click', function() {
7+
let taskText = taskInput.value.trim();
8+
9+
if(taskText !== '') {
10+
let listItem = document.createElement('li');
11+
listItem.className = "flex justify-between items-center";
12+
13+
let taskSpan = document.createElement('span');
14+
taskSpan.textContent = taskText;
15+
taskSpan.className = "text-gray-100 gap-6";
16+
17+
let buttonsDiv = document.createElement('div');
18+
19+
const doneButton = document.createElement('button');
20+
doneButton.textContent = 'done';
21+
doneButton.className = 'text-green-500';
22+
doneButton.addEventListener('click', () => {
23+
taskSpan.classList.toggle('line-through');
24+
// taskSpan.classList.toggle('text-gray-500');
25+
});
26+
27+
const deleteButton = document.createElement('button');
28+
deleteButton.textContent = 'delete';
29+
deleteButton.className = 'flex text-red-500 ';
30+
deleteButton.addEventListener('click', () => {
31+
listItem.remove();
32+
});
33+
34+
listItem.appendChild(taskSpan);
35+
buttonsDiv.appendChild(doneButton);
36+
buttonsDiv.appendChild(deleteButton);
37+
listItem.appendChild(buttonsDiv);
38+
taskList.appendChild(listItem);
39+
40+
taskInput.value = '';
41+
} else {
42+
alert('Enter any task!');
43+
}
44+
});

01_to-do-app/tailwind.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** @type {import('tailwindcss').Config} */
2+
module.exports = {
3+
content: ["./*.html"], // This tells Tailwind to scan all HTML files in the root
4+
theme: {
5+
extend: {},
6+
},
7+
plugins: [],
8+
};

0 commit comments

Comments
 (0)