all repos — h3 @ f9bcb98e362ff4f975a5dc7adf4cef4e97ed0dbe

A tiny, extremely minimalist JavaScript microframework.

example/assets/js/components/navigationBar.js

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
import h3 from "../h3.js";
import Paginator from "./paginator.js";

export default function NavigationBar() {
  // Set the todo filter.
  const setFilter = () => {
    let f = document.getElementById("filter-text");
    h3.dispatch("todos/filter", f.value);
    h3.update()
    f = document.getElementById("filter-text");
    f.focus();
  };
  // Filtering function for todo items
  return h3("div.navigation-bar", [
    h3(
      "a.nav-link",
      {
        onclick: () => h3.go("/settings"),
      },
      "⚙"
    ),
    h3("input", {
      id: "filter-text",
      placeholder: "Type to filter todo items...",
      onkeyup: setFilter,
    }),
    Paginator,
  ]);
}