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 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

              
                <section class="page">
  <header class="page__heading">
    <h1 class="page__title is-shadow is-text-bordered">Pomodoro</h1>
  </header>
  <div class="page__content">
    <div class="pomodoro" data-pomodoro="app" data-pomodoro-status="off">
      <div class="pomodoro__config">
        <div class="pomodoro__config-item" data-pomodoro="break">
          <h5 class="pomodoro__config-item-title is-shadow">BREAK LENGTH</h5>
          <div class="pomodoro__config-item-actions" data-pomodoro="item">
            <button class="btn" data-pomodoro-action="decrement">-</button>
            <span data-pomodoro-time="value">5</span>
            <button class="btn" data-pomodoro-action="increment">+</button>
          </div>
        </div>
        <div class="pomodoro__config-item" data-pomodoro="session">
          <h5 class="pomodoro__config-item-title is-shadow">SESSION LENGTH</h5>
          <div class="pomodoro__config-item-actions" data-pomodoro="item">
            <button class="btn" data-pomodoro-action="decrement">-</button>
            <span data-pomodoro-time="value">25</span>
            <button class="btn" data-pomodoro-action="increment">+</button>
          </div>
        </div>
      </div>
      <div class="pomodoro__timer">
        <div class="pomodoro__actions">
          <button class="btn btn--featured btn--large btn--round" data-pomodoro-action="start">          
            <i class="fa fa-play" aria-hidden="true"></i>
            <span class="is-hidden">Start</span>
          </button>
           <button class="btn btn--featured btn--large btn--round is-hidden" data-pomodoro-action="stop">          
            <i class="fa fa-stop" aria-hidden="true"></i>
            <span class="is-hidden">Stop</span>
          </button>          
        </div>
        
        <div class="pomodoro__session is-hidden" data-pomodoro="session-display"></div>
      </div>      
      <div class="pomodoro__time animated" data-pomodoro="time-display">
        00 : 00
      </div>
    </div>
  </div>
  <footer class="page__footer">
    <p class="copywrite">
      By <a href="http://alexsandro-sa.com.br" target="_black">Alexsandro Silva Alves</a> with <span> 
      <b class="is-hidden">love</b>
      <i class="fa fa-heart" aria-hidden="true"></i>
      </span>
    </p>
  </footer>
</section>
              
            
!

CSS

              
                // VARIABLES
// ---------------------------
$bg-site: #C10202;

// Base
// ---------------------------
html {
  height: 100%;
}
html, body {
  font-family: 'Orbitron', sans-serif;
  background-color: #C10202;
  color: #fff;
}

// Util
// ---------------------------
.is-hidden {
  display: none !important;
}
.is-shadow { 
  color: white; 
  text-shadow: 1px 1px #fe4902, 
    2px 2px #fe4902, 
    3px 3px #fe4902;
  transition: all 0.20s ease-out;
  
  &:hover {
    position: relative; 
    top: -3px; 
    left: -3px; 
    text-shadow: 1px 1px #fe4902, 
      2px 2px #fe4902, 
      3px 3px #fe4902, 
      4px 4px #fe4902, 
      5px 5px #fe4902, 
      6px 6px #fe4902;
  }
}
.is-text-bordered {
  text-stroke: 1px #4E3739;
}
.is-disabled-clicks {
   pointer-events: none;
}
// Components
// ---------------------------
.btn {
  display: inline-block;
  font-weight: normal;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease-in-out;
  background: transparent;
  color: #fff;
  
  &:focus, 
  &:hover {
    text-decoration: none;
    background: rgba(0, 0, 0, .3);
  }
  
  &--large {
    font-size: 2.3em;
  }
  
  &--round {
    border-radius: 50%;
  }
}

.pomodoro {
  width: 250px;
  margin: 0 auto;
  
  &__config {
    clear: both;
    height: 100px;
  }
  
  &__config-item {
    float: left;
    width: 115px;
  }
  
  &__config-item-title {
    margin: 0;
    margin-bottom: 5px;
  }
  
  &__timer {
    position: relative;
    width: 250px;
    height: 250px;
    background-color: #fe4902;
    border-radius: 50%;      
  }
  
  &__session {
    position: absolute; 
    bottom: 50px;
    left: 50%;
    width: 50px;
    margin-left: -25px;
    //color: #C10202;
  }
  
  &__time {
    font-size: 2em;
    margin-top: 10px;
    margin-bottom: 10px;
  }
  
  &__actions {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-left: -30px;
    margin-top: -30px;
    border-radius: 50%;
    background: $bg-site;
   
    width: 60px;
    height: 60px;
    line-height: 60px;
  }
}

// Layout
// ---------------------------
.page {
  text-align: center;

  &__heading {
    margin-top: 10px;  
  }

  &__title {
    font-size: 3em;
    margin-bottom: 10px;
  }

  &__content {}

  &__footer {
    font-size: 10px;
    
    a {
      color: #fff;      
    }
  }
}
              
            
!

