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

              
                <!-- --------------------------------------------- -->
<!-- Image inspired by Tide, a pomodoro app I use. -->
<!-- Check it out at: https://tide.moreless.io/en/ -->
<!-- --------------------------------------------- -->

  
  <div class="collection2"><p> <strong>Técnica Time Box</strong></p></div>
 
<p class="collection">
<a href="https://cibersergei.com/hacks-productividad/" target="_blank">CiberSergei Hacks <br>  de Productividad</a>
</p>


<div id="pomodoro">
  <div id="clock">
    <div id="timer">
      <div id="title">Listo?</div>
      <div id="countdown">
        <span id="minutes">10</span>
        <span id="seconds">00</span>
      </div>
      <div id="controls" class="reset">
        <div id="start"><i class="fas fa-play"></i> Inicia</div>
        <div id="pause"><i class="fas fa-pause"></i> Pausa</div>
        <div id="reset"><i class="fas fa-sync-alt"></i> Resetea</div>
      </div>
    </div>
  </div>
  <div id="options">
    <div id="session">
      <i id="incrSession" class="fas fa-angle-double-up"></i>
                <button class="btn1 btn-default" id="sessInc">+</button>       
      <span class="option-title">Tiempo Sesión</span>
      <input id="sessionInput" type="number" value="10" max="60" min="1">
                <button class="btn2 btn-default" id="sessDec">-</button>
        </div>
      <i id="decrSession" class="fas fa-angle-double-down"></i>
      </div>
    
  </div>
</div>
<div id="audio-selector">
  <div id="forest" class="theme"><!--🌲 -->Silencio</div>
  <div id="ocean" class="theme"><!--🌊 -->Océano</div>
  <div id="rainy" class="selected theme"><!--🌧 -->Lluvia</div>
  <div id="peace" class="theme"><!--🧘 -->Relax</div>
  <div id="cafe" class="theme"><!--☕ -->Selva</div>
</div>
<audio loop autoplay="false" src="https://joeweaver.me/codepenassets/freecodecamp/challenges/build-a-pomodoro-clock/rain.mp3">

              
            
!

CSS

              
                * {
  box-sizing: border-box;
  outline: none;
  user-select: none;  
}

body {  
  overflow: hidden;
  align-items: center;
  background: radial-gradient(ellipse at center, rgba(255, 98, 146, 0) 0%, rgba(	46, 179, 255, 0) 43%, rgba(46, 179, 255, 0.43) 100%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  display: flex;
  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#00ffb3ce", endColorstr="#6effb5bd", GradientType=1);
  flex-direction: column;
  font-family: "Open Sans", sans-serif;
  height: 100vh;
  justify-content: center;
  min-width: 184px;
  overflow-x: hidden;
  transition: background-color 0.2s;
}

#pomodoro {
  margin-bottom: 43px;
  max-width: 512px;
  width: 100%;
}
#pomodoro #clock {
  background: url(https://cibersergei.com/wp-content/uploads/2021/05/Blue-Circle3.png) no-repeat center center;
  background-size: contain;
  display: flex; 
  justify-content: center;
  margin-bottom: -6.25vw;
  padding: 40vw 0;
}
@media all and (min-width: 512px) {
  #pomodoro #clock {
    margin-bottom: -32px;
    padding: 204px 0;
  }
}
@media all and (max-width: 184px) {
  #pomodoro #clock {
    margin-bottom: -20px;
    margin-bottom: -11.5px;
    padding: 73px 0;
  }
}
#pomodoro #clock #timer {
  align-items: center;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
