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

              
                #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