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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 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.

HTML

              
                #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
              
            
!

CSS

              
                *
  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
              
            
!

JS

              
                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

Console