A lightweight focus timer built with vanilla JavaScript, designed around a clear state machine with persistent session data.
Live Demo
👉 https://selladurais.github.io/focus-timer/
This project was built to demonstrate clean state management, predictable timer behavior, and data persistence without relying on frameworks.
The focus was correctness, edge-case handling, and maintainable logic rather than UI libraries.
- Deterministic Start / Pause / Resume flow
- Configurable focus session duration
- Distraction tracking per session
- Persistent session history with timestamps
- Derived statistics (total focus time, sessions, average distractions)
- LocalStorage-based persistence
- Dark / Light mode
- Mobile-friendly layout
- Explicit state machine for timer control
- Defensive handling of pause/resume edge cases
- Derived state calculated without mutating core logic
- No framework abstractions — plain JavaScript only
- HTML5
- CSS3 (CSS variables, dark mode)
- Vanilla JavaScript
- Clone or download the repository
- Open
index.htmlin any modern browser - No build tools or dependencies required
v1.1 (Frozen)
This version is intentionally frozen after implementing derived session statistics without modifying the original state logic.