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

              
                -
  const COLUMNS = [
    {
      title: "To Do",
      tasks: [
        "Uses contenteditable",
        "Click to Edit!"
      ]
    },
    {
      title: "Click to Edit!",
      tasks: [
        "Creating Demo",
        "Practice DOM manipulation"
      ]
    },
    {
      title: "CSS",
      tasks: [
        "Learn flexbox"
      ]
    }
  ]

.board
  for column in COLUMNS
    .board__column.column
      .column__content
        .column__title(contenteditable='true')= column.title
        .column__tasks(ondrop="ON_DROP(event)" ondragover="ALLOW_DROP(event)")
          if column.tasks
            for task in column.tasks
              .task(draggable="true" ondragstart="ON_DRAG_START(event)")
                button.task__remove(title="Remove task" onclick="REMOVE_TASK(event)") Remove task
                  svg(viewBox="0 0 352 512" width="24" title="times")
                    path(d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z")
                .task__content(contenteditable="true")= task
        button.column__add(title="Add task" onclick="ADD_TASK(event)") Add task
          svg(viewBox="0 0 512 512" width="24" title="plus-circle")
            path(d="M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm144 276c0 6.6-5.4 12-12 12h-92v92c0 6.6-5.4 12-12 12h-56c-6.6 0-12-5.4-12-12v-92h-92c-6.6 0-12-5.4-12-12v-56c0-6.6 5.4-12 12-12h92v-92c0-6.6 5.4-12 12-12h56c6.6 0 12 5.4 12 12v92h92c6.6 0 12 5.4 12 12v56z")
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css2?family=Patrick+Hand&display=swap');

*
  box-sizing border-box

body
  min-height 100vh
  display flex
  align-items center
  justify-content center
  font-family 'Patrick Hand', cursive
  font-size 2rem
  background hsl(180, 25%, 25%)

.board
  display flex
  width 80%
  height calc(100vh - 2rem)
  border 1rem solid hsl(35, 40%, 40%)
  overflow-y hidden

  &__column
    flex 1 1 100%

.column
  background hsl(0, 0%, 98%)
  display flex
  flex-direction column
  flex 1 0 300px
  overflow auto

  &__content
    flex 1
    overflow auto
    display flex
    flex-direction column

  &__tasks
    flex 1 1 auto
    overflow-y auto

  &__add
    position relative
    height 44px
    background transparent
    color transparent
    border 0
    opacity 0.25
    cursor pointer
    flex 0 0 44px

    &:hover
      opacity 1
      transition opacity .2s

    svg
      position absolute
      top 50%
      left 50%
      transform translate(-50%, -50%)

  &__title
    text-align center
    padding 1rem
    flex 0 0 auto
    font-weight bold
    text-decoration underline

.task
  width 90%
  min-height 100px
  background hsl(50, 90%, 70%)
  margin 0.5rem auto
  position relative
  -webkit-clip-path polygon(0 0, 100% 0, 100% calc(100% - 30px), calc(100% - 30px) 100%, 0 100%)
  clip-path polygon(0 0, 100% 0, 100% calc(100% - 30px), calc(100% - 30px) 100%, 0 100%)

  &__content
    padding 2rem

  &:after
    content ''
    height 30px
    width 30px
    background linear-gradient(135deg, hsl(50, 90%, 30%) 49%, hsl(0, 0%, 98%) 50%)
    position absolute
    right 0
    bottom 0


  &__remove
    cursor pointer
    background transparent
    border 0
    opacity 0.25
    height 44px
    width 44px
    position absolute
    top 0
    right 0
    color transparent
    overflow hidden

    &:hover
      opacity 1
      transition opacity 0.2s

    svg
      position absolute
      top 50%
      left 50%
      transform translate(-50%, -50%)



              
            
!

JS

              
                let destination
const TASK_TEMPLATE = (_, ...keys) => {
  return `
    <div class="task" draggable="true" ondragstart="ON_DRAG_START(event)">
      <button class="task__remove" title="Remove task" onclick="REMOVE_TASK(event)">Remove task
        <svg viewBox="0 0 352 512" width="24" title="times">
          <path d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"></path>
        </svg>
      </button>
      <div class="task__content" contenteditable >${keys[0]}</div>
    </div>
  `
}

window.ALLOW_DROP = e => {
  e.preventDefault()
  if (e.target.className === 'column__tasks') destination = e.target
}

window.ON_DROP = e => {
  e.preventDefault()
  const TASK_ID = e.dataTransfer.getData('text')
  const TASK = document.getElementById(TASK_ID)
  TASK.querySelector('.task__content').setAttribute('contenteditable', 'true')
  if (destination) destination.appendChild(document.getElementById(TASK_ID))
}

window.ON_DRAG_START = e => {
  if (!e.target.closest) return e.preventDefault()
  const TASK = e.target.closest('.task')
  TASK.querySelector('.task__content').removeAttribute('contenteditable')
  TASK.id = new Date().toUTCString()
  e.dataTransfer.dropEffect = 'copy'
  e.dataTransfer.setDragImage(TASK, 0, 0)
  e.dataTransfer.setData('text', TASK.id)
}

window.REMOVE_TASK = e =>
  window.confirm('Remove task') && e.target.closest('.task').remove()

window.ADD_TASK = e => {
  const TASKS = e.target.closest('.column').querySelector('.column__tasks')
  const TASK = document.createElement('div')
  TASKS.appendChild(TASK)
  TASK.outerHTML = TASK_TEMPLATE`${prompt('What do you need to do?')}`
}

              
            
!
999px

Console