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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <h1 class="title">No Sad Tomatoes</h1>
<div class="mainSection">

  <div class="blurb">
    <h3 id="blurbTop">All work and no play...</h3>
  </div>
  <div class="timeLabels">
    <h2>Work</h2>
    <h2>Play</h2>
  </div>

  <div class="timersSection">
    <div class="upDownTime">
      <a class="upTimeWork">
                    <i class="fas fa-caret-up fa-2x"></i>
                </a>
      <a class="downTimeWork">
                    <i class="fas fa-caret-down fa-2x"></i>
                </a>
    </div>

    <div class="workTimersSection">
      <div class="workTimer">
        <h1 class="workMinSec">
          <span class="worktimeMinutes">25</span>:<span class="worktimeSeconds">00</span>
        </h1>
      </div>
    </div>

    <div class="playTimersSection">
      <div class="playTimer">
        <h1 class="playMinSec">
          <span class="playtimeMinutes">05</span>:<span class="playtimeSeconds">00</span>
        </h1>
      </div>
    </div>

    <div class="upDownTime">
      <a class="upTimePlay">
                    <i class="fas fa-caret-up  fa-2x"></i>
                </a>
      <a class="downTimePlay">
                    <i class="fas fa-caret-down  fa-2x"></i>
                </a>
    </div>
  </div>

  <div class="controlButtons">
    <a id="start">
                <i class="far fa-play-circle fa-3x fa-fw"></i>
            </a>
    <a id="pause">
                <i class="far fa-pause-circle fa-3x fa-fw"></i>
            </a>
    <a id="reset">
                <i class="fas fa-history fa-3x fa-fw"></i>
            </a>
  </div>

  <div class="blurb">
    <h3 id="blurbBottom">...makes sad tomatoes</h3>
    <a id="sadHappyFace">
                <i class="far fa-frown fa-5x" id="frownFace"></i>
            </a>
  </div>
</div>
<h1 class="myMark">A pomodoro app by Tom Corbin</h1>
<audio id="timerBell" src="https://actions.google.com/sounds/v1/alarms/beep_short.ogg"></audio>
              
            
!

CSS

              
                /* font families */
@import url("https://fonts.googleapis.com/css?family=Arimo|Nanum+Pen+Script");
/* font-family: 'Arimo', sans-serif; */
/* font-family: 'Nanum Pen Script', cursive; */

/* CSS Variables */
:root {
  --redTomato: #c70003;
  --orangeTomato: #dc3403;
  --yellowTomato: #f4ba2f;
  --rougeTomato: #e24761;
  --blackPrinceTomato: #911c25;
  --greenTomato: #8fc33b;
  --paleAphidGreen: #cee0c6;
  --tomatoBugGreen: #c1f7a9;
  --vineGreen: #1e392a;
  --aubergine: #380238;
}

body {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  font-family: "Arimo", sans-serif;
  font-size: 10px;
  background: var(--tomatoBugGreen);
  margin: 20px 0;
}

h1,
h2,
h3,
span {
  margin: 0;
}

.title,
.myMark {
  align-self: center;
  color: var(--rougeTomato);
  text-shadow: -1px 2px 2px var(--vineGreen);
  font-family: "Nanum Pen Script", cursive;
  font-size: 4em;
  padding: 5px;
}

.myMark {
  color: var(--greenTomato);
  text-shadow: none;
  font-family: "Arimo", sans-serif;
  font-size: 1.75em;
  margin-top: 15px;
}

.mainSection {
  display: flex;
  flex-direction: column;
  align-items: center;
  align-self: center;
  width: 285px;
  height: 335px;
  background: var(--redTomato);
  border: 2px solid var(--greenTomato);
  box-shadow: -8px 15px 2px var(--blackPrinceTomato);
  border-radius: 20%;
  padding: 5px;
}

.timeLabels {
  display: flex;
  color: var(--vineGreen);
  font-size: 1.5em;
  text-shadow: -2px 4px 4px var(--blackPrinceTomato);
  margin-bottom: 3px;
}

.timersSection {
  display: flex;
}

.workTimersSection {
  margin: 0 2px 0 1px;
}

.playTimersSection {
  margin: 0 1px 0 2px;
}

.upDownTime {
  display: flex;
  flex-direction: column;
}

.upTimeWork,
.downTimeWork,
.upTimePlay,
.downTimePlay {
  align-self: center;
  color: var(--aubergine);
  background: var(--greenTomato);
  padding: 2px;
  border: 1px solid var(--vineGreen);
  box-shadow: -2px 3px 1px var(--blackPrinceTomato);
  border-radius: 15%;
}

.upTimeWork:hover,
.downTimeWork:hover,
.upTimePlay:hover,
.downTimePlay:hover {
  background: var(--yellowTomato);
}

