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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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="root"></div>



              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Lato|Roboto+Mono|Nova+Square");

.App {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  font-family: "Lato", sans-serif;
  font-family: "Nova Square", cursive;
  color: #2c363f;
  padding: 50px;
  background-color: honeydew;
  min-height: 100vh;
  min-width: 400px;
}

#header {
  font-family: "Lato", sans-serif;
  font-size: 3.5em;
}
#clockWrapper {
  min-width: 35%;
  /* max-width: 75%; */
  border-radius: 25px;
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template: 40% 50%;
  grid-gap: 10px;
  grid-template-areas:
    "breakBox sessionBox"
    "timerBox timerBox";
  box-shadow: inset 0 0 2px 1px rgba(14, 13, 13, 0.397),
    2px 2px 50px 1px rgba(14, 13, 13, 0.397);
}

.clockBackground {
  background-color: #587b7f;
}
#breakBox {
  grid-area: breakBox;
  background-color: honeydew;

  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  border-radius: 25px 5px 5px 5px;
  padding: 10px;
}
#break-label,
#session-label {
  font-size: 1.5em;
  width: 100%;
}
#break-length,
#session-length {
  font-size: 3em;
  font-family: "Roboto Mono", monospace;
}

#sessionBox {
  grid-area: sessionBox;
  background-color: honeydew;

  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  border-radius: 5px 25px 5px 5px;
  padding: 10px;
}

#timerBox {
  grid-area: timerBox;
  background-color: honeydew;
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  grid-template-areas: "startStop timerLabel reset";
  border-radius: 5px 5px 25px 25px;
}

.increment {
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 3em;
  color: #3cdbd3;
}

.decrement {
  color: #ff8360;
  font-size: 3em;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 50%;
}

#start_stop,
#reset {
  font-size: 3em;
  padding: 5px 10px;
  margin: 2px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#reset {
  grid-area: reset;
  color: #ff8360;
}

#start_stop {
  grid-area: startStop;
}

#reset:active,
#start_stop:active,
.increment:active,
.decrement:active {
  transform: translateY(2px);
}

.decrement:active,
.fa-pause-circle:active,
.fa-redo-alt:active {
  box-shadow: inset 0 0 15px 1px #ff8360, 0 0 1px 1px #ff8360;
  border-radius: 50%;
}

.increment:active,
.fa-play-circle:active {
  border-radius: 50%;
  box-shadow: inset 0 0 15px 1px #3cdbd3, 0 0 1px 1px #3cdbd3;
}

.run-animation {
  animation: 0.75s linear 0s spin;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-120deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.fa-play-circle {
  color: #3cdbd3;
}

.fa-pause-circle {
  color: #ff8360;
}
#timer-label {
  color: #2c363f;
  font-size: 1.5em;
  grid-area: timerLabel;
}

#time-left {
  font-size: 3em;

  font-family: "Roboto Mono", monospace;
}

.sessionBackground {
  background-color: #f9fbb2;
  background-color: #392a16;
  transition: background-color 2s;
}

.breakBackground {
  background-color: #a1cca5;
  background-color: #587b7f;
  transition: background-color 2s;
}

.footer {
  font-family: "Nova Square", cursive;
  width: 100%;
  font-size: 1.25em;
  margin: 100px 0;
  color: #ff8360;
  text-align: center;
  text-shadow: 0 2px 20px rgba(51, 51, 51, 0.514);
}
.socialLinks i {
  font-size: 1.75em;
  margin: 0px 10px;
  color: #587b7f;
}

              
            
!

JS

              
                

class App extends React.Component{
 constructor(props) {
    super(props);
    this.state = {
      breakLength: 5,
      sessionLength: 25,
      timeLeft: 1500,
      timerLabel: "Session",
      oneMinLeft: true,
      countdownSession: true,
      pause: true,
      interval: null
    };

     this.playPause = this.playPause.bind(this);

     this.incrementBreak = this.incrementBreak.bind(this);
     this.decrementBreak = this.decrementBreak.bind(this);
    this.incrementSession = this.incrementSession.bind(this);
     this.decrementSession = this.decrementSession.bind(this);
     this.reset = this.reset.bind(this);
  }
  
  playPause() {
    let interval = null;
    if (this.state.interval) {
      interval = clearInterval(this.state.interval);
    } else {
      interval = setInterval(() => {
        if (this.state.timeLeft > 0) {
          this.setState({ timeLeft: this.state.timeLeft - 1, pause: false });
        } else {
          document.getElementById("beep").play();
          this.state.countdownSession
            ? this.setState({
                timeLeft: this.state.breakLength * 60,
                countdownSession: !this.state.countdownSession,
                timerLabel: "Break",
                pause: false
              })
            : this.setState({
                timeLeft: this.state.sessionLength * 60,
                countdownSession: !this.state.countdownSession,
                timerLabel: "Session",
                pause: false
              });
        }
      }, 1000);
    }
    this.setState({ interval, pause: !this.state.pause });
  }
  
   componentDidMount = () => {
    let resetBtn = document.getElementById("reset");
    resetBtn.addEventListener(
      "click",
      () => {
        resetBtn.classList.remove("run-animation");
        void resetBtn.offsetWidth;
        resetBtn.classList.add("run-animation");
      },
      false
    );

   };