#pomodoro #clock #timer #title {
  color: #3182CE;
  font-size: 28px;
  line-height: 28px;
  margin: 3px 0 1px;
}
@media all and (max-width: 512px) {
  #pomodoro #clock #timer #title {
    font-size: 5.5vw;
    line-height: 5.5vw;
  }
}
@media all and (max-width: 184px) {
  #pomodoro #clock #timer #title {
    font-size: 10px;
    line-height: 10px;
  }
}
#pomodoro #clock #timer #countdown {
  color: #0693E3;
  display: flex;
  font-size: 43px;
  font-weight: 600;
  line-height: 43px;
}
@media all and (max-width: 512px) {
  #pomodoro #clock #timer #countdown {
    font-size: 8.4vw;
    line-height: 8.4vw;
  }
}
@media all and (max-width: 184px) {
  #pomodoro #clock #timer #countdown {
    font-size: 15.4px;
    line-height: 15.4px;
  }
}
#pomodoro #clock #timer #countdown #minutes::after {
  content: ":";
}
#pomodoro #clock #timer #controls {
  align-items: center;
  display: flex;
  color: #2B6CB0;
  flex-direction: column;
  font-size: 15px;
  font-weight: 700;
  line-height: 15px;
  margin-top: 5px;
  text-align: center;
  text-transform: uppercase;
}
#pomodoro #clock #timer #controls .fas, #pomodoro #clock #timer #controls .svg-inline--fa {
  position: relative;
}
#pomodoro #clock #timer #controls #start, #pomodoro #clock #timer #controls #pause, #pomodoro #clock #timer #controls #reset {
  white-space: nowrap;
}
#pomodoro #clock #timer #controls #start .fa-play {
  font-size: 87%;
  top: -1px;
}
#pomodoro #clock #timer #controls #start:hover {
  color: #7A7A7A;
}
#pomodoro #clock #timer #controls #pause .fa-pause {
  font-size: 90%;
  top: -1px;
  transform: scaleX(0.84);
}
#pomodoro #clock #timer #controls #pause:hover {
  color: #1A202C;
}
#pomodoro #clock #timer #controls #reset {
  position: absolute;
  margin-top: 17.56px;
  transition: margin-top 0.43s, opacity 0.43s;
}
#pomodoro #clock #timer #controls #reset .fa-sync-alt {
  font-size: 84%;
}
#pomodoro #clock #timer #controls #reset:hover {
  color: #1A202C;
}
#pomodoro #clock #timer #controls.reset #pause {
  display: none;
}
#pomodoro #clock #timer #controls.reset #reset {
  margin-top: 0;
  opacity: 0;
  z-index: -1;
}
#pomodoro #clock #timer #controls.started #start {
  display: none;
}
#pomodoro #clock #timer #controls.started #reset {
  opacity: 0;
}
#pomodoro #clock #timer #controls.paused #pause {
  display: none;
}
@media all and (max-width: 512px) {
  #pomodoro #clock #timer #controls {
    font-size: 5.5vw;
    line-height: 5.5vw;
  }
  #pomodoro #clock #timer #controls #start, #pomodoro #clock #timer #controls #pause, #pomodoro #clock #timer #controls #reset {
    font-size: 3vw;
    line-height: 3vw;
  }
  #pomodoro #clock #timer #controls #reset {
    margin-top: 3.43vw;
  }
}
@media all and (max-width: 184px) {
  #pomodoro #clock #timer #controls {
    font-size: 10px;
    line-height: 10px;
  }
  #pomodoro #clock #timer #controls #start, #pomodoro #clock #timer #controls #pause, #pomodoro #clock #timer #controls #reset {
    font-size: 5.5px;
    line-height: 5.5px;
  }
  #pomodoro #clock #timer #controls #reset {
    margin-top: 6.31px;
  }
}
#pomodoro #options {
  color: #0693E3;
  display: flex;
  font-size: 28px;
  font-weight: normal;
  justify-content: center;
  margin-bottom: 28px;
  text-align: center;
}
#pomodoro #options .option-title {
  color: #3182CE;
  font-size: 14px;
  font-weight: bold;
  margin-top: 8px;
  margin-bottom: -6px;
  text-transform: uppercase;
}

.btn1 {
  margin-top: +1px;
  margin-bottom: -5px;
  font-size: 10px;
}

.btn2 {
  margin-top: -5px;
  margin-bottom: 2px;
  font-size: 10px;
}

#pomodoro #options .fa-angle-double-up {
  color: #010216;
  cursor: pointer;
  font-size: 14px;
  margin-top: 8px;
 
}
#pomodoro #options .fa-angle-double-down {
  color: #010216;
  cursor: pointer;
  font-size: 14px;

}
#pomodoro #options #session, #pomodoro #options {
  align-items: center;
  display: flex;
  flex-direction: column;
}
#pomodoro #options input[type=number] {
  background: linear-gradient(#f6f6f6, #d3efff);
  border: 0;
  border-bottom: calc(3px + .28vw) solid #0693E3;
  border-radius: 10px;
  color: #0693E3;
  font: bold calc(21px + 1.43vw) "Open Sans", sans-serif;
  margin: calc(5px + .43vw) calc(3px + .43vw);
  padding: calc(3px + .43vw) calc(5px + .43vw);
  text-align: center;
}
#pomodoro #options input[type=number]::-webkit-inner-spin-button, #pomodoro #options input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}
@media all and (min-width: 512px) {
  #pomodoro #options input[type=number] {
    border-bottom: 4.43px solid #0693E3;
    font: bold 28.43px "Open Sans", sans-serif;
    margin: 7.2px 5.2px;
    padding: 5.2px 7.2px;
  }
}
@media all and (max-width: 184px) {
  #pomodoro #options input[type=number] {
    border-bottom: 3.5px solid #FF6292;
    font: bold 23.6px "Open Sans", sans-serif;
    margin: 5.7px 3.7px;
    padding: 3.7px 5.7px;
  }
}

