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

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

              
                main(x-data="clickSpeedTest()" x-init="restart()")

  header
    p 
      span
        abbr(title="Clicks Per Second") CPS
      br
      b(x-text="cpsDisplay")
      
    div
      
    p 
      span CPS MAX
      br
      b(x-text="cpsMaxDisplay")
      
  
  button(
    x-ref="btn"
    @mousedown="mouseDown"
    @mouseup="mouseUp"
    :style="`--cps: ${cps}`"
  )
  

  footer
    p 
      span Clicks
      br
      b(x-text="clicks")
      
    div
      
    p 
      span Time
      br
      b(x-text="activeTimeDisplay")
      sub s

div Take a look
  | 
  a(href="https://github.lucianofelix.com.br/clicks" target="_blank" ref="noreferrer")
    | on a updated version
  | !
              
            
!

CSS

              
                body
  min-height: 100vh
  background-color: #222
  font-family: 'Lato', sans-serif
  color: #FFF
  display: grid
  place-items: center


main
  height: 100vh
  display: grid
  align-content: space-evenly
  justify-items: center
  align-items: center


header, footer
  display: grid
  grid-auto-flow: column
  grid-gap: 1rem
  align-items: center

  > p
    margin: 0
    text-align: center

    span
      margin-bottom: .5em
      color: #DDD
      font-size: .8em
      display: inline-block

    b
      font-size: 1.5em

  div
    width: 1px
    height: 75%
    background-color: #666


main > button
  appearance: none
  box-sizing: content-box
  width: 12rem
  height: 8rem
  padding: 0
  background-image: linear-gradient(#EEE, #EEE), linear-gradient(#222, #222), linear-gradient(-45deg, #F22, #F92, #FF2, #9F2, #2F2, #2F9, #2FF, #29F, #22F, #92F, #F2F, #F29, #F22, #F92, #FF2, #9F2, #2F2, #2F9, #2FF, #29F, #22F, #92F, #F2F, #F29, #F22)
  background-origin: border-box
  background-clip: content-box, padding-box, border-box
  background-size: auto, auto, 12rem 12rem
  background-position: center, center, 0 0
  border: 0 solid transparent
  border-radius: 2rem
  font-size: 2em
  transition: margin 100ms, border-width 100ms, border-radius 100ms, padding 100ms
  
  &:before
    content: "👆"
  
  &:active:before
    content: "👇"
  
  &:focus
    outline: none
    margin: calc(-.5rem - 2px)
    padding: 2px
    border-width: .5rem
    border-radius: 2.5rem
    animation: hue-rotate calc(10000ms / var(--cps)) infinite linear

    @keyframes hue-rotate
      to
        background-position: center, center, 12rem 12rem

body > div
  text-align: center
  position: absolute
  left: 0
  right: 0
  top: 1rem
  
  > a
    color: #FD2
              
            
!

JS

              
                const clickSpeedTest = () => {
  return {
    cps: 0,
    cpsMax: 0,
    clicks: 0,
    startTime: 0,
    endTime: 0,


    get time () {
      return new Date().getTime()
    },

    get activeTime () {
      return this.time - this.startTime
    },

    get idleTime () {
      return this.time - this.endTime
    },


    restart () {
      this.clicks = this.cps = this.cpsMax = 0
      this.startTime = this.time
    },

    mouseDown () {
      this.clicks++

      if (this.idleTime > 1000)
        this.restart()

      if (this.activeTime > 100)
        this.cps = this.clicks / this.activeTime * 1000

      if (this.activeTime > 1000)
        this.cpsMax = Math.max(this.cps, this.cpsMax)
    },

    mouseUp () {
      this.endTime = this.time
    },


    nornalize (num, fix = 2) {
      return num.toFixed(fix)
    },

    get activeTimeDisplay () {
      return this.nornalize(this.activeTime / 1000, 1)
    },

    get cpsDisplay () {
      return this.nornalize(this.cps)
    },

    get cpsMaxDisplay () {
      return this.nornalize(this.cpsMax)
    }
  }
}

              
            
!
999px

Console