all repos — h3 @ ba38ad5b41611b5e2ca05614a0acecfca29350f3

A tiny, extremely minimalist JavaScript microframework.

example/assets/js/components/SettingsView.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
 30
 31
 32
 33
 34
 35
 36
import h3 from "../h3.js";

export default function () {
  const toggleLogging = () => {
    const value = document.getElementById("options-logging").checked;
    h3.dispatch("settings/set", { logging: value });
    h3.dispatch("app/save");
  };
  const attrs = {
    type: "checkbox",
    onclick: toggleLogging,
  };
  if (h3.state("settings").logging) {
    attrs.checked = true;
  }
  return h3("div.settings.container", [
    h3("h1", "Settings"),
    h3("div.options", [
      h3("input#options-logging", attrs),
      h3(
        "label#options-logging-label",
        {
          for: "logging",
        },
        "Logging"
      ),
    ]),
    h3(
      "a.nav-link",
      {
        onclick: () => h3.go("/"),
      },
      "← Go Back"
    )
  ]);
}