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

              
                <div id="pomodoro" class="box">
  <div id="clock">
    <div id="timer">
      
      <div id="options">
        <button id="sessiondown" type='submit'>
          <i class="fa fa-angle-double-left"></i>
        </button>
        <div id="countdown">
          <span id="minutes">25</span>
          <span id="seconds">00</span>   
        </div>
        
        <button id="sessionup" type='submit'>
          <i class="fa fa-angle-double-right"></i>
        </button>
      </div>
      
      <div id="controls" class="reset">
        <button id="start"><i class="fa fa-play"></i> Start</button>
        <button id="reset"><i class="fas fa-redo-alt"></i> Reset</button>
      </div>
      
    </div>
  </div>
</div>
              
            
!

CSS

              
                * {
  box-sizing: border-box;
  outline: none;
  user-select: none;
  font-family: 'Annie Use Your Telescope', cursive;
}

.box {
  width:90%;
}

#pomodoro {
  margin: 1.5rem auto;
  
  #clock {
    background: url(https://image.freepik.com/free-vector/watercolor-floral-wreath_1278-156.jpg) no-repeat center center;
    background-size: contain;
    // display: flex;
    justify-content: center;
    margin-bottom: -6.25vw;
    padding: 16rem 0;
    
    #timer {
      $hover: 5;
      align-items: center;
      display: flex;
      flex-direction: column;
      
      #countdown {
        color: #ff778d;
        display: flex;
        font-size: 4rem;
        line-height: 4rem;
        
        #minutes::after {
          content: ":";
        }
      }
      
      #controls { 
        align-items: center;
        cursor: pointer;
        display: flex;
        flex-direction: row;
        font-weight: 700;
        margin-top: 5px;
        text-align: center;
        text-transform: uppercase;
        .fas, .svg-inline--fa {
          position: relative;
        }
        #start, #reset {
          white-space: nowrap;
          font-size: 1.2rem;
          color: #FF6F8A;
          &:hover {
            color: darken(#FF6292, $hover);
          }
        }
        
        #start {
          margin-right: 1.5rem;
        }
      }
    }
  }
  
  #options {
    color: #ff778d;
    display: flex;
    font-size: 1rem;
    justify-content: center;
    margin: 1rem 0;
    text-align: center;
    
    .fa-angle-double-right {
      cursor: pointer;
      color: #ff778d;
      font-size: 1.2rem;
      margin-left: 1.2rem;
    }
    .fa-angle-double-left {
      cursor: pointer;
      color: #ff778d;
      font-size: 1.2rem;
      margin-right: 1.2rem;
    }
    // #session, #break {
    //   align-items: center;
    //   display: flex;
    //   flex-direction: column;
    //   margin-right: 1.5rem;
    // }
    input[type=number]{
      background: linear-gradient(lighten(#a7f2e5, 10), lighten(#006050, 22));
      border: 0;
      border-bottom: calc(2px + .28vw) solid #a7f2e5;
      border-radius: 50%;
      color: white;
      font-size: 2rem;
      margin: calc(5px + .43vw) calc(3px + .43vw);
      padding: calc(3px + .43vw) calc(5px + .43vw);
      text-align: center;
      &::-webkit-inner-spin-button, 
      &::-webkit-outer-spin-button { 
        -webkit-appearance: none; 
      }
    }
  }
  
  button {
    border: none;
    background-color: transparent;
  }
}

@media (max-width: 500px) {
  .box {
    width: 100%;
  }
  
  #pomodoro {
    margin: 5rem auto;
    
    #clock {
      background: url(https://image.freepik.com/free-vector/watercolor-floral-wreath_1278-156.jpg) no-repeat center center;
      background-size: 100%;
      margin-bottom: 1rem;
      padding: 6rem 0;
    
      #countdown {
        font-size: 1rem;
        line-height: 1rem;
      }
      #timer{
        
        #options {
          font-size: .8rem;
          margin: 1rem 0;

          .fa-angle-double-right {
            font-size: .8rem;
            margin-left: .5rem;
          }
          .fa-angle-double-left {
            font-size: .8rem;
            margin-left: .5rem;
          }
        }
        
        #controls {
          #start {
            margin-right: .5rem;
          }
        }
      } 
    }
  }
  
  
  
 
}
              
            
!

JS

              
                class Pomodoro {
  constructor() {
    this.buttons = {
      start: $('#start'),
      reset: $('#reset'),
      sessionUp: $('#sessionup'),
      sessionDown: $('#sessiondown')
    }
    this.sessionInput = $('#sessioninput')
    this.minutes = 25
    this.countdown
    this.playing = false
    
    this.registerEvents()  
    // this.init()
  }
  registerEvents() {
    
    // increasing the minutes
    this.buttons.sessionDown.on('click', () => {
      if (this.playing === true) {
        return
      }
      if (this.minutes > 1) {
        this.minutes--
        $('#minutes').html(this.minutes < 10 ? '0' + this.minutes : this.minutes)
      }
    })
    
    // decreasing the minutes
    this.buttons.sessionUp.on('click', () => {
      if (this.playing === true) {
        return
      }
      if (this.minutes < 50) {
        this.minutes++
        $('#minutes').html(this.minutes < 10 ? '0' + this.minutes : this.minutes)
      }
    })
    
    // resetting the timer
    this.buttons.reset.on('click', () => {
      // this.minutes = 30
      $('#minutes').html(this.minutes < 10 ? '0' + this.minutes : this.minutes)
      $('#seconds').html('00')
      this.playing = false
      clearInterval(this.countdown)
    })
    
    this.buttons.start.on('click', () => {
      const duration = this.minutes * 60
      this.startCount(duration)
    })
  }
  
  
  // the countdown method
  startCount(duration) {
    this.playing = true
    this.countdown = setInterval(() => {
      let minutes = parseInt(duration / 60, 10)
      let seconds = parseInt(duration % 60, 10)
      
      minutes = minutes < 10 ? '0' + minutes : minutes
      seconds = seconds < 10 ? '0' + seconds : seconds
      
      $('#minutes').html(minutes)
      $('#seconds').html(seconds)
      
      if (--duration < 0) {
        clearInterval(this.countdown)
        
        this.playing = false
        return
      }
    }, 1000)
  }

}

const clock = new Pomodoro()
              
            
!
999px

Console