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

CSS

              
                *{
  margin:0;
  padding:0;
  color:white;
}
#root {
 background-color:black;
 height:100vh;
}
#container {
  margin-right:auto;
  margin-left:auto;
}
#clickable_elements,.spans,#display,#icons{
  display:flex;
  justify-content:space-between;
}
#container h1 {
  text-align:center;
  margin-bottom:20px;
  color:green;
}
#container {
  border:1px solid white;
 width:500px;
 box-sizing:border-box;
  padding:20px;
 border-radius:5px;
}

.spans{
  justify-content:center;
  margin-top:10px;
  font-size:22px;
}
.spans span{
  margin-right:10px;
  font-size:26px;
}
*#display,#icons{
  justify-content:center;
}
footer span {
  margin-right:14px;
}
              
            
!

JS

              
                class App extends React.Component {
  constructor(props){
    super(props);
    this.state ={
      break_length:5,
      breakSseconds:0,
      session_length:25,
      SMinutes:25,
      Sseconds:0,
      clearInterva:true,
      countDown:""
    }
  }
 
  incrementB(){
    {(this.state.break_length < 60) && this.setState({break_length:this.state.break_length+1})};
  }
  incrementS(){
    {(this.state.session_length < 60) && this.setState({session_length:this.state.session_length+1})};
    {(this.state.session_length != 60) && this.setState({SMinutes:this.state.session_length+1})}           
  }
    decrementB(){
    {(this.state.break_length > 1) && this.setState({break_length:this.state.break_length-1})};
  }
   decrementS(){
    {(this.state.session_length > 1) && this.setState({session_length:this.state.session_length-1})};     
     {(this.state.session_length != 1) && this.setState({SMinutes:this.state.session_length-1})}  
  }
  reset(){
    this.setState({break_length:5});
    this.setState({session_length:25});
    this.setState({SMinutes:25}); 
    this.setState({Sseconds:0});
     clearInterval(this.state.countDown);
  }
  tickingSession(){
if(this.state.clearInterva){
   this.setState({countDown:setInterval(()=>{
   this.setState({Sseconds:this.state.Sseconds-1});
 },1000)})
}
 else if (!this.state.clearInterva){
    clearInterval(this.state.countDown);
  }
    this.setState({clearInterva:!this.state.clearInterva});
}
countDown(){
  clearInterval(this.state.countDown);
}
  render(){
    return (
      <div id="container">
        <h1>Pomodro clock</h1>
        <section id="clickable_elements">
          <Break breakLength={this.state.break_length}//the displayed value default value
            incrementValB={this.incrementB.bind(this)}
            decrementValB={this.decrementB.bind(this)} />
        <Session sessionLength={this.state.session_length} //the displayed value default value
           incrementValS={this.incrementS.bind(this)}
          decrementValS={this.decrementS.bind(this)}/>
        </section>
        <SessionAndBreak incrmentSessionM={this.state.SMinutes}
           resetSeconds={this.state.Sseconds}
          restAll={this.reset.bind(this)}
          tickingBackwards={this.tickingSession.bind(this)}
          countDown={this.countDown.bind(this)}
          breakLength={this.state.break_length}
          breakSeconds={this.state.breakSseconds}
          clearInterva2={this.state.clearInterva2}
          //tickingBackBreak={this.tickingBreak.bind(this)}
          />
      </div>
    )
  }
}
const Break=(props)=>{
  return (
    <div id="break-label">
      <h2>Break Length</h2>
      <div className="spans">
        <span  onClick={props.decrementValB} id="break-decrement"><i className="fas fa-caret-down"></i></span>
        <span id="break-length">{props.breakLength}</span>
        <span  onClick={props.incrementValB} id="break-increment"  ><i className="fas fa-caret-up"></i></span>
      </div>
     </div>
  )
}
const Session=(props)=>{
  return (
    <div id="session-label">
      <h2>Session Length</h2>
      <div className="spans">
        <span onClick={props.decrementValS} id="session-decrement"><i className="fas fa-caret-down"></i></span>
        <span id="session-length">{props.sessionLength}</span>
        <span onClick={props.incrementValS} id="session-increment"><i className="fas fa-caret-up"></i>
</span>
      </div>
     </div>
  )
}

 
class SessionAndBreak extends React.Component{
  constructor(props){
    super(props);
    this.state={
      seconds:this.props.breakSeconds,
      stopCountDown:""
    }
    this.tickingBckwardBreak=this.tickingBckwardBreak.bind(this);
  }
tickingBckwardBreak(){
      this.setState({stopCountDown:setInterval(()=>{
      this.setState({seconds:this.props.breakSeconds-1})
    },1000)})
   }
 componentDidUpdate(){
   console.log("yeah I did");
 }
  componentWillMount(){
    console.log("I will mount")
  }
compponentDidMount(){
  console.log("I did mount")
}
  
  
render(){
  const sessionTime=new Date(2018, 11, 24, 10, this.props.incrmentSessionM,this.props.resetSeconds);
  const sessiontMinute=sessionTime.getMinutes();
  const sessionSeconds=sessionTime.getSeconds();
  const sessionValue=sessiontMinute+":"+sessionSeconds;
  const breakTime=new Date(2018, 11, 24, 10,this.props.breakLength,this.state.seconds);
  const breaktMinute=breakTime.getMinutes();
  const breaktSeconds=breakTime.getSeconds();
  if(sessionValue!=="0:0"){
    return (
    <section id="display_box">
     <div id="display">
        <div className="session">
         <h2>Session</h2>
          <h1 id="timer-label">
            {(sessiontMinute < 10 ? "0"+sessiontMinute:sessiontMinute && sessiontMinute === 0?60:sessiontMinute)+":"+(sessionSeconds < 10 ? "0"+sessionSeconds:sessionSeconds)}
          </h1>
        </div>
      </div>
      <footer>
        <div id="icons">
          <span onClick={this.props.tickingBackwards} id="start_stop">
          <i className="fas fa-play"></i>
            <i className="far fa-stop-circle"></i>
          </span>
          <i onClick={this.props.restAll} id="reset" className="fas fa-sync-alt"></i>
        </div>
      </footer>
    </section>
  )
  }
  else {
    this.props.countDown();
  // this.tickingBckwardBreak();
    return (
    <section id="display_box">
     <div id="display">
      <div className="break">
         <h2>Break</h2>
         <h1 id="time-left"> {(breaktMinute < 10 ? "0"+breaktMinute:breaktMinute && breaktMinute === 0?60:breaktMinute)+":"+(breaktSeconds < 10 ? "0"+breaktSeconds:breaktSeconds)}</h1>
      </div>
        </div>
      <footer>
        <div id="icons">
          <span onClick={this.props.tickingBackwards} id="start_stop">
          <i className="fas fa-play"></i>
            <i className="far fa-stop-circle"></i>
          </span>
          <i onClick={this.props.restAll} id="reset" className="fas fa-sync-alt"></i>
        </div>
      </footer>
    </section>
  )
  }
  }
}


ReactDOM.render(<App />,document.getElementById("root"));
              
            
!
999px

Console