.upTimeWork:active,
.downTimeWork:active,
.upTimePlay:active,
.downTimePlay:active {
  color: var(--orangeTomato);
  box-shadow: -1px 2px 1px var(--rougeTomato);
}

.workMinSec,
.playMinSec {
  width: 120px;
  height: 54px;
  color: var(--aubergine);
  text-shadow: 1px 1px 1px var(--vineGreen);
  text-align: center;
  font-size: 4em;
  background: var(--paleAphidGreen);
  border: 1px solid var(--vineGreen);
  border-radius: 5%;
}

.controlButtons {
  display: flex;
  flex-direction: row;
  color: var(--aubergine);
  margin-top: 10px;
}

#start,
#pause,
#reset {
  color: var(--aubergine);
  background: var(--greenTomato);
  padding: 5px;
  border: 1px solid var(--vineGreen);
  box-shadow: -2px 6px 1px var(--blackPrinceTomato);
  border-radius: 50%;
  margin: 2px;
}

/*LoVe Fears HAte: Link Visited Focus Hover Active*/
#start:hover,
#pause:hover,
#reset:hover {
  background: var(--yellowTomato);
}

#start:active,
#pause:active,
#reset:active {
  color: var(--orangeTomato);
  box-shadow: -2px 6px 1px var(--rougeTomato);
}

.timeLabels > h2 {
  width: 120px;
  text-align: center;
}

.blurb {
  display: flex;
  flex-direction: column;
}

.blurb > h3 {
  color: var(--yellowTomato);
  text-shadow: -2px 2px 2px var(--rougeTomato);
  font-family: "Nanum Pen Script", cursive;
  font-size: 3em;
  text-align: center;
  height: 50px;
}

#blurbTop {
  margin-top: 10px;
}

#sadHappyFace {
  align-self: center;
  margin-bottom: 15px;
}

#frownFace {
  color: var(--vineGreen);
  background: var(--rougeTomato);
  border-radius: 50%;
  padding: 3px;
  border: 2px solid var(--blackPrinceTomato);
  box-shadow: -2px 3px 1px var(--blackPrinceTomato);
}

#smileFace {
  color: var(--orangeTomato);
  background: var(--yellowTomato);
  border-radius: 50%;
  padding: 3px;
  border: 2px solid var(--blackPrinceTomato);
  box-shadow: -2px 3px 1px var(--blackPrinceTomato);
}

#frownFace:hover {
  background: var(--yellowTomato);
}

#smileFace:hover {
  color: var(--rougeTomato);
}

#frownFace:active {
  color: var(--blackPrinceTomato);
  box-shadow: -2px 3px 1px var(--rougeTomato);
}

#smileFace:active {
  color: var(--redTomato);
  box-shadow: -2px 3px 1px var(--rougeTomato);
}

              
            
!

JS

              
                "use strict";

// Initial setup
let initialState = true;
let timerRunning = false;
let sadTomato = true;

// Timers
let countSeconds;
const worktimeMinutes = document.querySelector(".worktimeMinutes");
const worktimeSeconds = document.querySelector(".worktimeSeconds");
const playtimeMinutes = document.querySelector(".playtimeMinutes");
const playtimeSeconds = document.querySelector(".playtimeSeconds");
let initialWorktimeMinutes = worktimeMinutes.textContent;
const initialWorktimeSeconds = "00";
let initialPlaytimeMinutes = playtimeMinutes.textContent;
const initialPlaytimeSeconds = "00";
const moreWork = document.querySelector(".upTimeWork");
const morePlay = document.querySelector(".upTimePlay");
const lessWork = document.querySelector(".downTimeWork");
const lessPlay = document.querySelector(".downTimePlay");
moreWork.addEventListener("click", () => moreTime("work"));
morePlay.addEventListener("click", () => moreTime("play"));
lessWork.addEventListener("click", () => lessTime("work"));
lessPlay.addEventListener("click", () => lessTime("play"));

// Control panel
document.querySelector("#start").addEventListener("click", startTimer);
document.querySelector("#pause").addEventListener("click", pauseTimer);
document.querySelector("#reset").addEventListener("click", resetTimer);

// Sad face to happy face adjustment
const blurbTop = document.querySelector("#blurbTop");
const blurbBottom = document.querySelector("#blurbBottom");
const sadHappyFace = document.querySelector("#sadHappyFace");
const originalBlurbTop = blurbTop.innerText;
const originalBlurbBottom = blurbBottom.innerText;
const originalSadFace = sadHappyFace.innerHTML;
let happyWorktimeMinutes = "05";
let happyPlaytimeMinutes = "85";
sadHappyFace.addEventListener("click", sadToHappy);

const timerBell = document.querySelector("#timerBell");

