css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <div class="wrapper">
   <div class="case">
      <div class="pwr"></div>
      <div id="pwr-light" class="pwr-light-on"></div>
      <div class="switch-hole"></div>
      <a href="#" onclick="pwrSwitch();">
         <div class="switch"><h3>PWR</h3></div>      
      </a>
      <div class="light-hole"></div>
      <div id="blinkyLight" class="light-off"></div>
      <div class="light-highlight"></div>
      <div class="label">
         <h2>METRONOME</h2>
         <h3>DIGITAL</h3>
      </div>
      <div id="tempoDisplay" class="tempo">120</div>
      <div class="display"></div>
      <div class="bpm">BPM</div>
      <div class="adjust">
         <ul>
            <a href="#" id="adjustDn" onmousedown="tempoChange(-1)"><li>-</li></a>
            <a href="#" id="adjustUp" onmousedown="tempoChange(1)"><li>+</li></a>
         </ul>
      </div>
<!--       <div class="tap-hole"></div>
      <div class="tap">
            <h4>TAP</h4> -->
      </div>
   </div>
</div>
            
          
!
            
              @import url("https://fonts.googleapis.com/css?family=Muli");
@import url('https://fonts.googleapis.com/css?family=VT323');

body {
  background-color: #ede4cb;
}
.case {
  margin: 0 auto;
  position: relative;
  width: 400px;
  height: 180px;
  background-color: #3b333d;
  box-shadow: inset 0 0 4px #333,
              inset -2px 2px 6px #aaa39bcc,
              -5px 5px 12px #444444aa,
              -15px 8px 60px #444444aa,
              inset 1px -6px 40px #22222166,
              inset 0 -10px 40px #222,
              inset -8px 12px 100px #FF8A8026;
  border-radius: 12px;
  margin-top: 40px;
}
.pwr {
   position: absolute;
   width: 4px;
   height: 20px;
   top: 130px;
   right: -4px;
   background: -webkit-linear-gradient(top, #cfccd3 0%,#6b7e96 28%,#0a0809 74%);
}
.pwr-light-on {
   position: absolute;
   width: 5px;
   height: 5px;
   border-radius: 50%;
   bottom: 38px;
   right: 21px;
   background: #D4E157;
   box-shadow: 0 0 4px #D4E157,
               inset 0 0 1px #111;
   transition: .2s;
}
.pwr-light-off {
   position: absolute;
   width: 5px;
   height: 5px;
   border-radius: 50%;
   bottom: 38px;
   right: 21px;
   background: #272805;
   box-shadow: inset 0 0 1px #111;
   transition: .4s;   
}
.switch-hole {
   position: absolute;
   width: 51px;
   height: 26px;
   bottom: 26px;
   right: 38px;
   background: #000; 
   border-radius: 3px;
   box-shadow: inset 1px -1px 2px #777,
               inset -1px 1px 2px #000,
               inset -5px 5px 50px #cdc1c333;
}
.switch {
   position: absolute;
   bottom: 28px;
   right: 40px;
   width: 46px;
   height: 22px;
   background: -webkit-linear-gradient(top, #585858 39%,#121212 74%,#121212 74%);    
}
.switch:active {
   background: -webkit-linear-gradient(top, #585858 39%,#121212 74%,#121212 74%);
   box-shadow:inset -2px 2px 8px #222;
   transition: .03s;
}

.switch h3 {
   color: #333;
   font-weight: normal;
   letter-spacing: 2px;
   text-align: center;
   margin-top: 4px;
   font-size: 11px;
   opacity: .5;
   text-shadow: -1px 1px 0 #bbb;
}
.light-hole {
  position: absolute;
  width: 23px;
  height: 23px;
  background-color: #000;
  box-shadow: inset 1px -1px 2px #77777acc;
  border-radius: 50%;
  top: 39px;
  left: 27px;
}
.light-off {
  position: absolute;
  width: 16px;
  height: 16px;
  background-color: #D32F2Fcc;
  border-radius: 50%;
  top: 42px;
  left: 32px;
  box-shadow: inset 2px -2px 6px #a11e1e,
              inset -5px 3px 4px #ffccca55,
              0 0 6px #000; 
}
.light-on {
   background: #f9acac;
}
.label {
  text-rendering: optimizeLegibility;
  color: #eae4deee;
  opacity: .8;
}
.label h2 {
  font-family: "Muli";
  font-weight: bold;
  font-size: 16px;
  letter-spacing: 3.3px;
  text-shadow: -1px 1px 0 #33333a77;
  padding: 8px;
  position: absolute;
  right: 26px;
  top: 24px;
}
.label h3 {
   position: absolute;
   font-weight: normal;
   font-size: 11px;
   text-rendering: optimizelegibility;
   letter-spacing: 4.6px;
   top: 20px;
   right: 33px;
   opacity: .45
}
.display {
   position: absolute;
   width: 125px;
   height: 60px;
   top: 20px;
   left: 70px;
   background-color: #000000aa;
   border-radius: 9px;
   box-shadow: inset 1px -1px 2px #777,
               inset -1px 1px 2px #000,
               inset -5px 5px 50px #cdc1c333;
}
.tempo {
   position: absolute;
   font-family: 'VT323', monospace;
   font-size: 46px;
   color: #45a4bcee;
   top: 22px;
   right: 232px;
   text-align: right;
   letter-spacing: 5px;
   z-index: 10;
   opacity: .85;
   text-shadow: 0 0 20px #5ed0ed,
               -2px 5px 0 #ffffff10;
   transition: 3s;
}
.tempo-off { 
   opacity:.2;
   transition: 2s;
}
.bpm {
   position: absolute;
   font-size: 7px;
   letter-spacing: 1px;
   color: #6ddbce77;
   top: 66px;
   left: 170px
}
.adjust {
   position: absolute;
   bottom: 10px;
   left: 30px;
}
.adjust ul li {
   display: inline-block;
   list-style: none;
   color: #ddddda88;
   font-size: 20px;
   font-weight: bold;
   border-radius: 9px;
   background: #555;
   width: 56px;
   height: 40px;
   text-align: center;
   padding-top: 18px;
   margin-right: 10px;
   box-shadow: -2px 2px 4px #222,
               inset -2px 2px 0 #666,
               0 0 6px #111;
}
.adjust ul li:active {
   background-color: #515151;
   box-shadow: -1px 1px 0 #333,
               inset 1px -1px 0 #222,
               0 0 6px #111;
}
.tap-hole {
   position: absolute;
   width: 110px;
   height: 66px;
   top: 94px;
   right: 46px;
   background-color: #000;
   border-radius: 12px;
}
.tap  {
   position: absolute;
   width: 100px;
   height: 51px;
   top: 101px;
   right: 52px;
   background-color: #22222acc;
   border-radius: 9px;
   box-shadow: -6px 4px 8px #00000a33,
               inset -1px 1px 4px #565656;
}
.tap h4 {
   color: #eae4deee;
   text-align: center;
   letter-spacing: 13px;
   font-weight: normal;
   opacity: .2;
   padding-left: 13px;
   margin-top: 19px
}

            
          
!
            
              // THIS IS A WORK IN PROGRESS. 

// STILL TO WORK ON IS INTERACTIVITY TO 
// HACE THE LED FLASH IN TIME WITH THE TEMPO



// INITIAL STATE 
var powerState = true;  // initial power state On
var tempo      = 120;   // initial tempo
var tempoLight = document.getElementById('blinkyLight');


// ELEMENT VARIABLES
var pwrLight     = document.getElementById('pwr-light');
var tempoDisplay = document.getElementById('tempoDisplay')

// VISUAL STATES FOR POWER ON AND OFF
function pwrSwitch() {
   powerState = !powerState;   // toggle powerState
   if(powerState == false) {
      pwrLight.classList.remove('pwr-light-on');  
      pwrLight.classList.add('pwr-light-off');
      tempoDisplay.classList.remove('tempo-on');
      tempoDisplay.classList.add('tempo-off');
   } else
   if (powerState == true) {
      pwrLight.classList.remove('pwr-light-off');
      pwrLight.classList.add('pwr-light-on');
      tempoDisplay.classList.remove('tempo-off');
      tempoDisplay.classList.add('tempo');
   }
}

// INCREMENT AND DECREMENT TEMPO VALUE
function tempoChange(val) {
   if(powerState == true) {
      var newTempo = (tempo + val);  // take value from tempo adjust html 
      tempo = newTempo;             // update the new tempo value
      setTimeout(function(){        // update display with slight delay
         document.getElementById('tempoDisplay').innerHTML = tempo;
      }, 100); 
   }
}

function pulseLight () {
   tempoLight.classList.add('light-on');
   setTimeout(function() {
      tempoLight.classList.remove('light-on');
      tempoLight.classList.add('light-off');
   }, 80);
}

setInterval(function() {
   pulseLight();
   document.getElementById('myNum').innerHTML = tempo;
   }, 60000 / tempo);

            
          
!
999px
🕑 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.
Loading ..................

Console