all repos — h3 @ 20714f0f648708b5c63579804f9db0957a8ab7ff

A tiny, extremely minimalist JavaScript microframework.

example/assets/js/components/todo.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
import h3 from "../h3.js";

export default function Todo(data) {
  const todoStateClass = data.done ? ".done" : ".todo";
  const toggleTodo = (todo) => {
    h3.dispatch("todos/toggle", data);
    h3.redraw()
  };
  const removeTodo = (todo) => {
    h3.dispatch("todos/remove", data);
    h3.redraw()
  };
  return h3(`div.todo-item`, {key: data.key}, [
    h3(`div.todo-content${todoStateClass}`, [
      h3("span.todo-text", { onclick: () => toggleTodo(data) }, data.text),
    ]),
    h3("span.delete-todo", { onclick: () => removeTodo(data) }, "✘"),
  ]);
}