// Timer control functions
function startTimer() {
  timerRunning === false
    ? (countSeconds = window.setInterval(tickTockClock, 1000))
    : console.log("Timer already running");
  timerRunning = true;
}

function pauseTimer() {
  clearInterval(countSeconds);
  timerRunning = false;
}

function resetTimer() {
  clearInterval(countSeconds);
  timerRunning = false;
  initialMinutes();
  initialSeconds();
  blurbTop.innerHTML = originalBlurbTop;
  blurbBottom.innerHTML = originalBlurbBottom;
  sadHappyFace.innerHTML = originalSadFace;
  initialState = true;
  sadTomato = true;
}

function moreTime(workOrPlay) {
  let minutesMore;
  workOrPlay === "work"
    ? (minutesMore = worktimeMinutes)
    : (minutesMore = playtimeMinutes);
  clearInterval(countSeconds);
  timerRunning = false;
  initialSeconds();
  if (minutesMore.textContent < 9) {
    minutesMore.textContent = "0" + (Number(minutesMore.textContent) + 1);
  } else if (minutesMore.textContent == 9) {
    minutesMore.textContent = String(Number(minutesMore.textContent) + 1);
  } else if (minutesMore.textContent < 90) {
    minutesMore.textContent = String(Number(minutesMore.textContent) + 5);
  }
  changeInitialOrHappyMinutes();
}

function lessTime(workOrPlay) {
  let minutesLess;
  workOrPlay === "work"
    ? (minutesLess = worktimeMinutes)
    : (minutesLess = playtimeMinutes);
  clearInterval(countSeconds);
  timerRunning = false;
  initialSeconds();
  if (minutesLess.textContent > 1 && minutesLess.textContent <= 10) {
    minutesLess.textContent = "0" + (Number(minutesLess.textContent) - 1);
  } else if (minutesLess.textContent > 10) {
    minutesLess.textContent = String(Number(minutesLess.textContent) - 5);
  }
  changeInitialOrHappyMinutes();
}

// Timer display functions
function tickTockClock() {
  let minuteActivity, secondActivity;
  initialState === true
    ? (minuteActivity = worktimeMinutes)
    : (minuteActivity = playtimeMinutes);
  initialState === true
    ? (secondActivity = worktimeSeconds)
    : (secondActivity = playtimeSeconds);
  if (
    minuteActivity.textContent == "00" &&
    secondActivity.textContent == "00"
  ) {
    timerBell.play();
    clearInterval(countSeconds);
    timerRunning = false;
    sadTomato === true ? initialMinutes() : happyMinutes();
    initialState === true ? (initialState = false) : (initialState = true);
    startTimer();
  } else if (
    minuteActivity.textContent <= 10 &&
    secondActivity.textContent == "00"
  ) {
    minuteActivity.textContent = "0" + (Number(minuteActivity.textContent) - 1);
    secondActivity.textContent = 59;
  } else if (secondActivity.textContent == "00") {
    minuteActivity.textContent -= 1;
    secondActivity.textContent = 59;
  } else if (secondActivity.textContent <= 10) {
    secondActivity.textContent = "0" + (secondActivity.textContent - 1);
  } else {
    secondActivity.textContent -= 1;
  }
}

function initialMinutes() {
  worktimeMinutes.textContent = initialWorktimeMinutes;
  playtimeMinutes.textContent = initialPlaytimeMinutes;
}

function initialSeconds() {
  worktimeSeconds.textContent = initialWorktimeSeconds;
  playtimeSeconds.textContent = initialPlaytimeSeconds;
}

function happyMinutes() {
  worktimeMinutes.textContent = happyWorktimeMinutes;
  playtimeMinutes.textContent = happyPlaytimeMinutes;
}

function changeInitialOrHappyMinutes() {
  if (sadTomato === true) {
    initialWorktimeMinutes = worktimeMinutes.textContent;
    initialPlaytimeMinutes = playtimeMinutes.textContent;
  } else {
    happyWorktimeMinutes = worktimeMinutes.textContent;
    happyPlaytimeMinutes = playtimeMinutes.textContent;
  }
}

// Sad to Happy Theme
function sadToHappy() {
  clearInterval(countSeconds);
  timerRunning = false;
  initialSeconds();
  if (sadTomato === true) {
    happyMinutes();
    blurbTop.innerHTML = `<h3>Happy tomatoes...</h3>`;
    blurbBottom.innerHTML = `<h3>...play in the sun!</h3>`;
    sadHappyFace.innerHTML = `<i class="far fa-smile fa-5x" id="smileFace"></i>`;
    sadTomato = false;
  } else {
    initialMinutes();
    blurbTop.innerHTML = originalBlurbTop;
    blurbBottom.innerHTML = originalBlurbBottom;
    sadHappyFace.innerHTML = originalSadFace;
    sadTomato = true;
  }
}

              
            
!
999px

Console