Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                	<div class="container">
		<header>
			<h1>Pomodoro Clock</h1>
			<div class="set-time">
				<div class="work-length">
					<h3>Work Time</h3>
					<button><i class="set-timer work-minus ion-chevron-down"></i></button>
					<span class="work-time">25</span>
					<button><i class="set-timer work-plus ion-chevron-up"></i></button>
				</div>
				<div class="break-length">
					<h3>Break Time</h3>
					<button><i class="set-timer break-minus ion-chevron-down"></i></button>
					<span class="break-time">5</span>
					<button><i class="set-timer break-plus ion-chevron-up"></i></button>
				</div>
			</div>
		</header>
		<section class="clock-section">
			<div class="clock-wrapper">
				<div class="clock-content">
					<p class="status">Work</p>
					<h1 class="timer">
					<span class="minute">25</span>:<span class="seconds">00</span></h1>
				</div>
			</div>
		</section>
		<section class="buttons-section">
			<div class="buttons-wrapper">
				<button class="play-button">
      			<i class="ion-play"> </i>
      		</button>
				<button class="pause-button">
      			<i class="ion-pause"> </i>
      		</button>
				<button class="reset-button">
      			<i class="ion-loop"> </i>
      		</button>
			</div>
		</section>
	</div>
              
            
!

CSS

              
                * {
	margin: 0;
	padding: 0;
	-webkit-box-sizing: border-box;
	box-sizing: border-box;
}

html,
body {
	font-family: Arial, sans-serif;
	font-size: 20px;
	background-color: #06032a;
	color: #e3e3e3;
	text-align: center;
}

.container,
.clock-wrapper,
.reset-wrapper {
	max-width: 1140px;
	margin: 0 auto;
}

header {
	margin: 50px 0 0 0;

}

h1,
h3 {
	font-weight: 400;
	letter-spacing: 1px
}

h1 {
	font-size: 300%;
}

h3 {
	font-size: 150%;
	margin: 0 0 10px 0;
}

button {
	background-color: #06032a;
	border: none;
	cursor: pointer;
}

button:focus {
	outline: none;
}

.set-time {
	display: -webkit-inline-box;
	display: -ms-inline-flexbox;
	display: inline-flex;
	margin: 30px 0 0 0;
}

.work-length,
.break-length {
	padding: 0 30px;
}

.work-time,
.break-time {
	font-size: 150%;
}

i {
	padding: 0 10px;
	color: #4678ff;
}

i:hover {
	color: #b7b7f0;
}

.clock-wrapper {
	margin: 50px auto 20px auto;
	width: 500px;
	height: 250px;
	border: 10px solid #0f3396;
	border-radius: 10px;
	letter-spacing: 2px;
}

.clock-content h1 {
	letter-spacing: 2px;
}

.clock-content {
	position: relative;
	top: 50%;
	-webkit-transform: translateY(-50%);
	transform: translateY(-50%);
}

.status {
	font-size: 300%;
	font-weight: 700;
	color: #f43a3a;
		text-transform: uppercase;
}

.timer {
	font-family: "Orbitron", sans-serif;
	font-size: 500%;
}

.buttons-wrapper {
	margin: 20px auto;
}

.ion-chevron-down,
.ion-chevron-up {
	font-size: 30px;
}

.play-button,
.pause-button,
.reset-button {
	font-size: 400%;
	margin: 0 10px;
}

              
            
!

JS

              
                (function () {
	const setWork = document.querySelector(".work-time");
	const setBreak = document.querySelector(".break-time");
	const minutes = document.querySelector(".minute");
	const seconds = document.querySelector(".seconds");
	let initialWork = 25;
	let initialBreak = 5;
	let isCounting = false;
	let workTick;
	let breakTick;

	timerHandlers();

	function timerHandlers() {
		const setTimer = document.getElementsByClassName("set-timer");

		for (let i = 0; i < setTimer.length; i++) {
			setTimer[i].addEventListener("click", function (e) {
				const workMinus = e.target.classList.contains("work-minus");
				const workPlus = e.target.classList.contains("work-plus");
				const breakMinus = e.target.classList.contains("break-minus");
				const breakPlus = e.target.classList.contains("break-plus");

				if (workMinus && !isCounting && initialWork > 1) {
					initialWork--
					setWork.textContent = initialWork;
					minutes.textContent = initialWork;
				} else if (workPlus && !isCounting) {
					initialWork++;
					setWork.textContent = initialWork;
					minutes.textContent = initialWork;
				} else if (breakMinus && !isCounting && initialBreak > 1) {
					initialBreak--
					setBreak.textContent = initialBreak;
				} else if (breakPlus && !isCounting) {
					initialBreak++;
					setBreak.textContent = initialBreak;
				}

			})
		}
	}

	function workCountdown(minute, second) {
		let mins = minute;
		let secs = second;
		const status = document.querySelector(".status");
		const chime = new Audio("http://www.wavlist.com/soundfx/014/cricket-1.wav");

		workTick = setInterval(function () {

			status.style.color = "#f43a3a";
			status.textContent = "Work";

			if (secs <= 0) {
				secs = 59;
				seconds.textContent = secs;

			} else {
				secs--;
				seconds.textContent = (secs < 10) ? "0" + secs : secs;
			}

			if (secs === 59) {
				mins--;
				minutes.textContent = mins;

			}

			if (minutes.textContent === "0" && seconds.textContent === "00") {
				clearInterval(workTick);
				chime.play();
				breakCountdown(setBreak.textContent, seconds.textContent);
			}
		}, 1000);
	}

	function breakCountdown(minute, second) {
		let mins = minute;
		let secs = second;
		const status = document.querySelector(".status");
		const rooster = new Audio("http://www.wavlist.com/soundfx/009/rooster-2.wav");

		breakTick = setInterval(function () {


			status.style.color = "#0daa32";
			status.textContent = "Break";


			if (secs <= 0) {
				secs = 59;
				seconds.textContent = secs;

			} else {
				secs--;
				seconds.textContent = (secs < 10) ? "0" + secs : secs;
			}

			if (secs === 59) {
				mins--;
				minutes.textContent = mins;

			}

			if (minutes.textContent === "0" && seconds.textContent === "00") {
				clearInterval(breakTick);
				rooster.play();
				workCountdown(setWork.textContent, seconds.textContent);
			}
		}, 1000);

	}

	document.querySelector(".play-button").addEventListener("click", function () {
		const status = document.querySelector(".status");

		if (!isCounting && status.textContent === "Work") {
			workCountdown(minutes.textContent, seconds.textContent);
		} else if (!isCounting && status.textContent === "Break") {
			breakCountdown(minutes.textContent, seconds.textContent);
		}

		isCounting = true;

	});

	document.querySelector(".pause-button").addEventListener("click", function () {
		clearInterval(workTick);
		clearInterval(breakTick);
		isCounting = false;
	});

	document.querySelector(".reset-button").addEventListener("click", function () {
		clearInterval(workTick);
		clearInterval(breakTick);
		minutes.textContent = initialWork;
		seconds.textContent = "00";
		setWork.textContent = initialWork;
		setBreak.textContent = initialBreak;
		isCounting = false;
	});
})();

              
            
!
999px

Console