cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Untitled

A Pen By Captain Anonymous

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <h1>xūs todos demo</h1>

<div id="main">
  <div>
    <form onsubmit="add">
      <input type="text" id="input" />
      <input type="submit" value="Add task" />
    </form>
    <p>You have completed <b>{completedCount}</b> of your tasks. Congratulations!</p>
    <p><b>Click on more tasks to finish them!</b><p>
    <ul>
      {#todos}
      <li class="{#done}finished{/done}" onClick="toggle">{title}</li>
      {/todos}
    </ul>
   <div>
  </div>
    <p><a href="https://github.com/tetsuo/xus/blob/master/examples/demo.html">source</a></p>
    <p><a href="https://tetsuo.github.io/xus/">xūs API homepage</a></p>
    
            
          
!
            
              .finished {
  background-color: aquamarine;
}
            
          
!
            
              const types = mobxStateTree.types

const Todo = types.model("Todo", {
  title: types.string,
  done: true
}, {
  toggle() {
    this.done = !this.done
  }
})

const State = types.model("State", {
  todos: types.array(Todo),
  get completedCount() {
    return this.todos.reduce((count, todo) => (todo.done ? count + 1 : count), 0)
  }
}, {
  add(event) {
    event.preventDefault()

    const currentTarget = event.currentTarget
    const input = currentTarget.querySelector("input[type=text]")

    if (!input.value.length) {
      return
    }

    this.todos.unshift({
      title: input.value,
      done: false
    })

    input.value = ""
  }
})

const state = State.create({
  todos: [
    { title: "Get coffee", done: false },
    { title: "Wake up", done: true }
  ]
})

var targetElement = document.getElementById("main")

var options = {
  createElement: React.createElement,
  observer: mobxReact.observer
}

// ...aaand, action!
xus(targetElement.innerHTML, state, options, (er, newElement) => {
  if (er) throw er

  ReactDOM.render(newElement, targetElement)

  document.getElementById("input").focus()
})
            
          
!
999px
Loading ..................

Console