Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/luwes/sinuous-todomvc

TodoMVC implemented in Sinuous ~ 2.9kB gzip
https://github.com/luwes/sinuous-todomvc

sinuous todomvc

Last synced: 14 days ago
JSON representation

TodoMVC implemented in Sinuous ~ 2.9kB gzip

Awesome Lists containing this project

README

        

# Sinuous TodoMVC

[Sinuous](https://github.com/luwes/sinuous/) implementation of the [TodoMVC](http://todomvc.com/) example application.
[luwes.github.io/sinuous-todomvc](https://luwes.github.io/sinuous-todomvc).

The entire app weighs 2.9kb gzip.

```js
import { h } from 'sinuous';
import { map } from 'sinuous/map';
import { addTodo, clearCompleted, completed, displayed, doneEditing, editing,
filter, remaining, remove, save, todos, toggle, toggleAll } from './controller.js';
import { cx, focus } from './utils.js';

const TodoApp = () => html`

todos



!todos().length}>
!remaining().length}
/>
Mark all as complete


    ${map(displayed, ({ id, title, completed }) => html`
  • cx({ completed: completed(), editing: editing() === id })}>

    toggle(e, id)}
    />
    editing(id)}>${title}
    remove(id)}>

    ${() => editing() === id && focus(html`
    save(e, id)}
    onkeyup=${e => doneEditing(e, id)}
    />`)
    }

  • `)}



${() => remaining().length}
${() => remaining().length === 1 ? ' item' : ' items'} left


${() => completed().length > 0 && html`

Clear completed

`}


`;

const updateView = () => filter(location.hash.slice(2) || 'all');
window.addEventListener('hashchange', updateView);
updateView();

document.querySelector('.todoapp').append(TodoApp());
```