From 46613c64609e731eaa2a39b977d596dabdb55dd2 Mon Sep 17 00:00:00 2001 From: anjalikarhale Date: Mon, 18 May 2026 10:15:45 +0530 Subject: [PATCH] Added dynamic visual progress bar --- index.html | 3 +++ script.js | 21 +++++++++++++++++++++ style.css | 16 ++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/index.html b/index.html index 0f7fb66..d17ca81 100644 --- a/index.html +++ b/index.html @@ -18,6 +18,9 @@

📚 Productivity Tracker

Progress: 0% (0/0 tasks completed)

+
+
+
diff --git a/script.js b/script.js index ca39a81..58c018b 100644 --- a/script.js +++ b/script.js @@ -97,4 +97,25 @@ function updateTime() { function pad(num) { return num < 10 ? "0" + num : num; +} + +const progressBar = document.getElementById("progressBar"); + +function updateProgress() { + const totalTasks = tasks.length; + const completedTasks = tasks.filter(task => task.completed).length; + + const progressPercent = + totalTasks === 0 ? 0 : (completedTasks / totalTasks) * 100; + + progressText.innerText = + `Progress: ${Math.round(progressPercent)}%`; + + progressBar.style.width = `${progressPercent}%`; + + if (progressPercent === 100) { + progressBar.style.background = "green"; + } else { + progressBar.style.background = "#4caf50"; + } } \ No newline at end of file diff --git a/style.css b/style.css index 79f3665..64d28f8 100644 --- a/style.css +++ b/style.css @@ -30,4 +30,20 @@ li { background: #eee; padding: 5px; border-radius: 5px; +} + +.progress-container { + width: 100%; + height: 12px; + background: #ddd; + border-radius: 10px; + overflow: hidden; + margin-top: 10px; +} + +#progressBar { + height: 100%; + width: 0%; + background: #4caf50; + transition: width 0.3s ease; } \ No newline at end of file