Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

<link rel="stylesheet" href="" integrity="sha384-50oBUHEmvpQ+1lW4y57PTFmhCaXp0ML5d60M1M7uH2+nqUivzIebhndOJK28anvf" crossorigin="anonymous">
<div id="root"></div>

              @import '';
@font-face {
    font-family: "Digital";
    src: url("//");
    src: url("//") format("embedded-opentype"), url("//") format("woff2"), url("//") format("woff"), url("//") format("truetype"), url("//") format("svg");
    margin: 0;
    box-sizing: border-box;
h1 {
    padding: 0.5vh;

#root {
    display: flex;
    height: 90vw;

    margin: auto;
    border-radius: 10px;
    background-color: gray;
    max-width: 400px;
    text-align: center;
    font-family: digital;
    padding: 10px;

i {
    padding: 1vh;
    font-size: 1.5em;
    color: white;
              const Header = () => <h1>Pomodoro Clock</h1>

      /*depending on props break or session, Settimeout generate title*/
      const SetTimer = ({type, value, handleClick}) => (
        <div className = 'SetTimer'>
          <div id={`${type}-label`}>{`${type == 'session' ? 'Session ': 'Break '}Length`}</div>
            <div className = 'SetTimer-controls'>
              <a id={`${type}-decrement`} onClick={() => handleClick(false,`${type}Value`)}><i className="fas fa-minus-circle"></i></a>
              <h1 id={`${type}-length`}>{value}</h1>
              <a id={`${type}-increment`} onClick={() => handleClick(true, `${type}Value`)}><i className="fas fa-plus-circle"></i></a>

      /*conditional output*/
      const Timer = ({mode, time }) =>(
        <div className='Timer'>
          <h1 id="timer-label">{mode == 'session' ? 'Session' : 'Break'}</h1>
          <h1 id="time-left">{time}</h1>

      /*contorls rendering buttons for pause start reset*/
      const Controls = ({active, handleReset, handlePlayPause}) => (
        <div className='Controls'>
          <a id="start_stop" onClick = {handlePlayPause}>
            {active ? <span><i className="fas fa-pause-circle"></i></span>:<span><i className="fas fa-play"></i></span>}
          <a id="reset" onClick= {handleReset}><i className="fas fa-redo"></i></a>

      class App extends React.Component {
      constructor(props) {
          this.state = {
            breakValue: 5,
            sessionValue: 25,
            time: 25*60*1000, //25min
            active: false,
            touched: false

        componentDidUpdate(prevProps, prevState){
            if(prevState.time === 0 && prevState.mode === 'session'){
                this.setState({time : this.state.breakValue * 60 * 1000, mode: 'break'})
            if(prevState.time === 0 && prevState.mode === 'break'){
              this.setState({time : this.state.sessionValue * 60 * 1000, mode: 'session'})

        handleReset = ()=> {
          this.setState({ breakValue: 5, sessionValue: 25, time: 25*60*1000,mode:'session', active: false, touched: false})

 = 0

        handlePlayPause = () => {
          //if active is true (pause button) then stop timer, and show play button
              this.setState({active: false})
          //if active is false (play) then check for touched state
          } else {
              //if touched is true continue to countdown and set active to pause
                  this.pomodoro = setInterval(() => this.setState({time: this.state.time - 1000}), 1000);
                  this.setState({active: true})
              //if touchen is false set users session(not a default), and start countdown, touched true active(pause button)
              }else {
                      time: this.state.sessionValue *60 * 1000, 
                      touched: true, 
                      active: true}, ()=>this.pomodoro = setInterval(() => this.setState({time: this.state.time - 1000}), 1000))

        handleSetTimers = (inc, type) =>{
          //stop function if state is of type is 60 and add button was clicked
          if(this.state[type] == 60 && inc) return
          //stop function if state is of type is 1 and minus button was clicked
          if(this.state[type] == 1 && !inc) return
          //change state from type break / session, same type state if it is currently inc true add increment for one if false decrement for one
          this.setState({ [type] : this.state[type] + (inc ? 1: -1) })

        render() {
          return (
            <div id="pomodoroBody">
              <Timer mode= {this.state.mode} time ={moment(this.state.time).format('mm:ss')}/>


              <div className= 'settings'>
                <SetTimer type = 'break' value = {this.state.breakValue} handleClick = {this.handleSetTimers}/>
                <SetTimer type = 'session' value = {this.state.sessionValue} handleClick = {this.handleSetTimers}/>
              <audio id='beep' 
                //reference to actual DOM element
                ref = {ref => = ref}>

      ReactDOM.render(<App date={new Date()} /> ,document.getElementById('root')); 
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.