audio {
  display: none;
}

#audio-selector {
  display: flex;
  left: 0;
  position: fixed;
  top: 0;
  width: 100vw;
}
#audio-selector .theme {
  background: linear-gradient(to bottom, rgba(255, 98, 146, 0.28) 0%, rgba(46, 179, 255, 0.28) 1%, rgba(46, 179, 255, 0) 84%, rgba(255, 98, 146, 0) 100%);
  color: #010216;
  cursor: pointer;
  
  flex: 1 1 25%;
  font: 600 calc(9px + 1vw) "Open Sans", sans-serif;
  margin: 0 2px 0 0;
  padding: 2vw 1vw 5vw;
  text-align: center;
  transition: all 0.43s;
  white-space: nowrap;
}
#audio-selector .theme:last-child {
  margin-right: 0;
}
#audio-selector .theme:hover, #audio-selector .theme.selected {
  background: linear-gradient(to bottom, rgba(255, 98, 146, 0.43) 0%, rgba(46, 179, 255, 0.43) 1%, rgba(46, 179, 255, 0) 84%, rgba(255, 98, 146, 0) 100%);
  
}
@media all and (min-width: 512px) {
  #audio-selector .theme {
    font-size: 15.33px;
    padding: 9px 5px 25px;
  }
}
@media all and (max-width: 300px) {
  #audio-selector {
    flex-wrap: wrap;
  }
  #audio-selector .theme {
    flex: 1 0 100%;
    font-size: 14px;
    padding: 7px;
  }
}

.collection {
  position: fixed;
  z-index: 1000;
  width: auto;
  bottom: 0;
  justify-content: right;
  right: 0;
  margin: 15px;
  padding: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 16px;
  
}

.collection a {
  display: inline-block;
  background: #fff;
  opacity: 0.4;
  transition: opacity 0.7s;
  margin-left: 5px;
  padding: 5px;
  text-decoration: none;
  font-weight: bold;
  color: #000;
}

.collection a:hover {
  opacity: 1;
}
 

.collection2 {
  position: fixed;
  z-index: 1000;
  width: auto;
  bottom: 0;
  justify-content: left;
  left: 0;
  margin: 15px;
  padding: 0;
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  
}

              
            
!

