cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div class="container"> 
  <div class="clock-wall" align="center">
    <div class="clock-content">
      <h1 id="clock-title">Pomodoro</h1>
      <span id="clock-display" class="disabled">
        <div id="clock-display-min">25</div>
        <div id="clock-display-sec">00</div>    
      </span>
      <br>
      <button id="clock-play-button"
              class="clock-button fa fa-play">
      </button>
    </div>
  </div>

  <div class="time-settings" align="center">
    <label id="session-switch" class="switch">
      <input id="session-switch-checkbox" type="checkbox">
      <div class="slider round"></div>
    </label>
    
    <div class="time-setting-element">
      <p class="time-setting-title">Session</p>
      <span>
        <button id="dec-session-time"><i class="fa fa-minus"></i></button>
        <p id="session-minutes-setting" class="time-setting-value">25</p>
        <button id="inc-session-time"><i class="fa fa-plus"></i></button>
      </span>
    </div>

    <br>

    <div class="time-setting-element">
      <p class="time-setting-title">Break</p>
      <span>
        <button id="dec-break-time"><i class="fa fa-minus"></i></button>
        <p id="break-minutes-setting" class="time-setting-value">5</p>
        <button id="inc-break-time"><i class="fa fa-plus"></i></button>
      </span>
    </div>
   
  </div>
  
</div>

            
          
!
            
              body {
  background-color: #F44336;
}
.working {
  transition: background 0.25s ease;
  background-color: #F44336;
}
.break {
  transition: background 0.25s ease;
  background-color: #8BC34A;
}
.disabled {
  filter: opacity(65%);
}
*:disabled {
  filter: opacity(65%);
}
.container {
  width: 589px;
  margin: 10% auto;
}
.switch {
  position: relative;
  display: inline-block;
  width: 250px;
  height: 55px;
}
.switch input {
  display: none;
}
.switch .slider {
  cursor: pointer;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  transition: .1s;
  border: 2px white solid;
  border-radius: 34px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2) inset;
  color: #808080;
  font-size: 25px;
  font-family: "Roboto Light", sans-serif;
}
.switch .slider:before {
  position: absolute;
  bottom: 6.5px;
  right: 129px;
  content: "Working";
  padding: 4px 10px;
  display: inline-block;
  background-color: white;
  transition: .1s;
  border-radius: 30px;
}
.switch input:checked + .slider:before {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  content: "Break";
  right: 7px;
}
.switch .other-option {
  z-index: -1;
  color: white;
  font-size: 25px;
  font-family: "Roboto Light", sans-serif;
}
.switch .slider:after {
  z-index: -1;
  color: white;
  font-size: 25px;
  font-family: "Roboto Light", sans-serif;
  content: 'Break';
  position: absolute;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 80%;
}
.switch input:checked + .slider:after {
  z-index: -1;
  color: white;
  font-size: 25px;
  font-family: "Roboto Light", sans-serif;
  content: 'Working';
  top: 50%;
  left: 25%;
}
button {
  cursor: pointer;
  cursor: hand;
}
button:active {
  box-shadow: 0px 0px 9px rgba(0, 0, 0, 0.16) !important;
  filter: brightness(85%);
}
.round-button {
  background-color: white;
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.15);
  outline: none !important;
  border: none;
  font-size: 22px;
  color: #808080;
  border-radius: 200px;
}
.clock-wall {
  width: 300px;
  height: 300px;
  display: inline-block;
  border: 17px rgba(255, 255, 255, 0.97) solid;
  border-radius: 200px;
  box-shadow: 0 0 200px #000000 inset;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.15), 0 0 20px rgba(0, 0, 0, 0.15);
}
.clock-content {
  margin-top: 12%;
}
.clock-content #clock-title {
  font-family: "Roboto Thin", sans-serif;
  font-size: 26px;
  text-align: center;
  color: rgba(255, 255, 255, 0.97);
}
.clock-content .clock-display-text {
  display: inline-block;
  font-family: "Roboto Thin", sans-serif;
  color: rgba(255, 255, 255, 0.95);
}
.clock-content #clock-display-min {
  display: inline-block;
  font-family: "Roboto Thin", sans-serif;
  color: rgba(255, 255, 255, 0.95);
  font-size: 100px;
}
.clock-content #clock-display-sec {
  display: inline-block;
  font-family: "Roboto Thin", sans-serif;
  color: rgba(255, 255, 255, 0.95);
  font-size: 50px;
  position: relative;
  bottom: 34px;
}
.clock-content .clock-button {
  background-color: white;
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.15);
  outline: none !important;
  border: none;
  font-size: 22px;
  color: #808080;
  border-radius: 200px;
  position: relative;
  width: 60px;
  height: 60px;
  margin: 15px 7px;
}
.time-settings {
  display: inline-block;
}
.time-settings .time-setting-element * {
  display: inline-block;
}
.time-settings .time-setting-element .time-setting-title {
  display: block;
  text-align: center;
  font-family: "Roboto Thin", sans-serif;
  font-size: 30px;
  color: rgba(255, 255, 255, 0.95);
  margin: 10px auto;
}
.time-settings .time-setting-element .time-setting-value {
  font-family: "Roboto Light", sans-serif;
  font-size: 25px;
  text-align: center;
  vertical-align: middle;
  color: rgba(255, 255, 255, 0.95);
  margin: 0;
}
.time-settings .time-setting-element button {
  background-color: white;
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.15);
  outline: none !important;
  border: none;
  font-size: 22px;
  color: #808080;
  border-radius: 200px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  margin: 0 12px;
}
@media only screen and (max-width: 630px) {
  .container {
    width: 340px;
    margin: 10% auto;
  }
  .time-settings {
    margin: 25px 0 30px 50px;
  }
}

            
          
