123

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.

            
              #palette
  each val in ['', '#d6e685', '#8cc665', '#44a340', '#1e6823']
    label
      input(type="radio", name="brush", value=val)
#calendar
  ul
    - var n = 0
    while n < 45
      - n++
      li
        ul
          each val in [0, 1, 2, 3, 4, 5, 6]
            li.pixel
label
  a(href='https://github.com/gelstudios/gitfiti') gelstudios/gitfiti
  textarea#gitfiti
label
  a(href='https://github.com/bayandin/github-board') bayandin/github-board
  textarea#github-board
            
          
!
            
              *
  font-family sans-serif
#palette
  label
    display inline-block
    height 40px
    width 40px
    margin 10px
    overflow hidden
    border 2px solid grey
    cursor pointer
    color transparent
    colours = #eee #d6e685 #8cc665 #44a340 #1e6823
    for colour, i in colours
      &:nth-of-type({i+1})
        background-color colour
#calendar
  font-size 0
  margin 0 0 10px 0
  cursor crosshair
  user-select none
  -webkit-user-select none
  -moz-user-select none
  > ul
    padding 0
    margin 0
    > li
      overflow hidden
      display inline-block
      width 13px
      height 91px
      margin 0
      > ul
        padding 0
        margin 0
        > li
          border 1px solid white
          display inline-block
          width 11px
          height 11px
          overflow hidden
          background-color #eee
textarea
  font-family monospace
  font-size 10px
  display block
  width 600px
  height 120px
  margin 0 0 10px 0
            
          
!
            
              let painting = false
document.body.addEventListener('mousedown', event => {
  if (event.target.className === 'pixel') {
    painting = true
    paint(event.target)
  }
})
document.body.addEventListener('mouseup', event => {
  painting = false
})
document.body.addEventListener('mouseover', event => {
  if (painting && event.target.className === 'pixel') {
    paint(event.target)
  }
})
function paint(pixel) {
  let brush = document.querySelector('input[name="brush"]:checked')
  let color = brush ? brush.value : ''
  let index = Math.floor(Array.prototype.indexOf.call(
    brush.parentNode.parentNode.childNodes,
    brush.parentNode
  ) / 2)
  pixel.style.backgroundColor = color
  pixel.dataset.brush = index
  updateTemplates()
}
function updateTemplates() {
  let data = [[],[],[],[],[],[],[]]
  let columns = document.querySelectorAll('#calendar > ul > li')
  Array.prototype.forEach.call(columns, (col, x) => {
    let cells = col.querySelectorAll('.pixel')
    Array.prototype.forEach.call(cells, (cell, y) => {
      let brush = cell.dataset.brush || 0
      data[y][x] = brush
    })
  })
  updateGitHubBoard(data)
  updateGitfiti(data)
}
function updateGitHubBoard(data) {
  document.getElementById('github-board').value =
    data.map(row => row.join('')).join('\n')
}
function updateGitfiti(data) {
  document.getElementById('gitfiti').value = ':template\n[[' +
    data.map(row => row.join()).join('],\n[') + ']]'
}
            
          
!
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.

Console