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="text-box">
		<h1 id="title">Pomodoro Clock</h1><br>
		 <h2>FreeCodeCamp</h2>
	</div>

	<div class="container">

	  <div id="pomodoro">
	    <div id="status"></div>
	    <div class="timerDisplay"> 25:00 </div>
	    <button id="start-btn" class="btn">START</button>
	  </div>

	  <div class="settings">
	    <div id="work">
	      <p>Work Session</p>
	      <h4 class="btn-settings" id="work-minus">-</h4>
	      <h4><span id="work-min">25</span> mins</h4>
				<h4 class="btn-settings" id="work-plus">+</h4>
	    </div>

	    <button id="reset" class="btn">RESET</button>

	    <div id="break">
	      <p>Break Session</p>
	      <h4 class="btn-settings" id="break-minus">-</h4>
	      <h4><span id="break-min">5</span> mins</h4>
				<h4 class="btn-settings" id="break-plus">+</h4>
	    </div>
	  </div>


	</div>

<footer class="footer">
	<p>Developed and designed by Linda Kovacs - 2018</p>
</footer>

              
            
!

CSS

              
                html {
  /* background-color: #3861F3; */
  text-align: center;
  min-width: 350px;
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
}

h1 {
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  font-size: 3em;
  font-weight: lighter;
  padding: 0px;
  margin: 0px 10px;
  color: #fff;
}
h2{
  font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
  font-size: 2em;
  font-weight: bold;
  padding: 0px;
  margin: 0px;
  color: #fff;
}
h4{
  display:inline;
}

.container {
  padding: 0px;
  width: 100%;
  max-width: 800px;
  margin: auto;
  text-align: center;
}

.text-box {
  background-color: #3861F3;
  border-radius: 20px;
  margin: 2em auto;
  padding: 10px;
  width: 70%;
}

#pomodoro {
  margin: 0 auto;
  position: relative;
  padding: 0px 10px;
  cursor:pointer;
  width: 300px;
  height: 300px;
  clear:both;
  border-radius:50%;
  border:5px #3861F3 solid;
  overflow:hidden;
  text-shadow:none;
}

#status {
  width: 70%;
  color: #3861F3;
  font-size: 1.7em;
  font-weight: bold;
  position: absolute;
  top: 40%;
  left:50%;
  transform: translate(-50%, -50%);
}

.timerDisplay {
  color: #3861F3;
  font-size: 4em;
  font-weight: bold;
  position: absolute;
  top: 60%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.btn {
  margin: 10px;
  padding: 8px 10px;
  color: white;
  font-size: 1em;
  cursor:pointer;
  border: 2px solid white;
}

#start-btn {
  height: 40px;
  width: 90px;
  border-radius: 20px;
  position: absolute;
  bottom: 8%;
  left: 48%;
  transform: translate(-50%, -50%);
  background: #3861F3;
}

.btn-settings {
  background-color: #3861F3;
  margin: 10px;
  border: 1px solid #4e4e5b;
  border-radius: 10px;
  padding: 2px 5px;
  min-width: 40px;
  color: white;
  font-size: 2em;
  cursor:pointer;
}

.settings {
  margin: auto;
  width: 80%;
  display: grid;
  grid-template-columns: 2fr 1fr 2fr;
  align-items: center;
}

#reset {
  border-radius: 50px;
  width: 80px;
  height: 80px;
  background: #3861F3;
  transform: translate(0%, 50%);

}

#work, #break {
  color: #4e4e5b;
  font-weight: bold;
  display: inline;
}

#work p, #break p {
  color: #fff;
  background: #3861F3;
  padding: 5px;
}


.footer {
    clear:both;
    width:100%;
    padding-top:10px;
    padding-bottom:10px;
    font-size: 15px;
    font-weight: bold;
    text-align:center;
    background-color: #3861F3;
    color: #fff;
    margin-top: 50px;
  }

@media only screen and (max-width: 400px) {
  .timerDisplay {
  font-size: 2.5em;
  }
}

              
            
!

JS

              
                let countdown = 0; // variable to set/clear intervals
let seconds = 1500; // seconds left on the clock
let workTime = 25;
let breakTime = 5;
let isBreak = true;
let isPaused = true;

const status = document.querySelector("#status");
const timerDisplay = document.querySelector(".timerDisplay");
const startBtn = document.querySelector("#start-btn");
const resetBtn = document.querySelector("#reset");
const workMin = document.querySelector("#work-min");
const breakMin = document.querySelector("#break-min");

const alarm = document.createElement('audio'); // A bell sound will play when the timer reaches 0
alarm.setAttribute("src", "http://codingtutorials360.com/14244764.mp3");


/* EVENT LISTENERS FOR START AND RESET BUTTONS */
startBtn.addEventListener('click', () => {
  clearInterval(countdown);
  isPaused = !isPaused;
  if (!isPaused) {
    countdown = setInterval(timer, 1000);
  }
})

resetBtn.addEventListener('click', () => {
  clearInterval(countdown);
  seconds = workTime * 60;
  countdown = 0;
  isPaused = true;
  isBreak = true;
})

/* TIMER - HANDLES COUNTDOWN */
function timer() {
  seconds --;
  if (seconds < 0) {
    clearInterval(countdown);
    alarm.currentTime = 0;
    alarm.play();
    seconds = (isBreak ? breakTime : workTime) * 60;
    isBreak = !isBreak;
  }
}


/* UPDATE WORK AND BREAK TIMES */
let increment = 1;

let incrementFunctions =
    {"#work-plus": function () { workTime = Math.min(workTime + increment, 60)},
     "#work-minus": function () { workTime = Math.max(workTime - increment, 5)},
     "#break-plus": function () { breakTime = Math.min(breakTime + increment, 60)},
     "#break-minus": function () { breakTime = Math.max(breakTime - increment, 5)}};

for (var key in incrementFunctions) {
    if (incrementFunctions.hasOwnProperty(key)) {
      document.querySelector(key).onclick = incrementFunctions[key];
    }
}

/* UPDATE HTML CONTENT */
function countdownDisplay() {
  let minutes = Math.floor(seconds / 60);
  let remainderSeconds = seconds % 60;
  timerDisplay.textContent = `${minutes}:${remainderSeconds < 10 ? '0' : ''}${remainderSeconds}`;
}

function buttonDisplay() {
  if (isPaused && countdown === 0) {
    startBtn.textContent = "START";
  } else if (isPaused && countdown !== 0) {
    startBtn.textContent = "Continue";
  } else {
    startBtn.textContent = "Pause";
  }
}

function updateHTML() {
  countdownDisplay();
  buttonDisplay();
  isBreak ? status.textContent = "Get some work done!" : status.textContent = "Take a Break!";
  workMin.textContent = workTime;
  breakMin.textContent = breakTime;
}

window.setInterval(updateHTML, 100);

document.onclick = updateHTML;

              
            
!
999px

Console