файл пакета→ .shtukbase/packages/lenses/kit/kit/templates/gallery.js
kit/kit/templates/gallery.js
28 строк, 1.7 КБ.
Файл как есть в пакете: код и комментарии в нём не переводятся.
- /* The "gallery" template: all lenses of the base, by layer. This is the start page lib/index.html. */
- (function () {
- const { h } = Lens;
- Lens.templates.gallery = function (cfg) {
- const D = Lens.data;
- const ui = Lens.page({ ...cfg, title: "Lenses", icon: "🔭", description: `The base "${D.base}": different views of the same records`, search: false });
- const total = Object.keys(D.records).length;
- ui.showBar().append(...Lens.stats([["Records in the base", total], ["Lenses", D.lenses.length]]));
- const byLayer = new Map();
- for (const l of D.lenses) {
- const k = l.layer || "";
- if (!byLayer.has(k)) byLayer.set(k, []);
- byLayer.get(k).push(l);
- }
- ui.main.append(h("div", { class: "lx-gallery-wrap" }, [...byLayer].map(([layer, list]) => {
- const lr = Lens.rec("/" + layer + ".md");
- return h("section", { class: "lx-gallery-layer" },
- h("h2", {}, lr ? Lens.icon(lr) : null, lr ? lr.title : layer || "Base root", h("span", { class: "n" }, list.length)),
- h("div", { class: "lx-gallery" }, list.map((l) =>
- h("a", { class: "lx-card", href: Lens.rootHref + l.path.slice(1).split("/").map(encodeURIComponent).join("/") },
- h("div", { class: "big" }, Lens.glyph(l.icon || "🔭", l.path)),
- h("div", { class: "ttl" }, l.title),
- h("div", { class: "sub" }, l.description || ""),
- h("div", { class: "chips" }, Lens.chip(TEMPLATES[l.template] || l.template || "custom layout", "gray"), Lens.chip(l.path, "default"))))));
- })));
- };
- const TEMPLATES = { canvas: "canvas", types: "ontology", nest: "nesting", board: "board", lanes: "lanes", custom: "custom layout" };
- })();