Skip to content

Commit 0c7d9ba

Browse files
authored
Merge pull request #47 from tajulafreen/Pomodoro_Timer
50Projects-HTML-CSS-JavaScript : Pomodoro timer
2 parents 41b672c + 58eb81c commit 0c7d9ba

File tree

4 files changed

+141
-0
lines changed

4 files changed

+141
-0
lines changed

Diff for: README.md

+13
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,19 @@ In order to run this project you need:
496496
</details>
497497
</li>
498498

499+
<li>
500+
<details>
501+
<summary>Pomodoro Timer</summary>
502+
<p>The Productivity Timer (Pomodoro Timer) is a simple yet effective timer application based on the Pomodoro technique. It helps users stay productive by alternating between focus intervals (e.g., 5 minutes) and short breaks (e.g., 2 minutes). The app provides visual cues through animations and sound alerts to signal transitions between focus and break periods.
503+
504+
</p>
505+
<ul>
506+
<li><a href="https://tajulafreen.github.io/50Projects-HTML-CSS-JavaScript/Source-Code/PomodoroTimer/">Live Demo</a></li>
507+
<li><a href="https://github.com/tajulafreen/50Projects-HTML-CSS-JavaScript/tree/main/Source-Code/PomodoroTimer">Source</a></li>
508+
</ul>
509+
</details>
510+
</li>
511+
499512
</ol>
500513

501514
<p align="right">(<a href="#readme-top">back to top</a>)</p>

Diff for: Source-Code/PomodoroTimer/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
<title>Productivity Timer</title>
7+
<link rel="stylesheet" href="style.css">
8+
</head>
9+
<body>
10+
<div class="container">
11+
<h1>Productivity Timer</h1>
12+
<div class="timer-display">
13+
<span id="minutes">25</span>:<span id="seconds">00</span>
14+
</div>
15+
<div class="controls">
16+
<button id="start-btn">Start</button>
17+
<button id="reset-btn">Reset</button>
18+
</div>
19+
<p id="status">Focus Session</p>
20+
</div>
21+
<script src="script.js"></script>
22+
</body>
23+
</html>

Diff for: Source-Code/PomodoroTimer/script.js

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
const startBtn = document.getElementById('start-btn');
2+
const resetBtn = document.getElementById('reset-btn');
3+
const minutesDisplay = document.getElementById('minutes');
4+
const secondsDisplay = document.getElementById('seconds');
5+
const statusDisplay = document.getElementById('status');
6+
7+
let timerInterval;
8+
let isFocusSession = true; // Start with a focus session
9+
const focusTime = 5 * 60; // 5 minutes in seconds
10+
const breakTime = 5 * 60; // 5 minutes in seconds
11+
let timeRemaining = focusTime;
12+
13+
const updateDisplay = () => {
14+
const minutes = Math.floor(timeRemaining / 60);
15+
const seconds = timeRemaining % 60;
16+
minutesDisplay.textContent = String(minutes).padStart(2, '0');
17+
secondsDisplay.textContent = String(seconds).padStart(2, '0');
18+
};
19+
20+
const toggleSession = () => {
21+
isFocusSession = !isFocusSession;
22+
timeRemaining = isFocusSession ? focusTime : breakTime;
23+
statusDisplay.textContent = isFocusSession
24+
? 'Focus Session'
25+
: 'Break Session';
26+
updateDisplay();
27+
};
28+
29+
const startTimer = () => {
30+
if (timerInterval) return; // Prevent multiple intervals
31+
timerInterval = setInterval(() => {
32+
if (timeRemaining > 0) {
33+
timeRemaining -= 1;
34+
updateDisplay();
35+
} else {
36+
clearInterval(timerInterval);
37+
timerInterval = null;
38+
toggleSession();
39+
}
40+
}, 1000);
41+
};
42+
43+
const resetTimer = () => {
44+
clearInterval(timerInterval);
45+
timerInterval = null;
46+
timeRemaining = isFocusSession ? focusTime : breakTime;
47+
updateDisplay();
48+
};
49+
50+
startBtn.addEventListener('click', startTimer);
51+
resetBtn.addEventListener('click', resetTimer);
52+
53+
// Initialize display
54+
updateDisplay();

Diff for: Source-Code/PomodoroTimer/style.css

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
body {
2+
font-family: Arial, sans-serif;
3+
background-color: #f0f4f8;
4+
color: #333;
5+
text-align: center;
6+
margin: 0;
7+
padding: 0;
8+
}
9+
10+
.container {
11+
max-width: 400px;
12+
margin: 100px auto;
13+
padding: 20px;
14+
background: #fff;
15+
border-radius: 10px;
16+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
17+
}
18+
19+
h1 {
20+
margin-bottom: 20px;
21+
}
22+
23+
.timer-display {
24+
font-size: 3rem;
25+
margin: 20px 0;
26+
}
27+
28+
.controls button {
29+
font-size: 1rem;
30+
padding: 10px 20px;
31+
margin: 5px;
32+
border: none;
33+
border-radius: 5px;
34+
cursor: pointer;
35+
}
36+
37+
#start-btn {
38+
background-color: #28a745;
39+
color: white;
40+
}
41+
42+
#reset-btn {
43+
background-color: #dc3545;
44+
color: white;
45+
}
46+
47+
#status {
48+
font-size: 1.2rem;
49+
margin-top: 20px;
50+
color: #555;
51+
}

0 commit comments

Comments
 (0)