ShtukbaseStandard
файл пакета→ .shtukbase/packages/lenses/kit/kit/templates/gallery.js

kit/kit/templates/gallery.js

28 строк, 1.7 КБ.

Файл как есть в пакете: код и комментарии в нём не переводятся.

  1. /* The "gallery" template: all lenses of the base, by layer. This is the start page lib/index.html. */
  2. (function () {
  3. const { h } = Lens;
  4. Lens.templates.gallery = function (cfg) {
  5. const D = Lens.data;
  6. const ui = Lens.page({ ...cfg, title: "Lenses", icon: "🔭", description: `The base "${D.base}": different views of the same records`, search: false });
  7. const total = Object.keys(D.records).length;
  8. ui.showBar().append(...Lens.stats([["Records in the base", total], ["Lenses", D.lenses.length]]));
  9. const byLayer = new Map();
  10. for (const l of D.lenses) {
  11. const k = l.layer || "";
  12. if (!byLayer.has(k)) byLayer.set(k, []);
  13. byLayer.get(k).push(l);
  14. }
  15. ui.main.append(h("div", { class: "lx-gallery-wrap" }, [...byLayer].map(([layer, list]) => {
  16. const lr = Lens.rec("/" + layer + ".md");
  17. return h("section", { class: "lx-gallery-layer" },
  18. h("h2", {}, lr ? Lens.icon(lr) : null, lr ? lr.title : layer || "Base root", h("span", { class: "n" }, list.length)),
  19. h("div", { class: "lx-gallery" }, list.map((l) =>
  20. h("a", { class: "lx-card", href: Lens.rootHref + l.path.slice(1).split("/").map(encodeURIComponent).join("/") },
  21. h("div", { class: "big" }, Lens.glyph(l.icon || "🔭", l.path)),
  22. h("div", { class: "ttl" }, l.title),
  23. h("div", { class: "sub" }, l.description || ""),
  24. h("div", { class: "chips" }, Lens.chip(TEMPLATES[l.template] || l.template || "custom layout", "gray"), Lens.chip(l.path, "default"))))));
  25. })));
  26. };
  27. const TEMPLATES = { canvas: "canvas", types: "ontology", nest: "nesting", board: "board", lanes: "lanes", custom: "custom layout" };
  28. })();