918 B · text History 7f67051
// Bundled to f/js/app.js by esbuild (see the Justfile). Importing htmx here
// registers it globally and processes hx-* attributes on load, which is what
// powers hx-boost navigation and the note status polling.
import "htmx.org";

// Small toast helper available as window.toast(msg, {kind}) for ad-hoc use.
window.toast = (msg, opts = {}) => {
  let host = document.getElementById("toast-host");
  if (!host) {
    host = document.createElement("div");
    host.id = "toast-host";
    host.className = "toast toast-end z-50";
    document.body.appendChild(host);
  }
  const alert = document.createElement("div");
  alert.className = `alert alert-${opts.kind || "info"} shadow-lg`;
  const span = document.createElement("span");
  span.textContent = msg;
  alert.appendChild(span);
  host.appendChild(alert);
  const ttl = opts.ttl ?? 4000;
  if (ttl > 0) setTimeout(() => alert.remove(), ttl);
  return alert;
};