JS

              
                $(() => {

  let $audio = $("audio"), // from https://tide.moreless.io/en/
      $theme = $(".theme"),
      $title = $("#title"),
      $controls = $("#controls"),
      $options = $("#options"),
      $minutes = $("#minutes"),
      $seconds = $("#seconds"),
      $start = $("#start"),
      $pause = $("#pause"),
      $reset = $("#reset"),
      $incrSession = $("#incrSession"),
      $sessInc = $("#sessInc"),
      $sessionInput = $("#sessionInput"),
      $sessDec = $("#sessDec"),
      $decrSession = $("#decrSession"),
      $incrBreak = $("#incrBreak"),
      $breakInput = $("#breakInput"),
      $decrBreak = $("#decrBreak"),
      breakLength = 1 * 60,
      breakMax = 10,
      breakMin = 1,
      sessionLength = 10 * 60,
      sessionMax = 60,
      sessionMin = 1,
      sessionNum = 0,
      countdown,
      countType,
      remainingTime = sessionLength;

  init();

  function init(){
    $audio.prop("volume", 0);
    $sessInc.click(() => incrSession());
    $incrSession.click(() => incrSession());
    $sessDec.click(() => decrSession());
    $decrSession.click(() => decrSession());
    $sessionInput.on("change", e => updateSession(e.target.value));
    $start.click(() => { if (countType === "break"){ reset(); } else { startSession(); } });
    $pause.click(() => pause());
    $reset.click(() => reset());
    $theme.click(e => audioSelect(e));
  }
  function startSession(){
    sessionNum++;
    countType = "session";
    $options.slideUp(143);
    $controls.removeClass().addClass("started");
    $title.fadeOut(43, function(){
      $(this).html("Sesión ").fadeIn();
    });
    $audio.animate({volume: 1}, 1000);
    start(remainingTime || sessionLength);
  }
  function startBreak(){
        countType = "break";
    $title.fadeOut(43, function(){
      $(this).html("Break " + sessionNum).fadeIn();
    });
    $audio.animate({volume: 0}, 5000);
    start(remainingTime || breakLength);
  }
  function start(timeLeft){
    clearInterval(countdown);
    countdown = setInterval(() => {
      timeLeft--;
      remainingTime = timeLeft;
      let minLeft = Math.floor(timeLeft / 60),
          secLeft = timeLeft - minLeft * 60;
      updateMinutes(minLeft);
      updateSeconds(secLeft < 10 ? "0" + secLeft : secLeft);
      if (timeLeft < 1){
        if (countType === "session"){
          reset();                   $options.slideDown(143);
        } else {
          reset();
          $options.slideDown(143);
          ;
        }
      }
    }, 1000);
  }
  function pause(){
    sessionNum--;
    $audio.animate({volume: 0}, 1000);
    clearInterval(countdown);
    $options.slideDown(143);
    $controls.removeClass().addClass("paused");
    $title.fadeOut(43, function(){
      $(this).html("Paused").fadeIn();
    });
  }
  function reset(){
    clearInterval(countdown);
    updateMinutes(sessionLength / 60);
    updateSeconds("00");
    countType = undefined;
    $controls.removeClass().addClass("reset");
    $title.html("Listo?");
    remainingTime = sessionLength; 
  }
  function incrSession(){
    let num = Number($sessionInput.val());
    num = num + (num === sessionMax ? 0 : 1);
    sessionLength = num * 60;
    updateSession(num);
    updateMinutes(num);
    updateSeconds("00");
    reset();
  }
  function decrSession(){
    let num = Number($sessionInput.val());
    num = num - (num === sessionMin ? 0 : 1);
    sessionLength = num * 60;
    updateSession(num);
    updateMinutes(num);
    updateSeconds("00");
    reset();
  }
  function incrBreak(){
    let num = Number($breakInput.val());
    num = num + (num === breakMax ? 0 : 1);
    breakLength = num * 60;
    updateBreak(num);
    reset();
  }
  function decrBreak(){
    let num = Number($breakInput.val());
    num = num - (num === breakMin ? 0 : 1);
    breakLength = num * 60;
    updateBreak(num);
    reset();
  }
  function updateMinutes(num){
    $minutes.text(num);
  }
  function updateSeconds(num){
    $seconds.text(num);
  }
  function updateSession(num){
    num = num < sessionMin ? sessionMin : num > sessionMax ? sessionMax : num;
    $sessionInput.val(num).blur();
    updateMinutes(num);
    updateSeconds("00");
    sessionLength = num * 60;
    reset();
  }
  function updateBreak(num){
    $breakInput.val(num < breakMin ? breakMin : num > breakMax ? breakMax : num).blur();
    breakLength = num * 60;
    reset();
  }
  function audioSelect(e){
    $theme.removeClass("selected");
    $(e.target).addClass("selected");
    switch(e.target.id){
      case "forest": $audio.attr("src", ""); break;
//https://joeweaver.me/codepenassets/freecodecamp/challenges/build-a-pomodoro-clock/cafe.mp3
      case "ocean": $audio.attr("src", "https://joeweaver.me/codepenassets/freecodecamp/challenges/build-a-pomodoro-clock/ocean.mp3"); break;
      case "rainy": $audio.attr("src", "https://joeweaver.me/codepenassets/freecodecamp/challenges/build-a-pomodoro-clock/rain.mp3"); break;
      case "peace": $audio.attr("src", "https://joeweaver.me/codepenassets/freecodecamp/challenges/build-a-pomodoro-clock/peace.mp3"); break;
      case "cafe": $audio.attr("src", "https://joeweaver.me/codepenassets/freecodecamp/challenges/build-a-pomodoro-clock/forest.mp3"); break;
    }
  }

});
              
            
!
999px

Console