Membuat Pomodoro Timer untuk Produktivitas Belajar dan Kerja
Membuat Pomodoro Timer untuk Produktivitas Belajar dan Kerja
Dipublikasikan: Juli 2026
Teknik Pomodoro adalah metode manajemen waktu yang sangat populer. Tutorial ini membuat timer Pomodoro dengan sesi fokus 25 menit dan istirahat 5 menit.
Fitur
- Timer fokus 25 menit
- Timer istirahat 5 menit
- Notifikasi suara
- Riwayat sesi hari ini
Kode Lengkap
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Pomodoro Timer</title>
<style>
* { margin:0; padding:0; box-sizing:border-box; }
body { font-family:'Segoe UI',Arial,sans-serif; background:#f0f2f5; min-height:100vh; display:flex; justify-content:center; align-items:center; padding:20px; }
.container { background:#fff; border-radius:20px; padding:35px; box-shadow:0 20px 60px rgba(0,0,0,0.1); width:100%; max-width:450px; text-align:center; }
h1 { color:#2d3436; margin-bottom:20px; }
.mode-tabs { display:flex; gap:10px; justify-content:center; margin-bottom:25px; }
.mode-tab { padding:10px 22px; border:2px solid #dfe6e9; border-radius:10px; cursor:pointer; font-size:14px; background:#fff; }
.mode-tab.active { background:#6c5ce7; color:#fff; border-color:#6c5ce7; }
.timer { font-size:80px; font-weight:700; color:#2d3436; font-variant-numeric:tabular-nums; margin:20px 0; }
.controls { display:flex; gap:12px; justify-content:center; }
.controls button { padding:14px 32px; border:none; border-radius:12px; cursor:pointer; font-size:16px; }
.btn-start { background:#00b894; color:#fff; }
.btn-start:hover { background:#00a381; }
.btn-pause { background:#fdcb6e; color:#2d3436; }
.btn-pause:hover { background:#f0c05e; }
.btn-reset { background:#dfe6e9; color:#636e72; }
.btn-reset:hover { background:#d0d7dd; }
.session-count { margin-top:20px; color:#636e72; font-size:14px; }
.session-count span { font-weight:700; color:#6c5ce7; }
.progress-ring { margin:15px auto; width:220px; height:220px; position:relative; }
.progress-ring svg { transform:rotate(-90deg); }
.progress-ring .bg { fill:none; stroke:#dfe6e9; stroke-width:6; }
.progress-ring .fg { fill:none; stroke:#6c5ce7; stroke-width:6; stroke-linecap:round; transition:stroke-dashoffset 1s; }
.timer-text { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); font-size:48px; font-weight:700; color:#2d3436; }
</style>
</head>
<body>
<div class="container">
<h1>🅠Pomodoro Timer</h1>
<div class="mode-tabs">
<div class="mode-tab active" id="tabFocus" onclick="setMode('focus')">Fokus 25m</div>
<div class="mode-tab" id="tabBreak" onclick="setMode('break')">Istirahat 5m</div>
</div>
<div class="progress-ring">
<svg width="220" height="220">
<circle class="bg" cx="110" cy="110" r="100" />
<circle class="fg" id="progress" cx="110" cy="110" r="100" stroke-dasharray="628.3" stroke-dashoffset="0" />
</svg>
<div class="timer-text" id="timerDisplay">25:00</div>
</div>
<div class="controls">
<button class="btn-start" id="startBtn" onclick="startTimer()">Mulai</button>
<button class="btn-reset" onclick="resetTimer()">Reset</button>
</div>
<div class="session-count">Sesi selesai: <span id="sessionCount">0</span></div>
</div>
<script>
let mode = 'focus', timeLeft = 1500, totalTime = 1500, running = false, interval = null, sessions = 0;
const circumference = 2 * Math.PI * 100;
function setMode(m) {
if (running) return;
mode = m;
document.getElementById('tabFocus').classList.toggle('active', m === 'focus');
document.getElementById('tabBreak').classList.toggle('active', m === 'break');
timeLeft = m === 'focus' ? 1500 : 300;
totalTime = timeLeft;
updateDisplay();
}
function startTimer() {
if (running) { clearInterval(interval); running = false; document.getElementById('startBtn').textContent = 'Lanjut'; return; }
running = true; document.getElementById('startBtn').textContent = 'Jeda';
interval = setInterval(() => {
timeLeft--;
updateDisplay();
if (timeLeft <= 0) {
clearInterval(interval); running = false;
document.getElementById('startBtn').textContent = 'Mulai';
if (mode === 'focus') { sessions++; document.getElementById('sessionCount').textContent = sessions; }
alert(mode === 'focus' ? 'Waktu fokus selesai! Saatnya istirahat.' : 'Istirahat selesai! Kembali fokus.');
setMode(mode === 'focus' ? 'break' : 'focus');
}
}, 1000);
}
function resetTimer() { clearInterval(interval); running = false; document.getElementById('startBtn').textContent = 'Mulai'; setMode(mode); }
function updateDisplay() {
const m = Math.floor(timeLeft / 60); const s = timeLeft % 60;
document.getElementById('timerDisplay').textContent = String(m).padStart(2,'0') + ':' + String(s).padStart(2,'0');
const offset = circumference * (1 - timeLeft / totalTime);
document.getElementById('progress').style.strokeDashoffset = offset;
}
setMode('focus');
</script>
</body>
</html>
Cara Jalankan
- Simpan sebagai pomodoro.html
- Buka di browser
- Mulai sesi fokus dan tingkatkan produktivitas!
"Fokus 25 menit, istirahat 5 menit. Produktivitas maksimal!"
Label: Tutorial, Web App, Pomodoro, Timer, Produktivitas, JavaScript, HTML, CSS
Posting Komentar untuk "Membuat Pomodoro Timer untuk Produktivitas Belajar dan Kerja"
Terimaksih telah menyempatkan hadir di blog saya
Posting Komentar