!
            
              $(document).ready(function() {
  var SECONDS_PER_MINUTE = 60;

  var sessionTime = 25;
  var breakTime = 5;
  var timeSettingsEnabled = true;
  var timeRemaining = sessionTime * SECONDS_PER_MINUTE;
  var playing = false;
  var bell = new Audio(
    'http://www.freesfx.co.uk/rx2/mp3s/9/10604_1376407711.mp3'
  );

  function isDisabled(view) {
    return view.prop('disabled') || view.hasClass('disabled');
  }

  function toggleDisabled(view) {
    if (view.prop('disabled')) {
      view.removeAttr('disabled');
    } else {
      view.prop('disabled', true);
    }
  }

  function toggleTimeSettingEnableState() {
    timeSettingsEnabled = !timeSettingsEnabled;
    toggleDisabled($('#dec-session-time'));
    toggleDisabled($('#inc-session-time'));
    toggleDisabled($('#break-minutes-setting'));
    toggleDisabled($('#dec-break-time'));
    toggleDisabled($('#inc-break-time'));
    toggleDisabled($('#session-minutes-setting'));
    $('#session-switch').toggleClass('disabled');
  }

  function toggleBackground(isBreakMode) {
    if (isBreakMode) {
      $('body').addClass('break');
      $('body').removeClass('working');
    } else {
      $('body').addClass('working');
      $('body').removeClass('break');
    }
  }

  function getTargetSessionTime() {
    var isBreakMode = $('#session-switch-checkbox').is(':checked');
    return (isBreakMode ? breakTime : sessionTime) * SECONDS_PER_MINUTE;
  }

  function updateClockDisplay(time) {
    var minutes = Math.floor(time / SECONDS_PER_MINUTE);
    var seconds = time - minutes * SECONDS_PER_MINUTE;
    seconds = ('0' + seconds).slice(-2);
    $('#clock-display-min').html(minutes);
    $('#clock-display-sec').html(seconds);
  }

  setInterval(function() {
    if (playing) updateClockDisplay(--timeRemaining);
    if (timeRemaining === 0) {
      var isBreakMode = $('#session-switch-checkbox').is(':checked');
      $('#session-switch-checkbox').prop('checked', !isBreakMode);
      toggleBackground(!isBreakMode);
      timeRemaining = getTargetSessionTime();
      bell.play();
    }
  }, 1000);

  function playSession() {
    playing = true;
    toggleTimeSettingEnableState();
    timeRemaining = getTargetSessionTime();

    $('#clock-display').removeClass('disabled');
    $('#clock-play-button').removeClass('fa-play');
    $('#clock-play-button').addClass('fa-stop');
  }

  function stopSession() {
    toggleTimeSettingEnableState();
    timeRemaining = getTargetSessionTime();
    updateClockDisplay(timeRemaining);
    playing = false;
    $('#clock-display').addClass('disabled');
    $('#clock-play-button').removeClass('fa-stop');
    $('#clock-play-button').addClass('fa-play');
  }

  //region [---- events ----]

  $('#clock-play-button').on('click', function() {
    if (!playing) {
      playSession();
    } else {
      stopSession();
    }
  });

  $('#session-switch').on('click', function(e) {
    if (isDisabled($(this))) {
      e.preventDefault();
    } else {
      var isChecked = $('#session-switch-checkbox').is(':checked');
      toggleBackground(isChecked);
      updateClockDisplay(getTargetSessionTime());
    }
  });

  //region session-time-settings events
  $('#dec-session-time').on('click', function() {
    if (timeSettingsEnabled && sessionTime > 1) {
      $('#session-minutes-setting').html(--sessionTime);
      updateClockDisplay(getTargetSessionTime());
    }
  });
  $('#inc-session-time').on('click', function() {
    if (timeSettingsEnabled && sessionTime < 99) {
      $('#session-minutes-setting').html(++sessionTime);
      updateClockDisplay(getTargetSessionTime());
    }
  });
  //endregion -- end --

  //region break-time-settings events
  $('#dec-break-time').on('click', function() {
    if (timeSettingsEnabled && breakTime > 1) {
      $('#break-minutes-setting').html(--breakTime);
      updateClockDisplay(getTargetSessionTime());
    }
  });
  $('#inc-break-time').on('click', function() {
    if (timeSettingsEnabled && breakTime < 99) {
      $('#break-minutes-setting').html(++breakTime);
      updateClockDisplay(getTargetSessionTime());
    }
  });
  //endregion -- end --

  //endregion [---- events ----]
});

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console