Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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>
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js" />
              
            
!

CSS

              
                *{
  text-align: center;
}
#app{
  height: 100vh;
  overflow: scroll;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2vw;
  overflow: scroll;
}
#setTime{
  min-height: 60vh;
}
#setBreak{
  min-height: 60vh;
}
#timer-label{
  height: 60vh;

}
.miniDisplay{
  margin: 5vh auto 5vh auto ;
  max-width: 15vw;
  width: 15vw;
  height: 20vh;
/*   border: .3px solid grey; */
  border-radius: 5px;
  box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 8px;
  font-size: 80px;
  text-align: center;
}
h2{
  margin-top: 5vh;
  font-size: 30px;
  font-family: sans-serif, georgia;
}
 .timeD{
   margin-left: 5%;
  width: 90%;
  font-size: 90px;
  margin-top: 10vh;
  margin-bottom: 8vh;
  border-radius: 5px;
  box-shadow: rgba(149, 157, 165, 0.2) 0px 8px 8px ;
}
#timer-label{
  width: 30vw;
}

#play{
  margin-top: 10vh;
}
p{
  font-size: 50px;
}

.disabled{
  fill: rgb(80,80,80);
}
              
            
!

JS

              
                import * as React from "https://cdn.skypack.dev/react@17.0.1";
import * as ReactDOM from "https://cdn.skypack.dev/react-dom@17.0.1";

const App = () => {
  const [time, setTime] = React.useState(25);
  const [rest, setRest] = React.useState(5);
  const [count, setCount] = React.useState(time*60);
  const [timer, setTimer] = React.useState();
  let countTime = count;
  let breakTime = rest * 60;
  const [clicked, setClicked] = React.useState(false);
  
   const handleTimeIncrease = () =>{
     if (time <= 59){
     setTime((time) => time+=1);
     setCount((count) => count+=60);
     }
   }            
      
   const handlePlay = () => {
     setClicked (!clicked);
     setTimer(setInterval(() => {
      if (countTime == 0 && breakTime == 0){
        clearInterval(timer)
      } 
       else if (countTime == 0 & breakTime !=0) {
        (breakTime >= 1) ? breakTime -= 1 : breakTime = 0; 
         setCount(breakTime)
       }
       else{
        (countTime >= 1) ? countTime -= 1 : countTime = 0;
         setCount(countTime)
      }
     }, 1000));
   }
  const handlePause = () => {
    clearInterval(timer);
    setClicked(false);
  } 
  const handleReset = () => {
    clearInterval(timer);
    setRest(5);
    setTime(25);
    setCount(25*60);
    setClicked(false);
  }
  
  return(
    <div id="app"
      className="bg-blue-300 aspect-square"
      >
    <div 
      id="setTime"
      className="w-56 bg-white shadow rounded "
      >
      <h2 id="session-label"> Session Length </h2>
      <div
        id="session-length"
        className="miniDisplay"
        >{time}</div>
      <button 
id="session-increment"        className="controls"
        onClick ={handleTimeIncrease}
        >
        <svg xmlns="http://www.w3.org/2000/svg" className="h-10 w-10" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
  <path strokeLinecap="round" strokeLinejoin="round" d="M9 11l3-3m0 0l3 3m-3-3v8m0-13a9 9 0 110 18 9 9 0 010-18z" />
</svg>
</button>
      <button
        
id="session-decrement"        className="controls"
        onClick ={() =>{ setTime((time) => (time >= 2 ) ? time-=1 : time=1)
       setCount((count) => (count >60 ) ? count-=60: count=60)
                       }}
        >
        <svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
  <path stroke-linecap="round" stroke-linejoin="round" d="M15 13l-3 3m0 0l-3-3m3 3V8m0 13a9 9 0 110-18 9 9 0 010 18z" />
</svg>
  
</button>
    </div>
      <div
       id="timer-label"
       className="w-64 bg-white shadow rounded"
       >
        <div className="timeD">
       <h1 id="time-left">
          {Math.floor(countTime/60)}:{(countTime%60 <10) ? "0" +  parseInt(countTime%60, 10): parseInt(countTime%60, 10)}
        </h1>
        </div>
        <div id ="start_stop">
        <button
          onClick={handlePlay}
          disabled={clicked}
          >
          <svg xmlns="http://www.w3.org/2000/svg" className={(clicked) ? "h-10 w-10 disabled" : "h-10 w-10"} viewBox="0 0 20 20" fill="vlue">
  <path fillRule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clipRule="evenodd" />
</svg>
        </button>
        <button
          onClick={handlePause}
          >
          <svg xmlns="http://www.w3.org/2000/svg" className="h-10 w-10" viewBox="0 0 20 20" fill="currentColor">
  <path fillRule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zM7 8a1 1 0 012 0v4a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v4a1 1 0 102 0V8a1 1 0 00-1-1z" clipRule="evenodd" />
</svg>
        </button>
        <button
          id="reset"
          onClick={handleReset}
          >
          <svg xmlns="http://www.w3.org/2000/svg" className="h-10 w-10" viewBox="0 0 20 20" fill="currentColor">
  <path fillRule="evenodd" d="M4 2a1 1 0 011 1v2.101a7.002 7.002 0 0111.601 2.566 1 1 0 11-1.885.666A5.002 5.002 0 005.999 7H9a1 1 0 010 2H4a1 1 0 01-1-1V3a1 1 0 011-1zm.008 9.057a1 1 0 011.276.61A5.002 5.002 0 0014.001 13H11a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0v-2.101a7.002 7.002 0 01-11.601-2.566 1 1 0 01.61-1.276z" clipRule="evenodd" />
</svg></button>
        </div>
      </div>
      
    <div
      id="setBreak"
      className="w-56 bg-white shadow rounded"
      >
      <h2 id="break-label"> Break Length</h2>
      <div id="break-length" className="miniDisplay">{rest}</div>
      <button
        id="break-increment"
        className="controls"
        onClick ={() => setRest((rest) => (rest <= 59) ? rest+=1 : rest=60)
                 }
        ><svg xmlns="http://www.w3.org/2000/svg" className="h-10 w-10" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth={2}>
  <path strokeLinecap="round" strokeLinejoin="round" d="M9 11l3-3m0 0l3 3m-3-3v8m0-13a9 9 0 110 18 9 9 0 010-18z" />
</svg></button>
      <button
        id="break-decrement"
        className="controls"
        onClick ={() => {setRest((rest) => (rest>= 2 ) ? rest-=1: rest =1)}}
        ><svg xmlns="http://www.w3.org/2000/svg" class="h-10 w-10" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
  <path stroke-linecap="round" stroke-linejoin="round" d="M15 13l-3 3m0 0l-3-3m3 3V8m0 13a9 9 0 110-18 9 9 0 010 18z" />
</svg></button>
      
     </div>
      </div>
  )
}

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

Console