  componentWillUpdate = () => {
    let background = document.getElementById("clockWrapper");
    if (this.state.timerLabel == "Session") {
      background.classList.add("sessionBackground");
      background.classList.remove("breakBackground");
    } else {
      background.classList.add("breakBackground");
      background.classList.remove("sessionBackground");
    }
  };
  
  reset() {
    document.getElementById("beep").pause();
    document.getElementById("beep").currentTime = 0;

    this.setState({
      breakLength: 5,
      sessionLength: 25,
      timeLeft: 1500,
      timerLabel: "Session",
      interval: clearInterval(this.state.interval),
      countdownSession: true,
      pause: true
    });
  }
  
   incrementBreak() {
    const curValUp = this.state.breakLength + 1;

    curValUp <= 60 && this.setState({ breakLength: curValUp });
  }

  decrementBreak() {
    const curValDown = this.state.breakLength - 1;
    curValDown > 0 && this.setState({ breakLength: curValDown });
  }

  
  incrementSession() {
    const curValUp = this.state.sessionLength + 1;
    const timeLeft = curValUp * 60;
    curValUp <= 60 &&
      this.setState({
        sessionLength: curValUp,
        timeLeft: timeLeft
      });
  }

  decrementSession() {
    const curValDown = this.state.sessionLength - 1;
    const timeLeft = curValDown * 60;
    curValDown > 0 &&
      this.setState({
        sessionLength: curValDown,
        timeLeft: timeLeft
      });
  }
  
   componentDidMount = () => {
    let resetBtn = document.getElementById("reset");
    resetBtn.addEventListener(
      "click",
      () => {
        resetBtn.classList.remove("run-animation");
        void resetBtn.offsetWidth;
        resetBtn.classList.add("run-animation");
      },
      false
    );
  };
  
  render() {
    return (
     <div className="App">
        <Header/>
        <div id="clockWrapper" className="clockBackground">
          
        <Break
          breakLength={this.state.breakLength}
            incrementBreak={this.incrementBreak}
            decrementBreak={this.decrementBreak}
          />
        <Session
          sessionLength={this.state.sessionLength}
            incrementSession={this.incrementSession}
            decrementSession={this.decrementSession}
          />
        <Timer
          timerLabel={this.state.timerLabel}
            timeLeft={this.state.timeLeft}
            reset={this.reset}
            playPause={this.playPause}
            pause={this.state.pause}
            
          />
      </div>
        <Footer/>
        </div>
    )
  }
};

const Header = () => {
  return <h1 id="header"> FCC | Pomodoro Clock</h1>;
};

class Break extends React.Component {
  render() {
    return (
      <div id="breakBox">
        <div id="break-label">
          Break Length
          <div id="break-length">{this.props.breakLength}</div>
        </div>
       <div
          id="break-decrement"
          className="decrement"
          onClick={this.props.decrementBreak}
        >
          <i className="fas fa-chevron-circle-down" />
        </div>
        <div
          id="break-increment"
          className="increment"
          onClick={this.props.incrementBreak}
        >
          <i className="fas fa-chevron-circle-up" />
        </div>
      </div>
    );
  }
}

class Session extends React.Component {
  render() {
    return (
      <div id="sessionBox">
        <div id="session-label">
          Session Length
          <div id="session-length">{this.props.sessionLength}</div>
        </div>
         <div
          id="session-decrement"
          className="decrement"
          onClick={this.props.decrementSession}
        >
          <i className="fas fa-chevron-circle-down" />
        </div>
        <div
          id="session-increment"
          className="increment"
          onClick={this.props.incrementSession}
        >
          <i className="fas fa-chevron-circle-up" />
        </div>
      </div>
    );
  }
}


class Timer extends React.Component {
  render() {
    let minutes = Math.floor(this.props.timeLeft / 60);
    let seconds = this.props.timeLeft - minutes * 60;
    seconds = seconds < 10 ? "0" + seconds : seconds;
    minutes = minutes < 10 ? "0" + minutes : minutes;
    const timeAvail = minutes + ":" + seconds;

    return (
      <div id="timerBox">
        <div id="timer-label">
          {this.props.timerLabel}
          {this.props.timeLeft < 60 ? (
            <div id="time-left" style={{ color: "#ff8360" }}>
              {timeAvail}
            </div>
          ) : (
            <div id="time-left">{timeAvail}</div>
          )}
        </div>
         <div id="start_stop" onClick={this.props.playPause}>
          {this.props.pause ? (
            <i className="fas fa-play-circle" />
          ) : (
            <i className="fas fa-pause-circle" />
          )}
        </div>
        <div id="reset" onClick={this.props.reset}>
          <i className="fas fa-redo-alt" />
        </div>
        <audio src="https://goo.gl/65cBl1" id="beep" preload="auto" />
      </div>
    );
  }
}

class Footer extends React.Component {
  render() {
    return (
      <div className="footer">
        <div className="socialLinks">
          <a href="https://github.com/Alba-C" target="_blank">
            <i className="fab fa-github" />
          </a>

          <a href="https://twitter.com/albanesechris" target="_blank">
            <i className="fab fa-twitter" />
          </a>

          <a href="https://codepen.io/Alba-C" target="_blank">
            <i className="fab fa-codepen" />
          </a>
        </div>

        <p> Created by Christopher Albanese</p>
      </div>
    );
  }
}


ReactDOM.render(<App />, document.getElementById('root'));


              
            
!
999px

Console