JS

              
                (function(win, $){
  // Variables 
  const $doc = $(document);
  let TIMER_POMODORO;

  // Event
  $doc.on('click', '[data-pomodoro-action="start"]', play);
  $doc.on('click', '[data-pomodoro-action="stop"]', stop);
  $doc.on('click', '[data-pomodoro-action="decrement"]', decrementTime);
  $doc.on('click', '[data-pomodoro-action="increment"]', incrementTime);

  function play() {
    const $timer = getElementDisplayTimer();
    const $sessionName = getElementPomodoSessionDisplay();
        
    disablePomodoroConfig();
    enablePomodoroStopActions(); 
    animationTime($timer);
    startTimer($timer);
    animationTime($sessionName);
    show($sessionName);
  }
  
  function disablePomodoroConfig() {
    const $item = $('[data-pomodoro="item"]');
    disabledClick( $item.first() );
    disabledClick( $item.last() );
  }
  
  function enabledPomodoroConfig() {
    const $item = $('[data-pomodoro="item"]');
    enabledClick( $item.first() );
    enabledClick( $item.last() );
  }
  
  function enablePomodoroStopActions() {
    const $btnPlay = $('[data-pomodoro-action="start"]');
    const $btnStop = $('[data-pomodoro-action="stop"]');    
    hide($btnPlay);
    show($btnStop);   
  }
  
  function disabledPomodoroStopActions() {
    const $btnPlay = $('[data-pomodoro-action="start"]');
    const $btnStop = $('[data-pomodoro-action="stop"]');    
    hide($btnStop);
    show($btnPlay);   
  }
  
  function getElementDisplayTimer() {
    return $('[data-pomodoro="time-display"]');
  }
  
  function getValueConfigSession() {
    const $configSession = getElementConfigSession();
    return $configSession.find('[data-pomodoro-time="value"]').text();
  }
  
  function getElementConfigSession() {
    return $('[data-pomodoro="session"]');
  }
  
  function getElementConfigBreak() {
    return $('[data-pomodoro="break"]');
  }
  
  function getValueConfigBreak() {
    const $configBreak = getElementConfigBreak();
    return $configBreak.find('[data-pomodoro-time="value"]').text();
  }
  
  function animationTime() {
    const $timer = getElementDisplayTimer();
    $timer.addClass('bounce');
  }

  function startTimer($display) {    
    let isBreak = false;
    let minutes = 0; 
    let seconds = 0;    
    let breakTimer = getValueConfigBreak();
    let sessionTimer = getValueConfigSession();
    let timer = convertIntInMinutes(sessionTimer);
    let nameSession = 'WORK';
    
    setNamePomodoSessionDisplay( nameSession );

    TIMER_POMODORO = setInterval(() => {
      minutes = parseInt(timer / 60, 10);
      seconds = parseInt(timer % 60, 10);

      minutes = minutes < 10 ? "0" + minutes : minutes;
      seconds = seconds < 10 ? "0" + seconds : seconds;

      $display.text(`${minutes} : ${seconds}`);

      if (--timer < 0) {        
        isBreak = !isBreak;
        timer = (isBreak) ? convertIntInMinutes(breakTimer) : convertIntInMinutes(sessionTimer);
        nameSession = (isBreak) ? 'BREAK' : 'WORK';
        setNamePomodoSessionDisplay( nameSession );
      }
    }, 1000);
  }
  
  function stop() {
    const $sessionName = getElementPomodoSessionDisplay();
        
    clearInterval(TIMER_POMODORO);
    zeroTimer();
    hide($sessionName);    
    enabledPomodoroConfig();
    disabledPomodoroStopActions(); 
  }
  
  function zeroTimer() {
    const $display = getElementDisplayTimer();
    $display.text('00 : 00');
  }
  
  function decrementTime() {
    const $el = $(this);
    const $valueConfig = getElementPomodoroConfigValue($el);
    const currentValue = getPomodoroConfigValue($el);
    let newValue = convertToNumber(currentValue);

    if(isValueValid(newValue)) {
      setPomodoroConfigValue($el, --newValue);
    }
  }

  function incrementTime() {
    const $el = $(this);
    const $valueConfig = getElementPomodoroConfigValue($el);
    const currentValue = getPomodoroConfigValue($el);
    let newValue = convertToNumber(currentValue);

    setPomodoroConfigValue($el, ++newValue);
  }

  function getElementPomodoroConfigItem($el) {
    return $el.parents('[data-pomodoro="item"]');
  }

  function getElementPomodoroConfigValue($el) {
    const $item = getElementPomodoroConfigItem($el);
    return $item.find('[data-pomodoro-time="value"]');
  }

  function getPomodoroConfigValue($el) {
    const $item = getElementPomodoroConfigValue($el);
    return $item.text();
  }
  
  function getElementPomodoSessionDisplay(){
    return $('[data-pomodoro="session-display"]');
  }
  
  function setNamePomodoSessionDisplay(name){
    const $sessionName = getElementPomodoSessionDisplay();
    $sessionName.text( name );
  }

  function setPomodoroConfigValue($el, value) {
    const $item = getElementPomodoroConfigValue($el);
    return $item.text( value );
  }

  function convertToNumber(string) {
    return parseInt(string, 10);
  }
  
  function convertIntInMinutes(int) {
    return int * 60;
  }

  function isValueValid(value) {
    const MIN_TIME = 1;
    return (value > MIN_TIME);
  }  
   
  // External module - Util.js
  function show($el) {
    $el.removeClass('is-hidden');
  }
  
  function hide($el){
    $el.addClass('is-hidden');
  }
  
  function disabledClick($el) {
    $el.addClass('is-disabled-clicks');
  }
  
  function enabledClick($el) {
    $el.removeClass('is-disabled-clicks');
  }
 
})(window, jQuery);

              
            
!
999px

Console