Skip to content

Commit 58e76a2

Browse files
authored
Merge pull request #26 from murdercode/feature-5plusmins
Feature 5plusmins
2 parents 9950281 + f6bc7bf commit 58e76a2

File tree

4 files changed

+119
-5
lines changed

4 files changed

+119
-5
lines changed

src/core/pomodoro-timer.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export class PomodoroTimer {
6565
this.smartPauseCountdown = document.getElementById('smart-pause-countdown');
6666
this.autoStartIndicator = document.getElementById('auto-start-indicator');
6767
this.continuousSessionIndicator = document.getElementById('continuous-session-indicator');
68+
this.timerPlusBtn = document.getElementById('timer-plus-btn');
69+
this.timerMinusBtn = document.getElementById('timer-minus-btn');
6870

6971
// Task management
7072
this.tasks = [];
@@ -201,6 +203,19 @@ export class PomodoroTimer {
201203
}
202204
});
203205

206+
// Timer adjustment buttons
207+
if (this.timerPlusBtn) {
208+
this.timerPlusBtn.addEventListener('click', () => {
209+
this.adjustTimer(5);
210+
});
211+
}
212+
213+
if (this.timerMinusBtn) {
214+
this.timerMinusBtn.addEventListener('click', () => {
215+
this.adjustTimer(-5);
216+
});
217+
}
218+
204219
// Keyboard shortcuts
205220
document.addEventListener('keydown', async (e) => {
206221
// Only trigger if not typing in an input
@@ -753,6 +768,39 @@ export class PomodoroTimer {
753768
}
754769
}
755770

771+
adjustTimer(minutes) {
772+
// Convert minutes to seconds
773+
const adjustment = minutes * 60;
774+
775+
// Add the adjustment to the current time remaining
776+
this.timeRemaining += adjustment;
777+
778+
// Ensure we don't go below 0 seconds
779+
if (this.timeRemaining < 0) {
780+
this.timeRemaining = 0;
781+
}
782+
783+
// If timer is running, we need to update the accuracy tracking
784+
if (this.isRunning && this.timerStartTime) {
785+
// Calculate how much time should remain based on the adjustment
786+
const now = Date.now();
787+
const elapsedSinceStart = Math.floor((now - this.timerStartTime) / 1000);
788+
789+
// Update the timer duration to account for the adjustment
790+
this.timerDuration = elapsedSinceStart + this.timeRemaining;
791+
}
792+
793+
// Update the display immediately
794+
this.updateDisplay();
795+
796+
// Show notification
797+
const action = minutes > 0 ? 'added' : 'subtracted';
798+
const absMinutes = Math.abs(minutes);
799+
NotificationUtils.showNotificationPing(
800+
`${absMinutes} minute${absMinutes !== 1 ? 's' : ''} ${action} ${minutes > 0 ? 'to' : 'from'} timer ⏰`
801+
);
802+
}
803+
756804
async skipSession() {
757805
this.isRunning = false;
758806
this.isPaused = false;

src/index.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,18 @@
9595

9696
<!-- Status Label -->
9797
<div style="text-align:center; position: relative">
98-
<div class="timer-status clickable" id="timer-status">
99-
<i id="status-icon" class="ri-brain-line"></i>
100-
<span id="status-text">Focus</span>
101-
<i class="ri-arrow-down-s-line tag-dropdown-arrow" id="tag-dropdown-arrow"></i>
98+
<div class="timer-status-container">
99+
<button class="timer-adjust-btn" id="timer-minus-btn" title="Subtract 5 minutes">
100+
<span>-5</span>
101+
</button>
102+
<div class="timer-status clickable" id="timer-status">
103+
<i id="status-icon" class="ri-brain-line"></i>
104+
<span id="status-text">Focus</span>
105+
<i class="ri-arrow-down-s-line tag-dropdown-arrow" id="tag-dropdown-arrow"></i>
106+
</div>
107+
<button class="timer-adjust-btn" id="timer-plus-btn" title="Add 5 minutes">
108+
<span>+5</span>
109+
</button>
102110
</div>
103111
<!-- Tag Dropdown Menu -->
104112
<div class="tag-dropdown-menu" id="tag-dropdown-menu">

src/styles/timer.css

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,50 @@
66
background: transparent;
77
}
88

9+
/* Timer Status Container with Adjust Buttons */
10+
.timer-status-container {
11+
display: flex;
12+
align-items: start;
13+
justify-content: center;
14+
gap: 0.25rem;
15+
margin-bottom: 0.5rem;
16+
}
17+
18+
.timer-adjust-btn {
19+
display: flex;
20+
align-items: center;
21+
justify-content: center;
22+
width: 32px;
23+
height: 32px;
24+
border: none;
25+
background-color: transparent;
26+
cursor: pointer;
27+
transition: all 0.2s ease;
28+
font-size: 12px;
29+
font-weight: 600;
30+
color: var(--focus-timer-color);
31+
padding: 0;
32+
}
33+
34+
.timer-adjust-btn:hover {
35+
transform: scale(1.05);
36+
}
37+
38+
.timer-adjust-btn:active {
39+
transform: scale(0.95);
40+
}
41+
42+
.timer-adjust-btn i {
43+
font-size: 14px;
44+
line-height: 1;
45+
}
46+
47+
.timer-adjust-btn span {
48+
font-size: 14px;
49+
font-weight: 700;
50+
line-height: 1;
51+
}
52+
953
/* Timer status label - positioned outside timer-container in HTML */
1054
#timer-view .timer-status {
1155
font-size: 14px;
@@ -396,6 +440,20 @@
396440
color: var(--long-break-timer-color);
397441
}
398442

443+
/* Timer adjust buttons for different timer modes */
444+
.container.focus .timer-adjust-btn {
445+
color: var(--focus-timer-color);
446+
}
447+
448+
.container.break .timer-adjust-btn {
449+
color: var(--break-timer-color);
450+
}
451+
452+
453+
.container.longBreak .timer-adjust-btn {
454+
color: var(--long-break-timer-color);
455+
}
456+
399457
/* Overtime styles for continuous sessions */
400458
.container.overtime .timer-minutes,
401459
.container.overtime .timer-seconds {

src/utils/theme-loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ThemeLoader {
3939
// that gets updated by the build process or manually maintained
4040

4141
// This could be enhanced to use a build-time script that generates this list
42-
const knownThemes = [
42+
const knownThemes = [
4343
'espresso.css',
4444
'pipboy.css',
4545
'pommodore64.css'

0 commit comments

Comments
 (0)