package file→ .shtukbase/packages/lenses/kit/templates/overview.html
kit/templates/overview.html
181 lines, 12.0 KB.
- <!--
- ---
- type: Lens
- title: {{title}}
- icon: {{icon}}
- description: {{description}}
- lensType: report
- render: live
- sources: {{sources}}
- generator: {{generator}}
- template: custom
- layer: {{layer}}
- data: {{data}}
- ---
- A layer overview from one template: how many records are in each collection, how many in each state
- of the layer's contours, what is stuck longer than the norm `maxDays`, open questions and the owner's gates for the layer.
- The shell is placed by the generator from templates/overview.html of the shtukbase-html-lenses kit; do not edit by hand.
- -->
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Layer overview</title>
- <link rel="stylesheet" href="{{lib}}/kit.css">
- <style>
- :root {
- --bg: #ffffff; --bg2: #f9f8f7; --lx-card: #ffffff; --ink: #2c2c2b; --lx-muted: #7d7a75; --faint: #a19e99;
- --line: #e6e5e3; --line2: #d4d3cf; --wash: rgba(33,27,23,.05); --lx-accent: #2783de; --lx-radius: 8px;
- --shadow: 0 0 0 1px rgba(15,15,15,.07), 0 1px 2px rgba(15,15,15,.06);
- --c-default: #8e8b87; --cb-default: rgba(42,28,0,.07); --cf-default: #494846; --ct-default: #f9f8f8;
- --c-gray: #8e8b87; --cb-gray: rgba(28,19,1,.11); --cf-gray: #494846; --ct-gray: #f2f2f1;
- --c-brown: #9f6b53; --cb-brown: rgba(127,51,0,.157); --cf-brown: #584437; --ct-brown: #f7f1ee;
- --c-orange: #d9730d; --cb-orange: rgba(196,88,0,.204); --cf-orange: #6a4222; --ct-orange: #fdf0e7;
- --c-yellow: #cb912f; --cb-yellow: rgba(209,156,0,.282); --cf-yellow: #655121; --ct-yellow: #fef6e6;
- --c-green: #448361; --cb-green: rgba(0,96,38,.157); --cf-green: #2a533c; --ct-green: #eff7ef;
- --c-blue: #337ea9; --cb-blue: rgba(0,118,217,.204); --cf-blue: #264a72; --ct-blue: #ebf3f8;
- --c-purple: #9065b0; --cb-purple: rgba(92,0,163,.14); --cf-purple: #553b69; --ct-purple: #f5f0f7;
- --c-pink: #c14c8a; --cb-pink: rgba(183,0,78,.153); --cf-pink: #68354e; --ct-pink: #fbf1f5;
- --c-red: #d44c47; --cb-red: rgba(206,24,0,.165); --cf-red: #6d3531; --ct-red: #fff2f0;
- --c-teal: #2b8a85; --cb-teal: rgba(0,128,120,.15); --cf-teal: #22524f; --ct-teal: #ecf6f5;
- font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
- }
- * { box-sizing: border-box; }
- html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
- body { font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
- a { color: inherit; }
- * { box-sizing: border-box; }
- html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
- body { font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
- a { color: inherit; }
- .ov { max-width: 1180px; margin: 0 auto; padding: 18px 24px 40px; }
- .ov h1 { font-size: 26px; font-weight: 700; margin: 4px 0 2px; display: flex; gap: 10px; align-items: center; }
- .ov .sub { color: var(--lx-muted); font-size: 13px; display: flex; gap: 14px; flex-wrap: wrap; }
- .ov .sub a { color: var(--lx-accent); text-decoration: none; } .ov .sub a:hover { text-decoration: underline; }
- .ov h2 { font-size: 15px; font-weight: 600; margin: 26px 0 10px; display: flex; gap: 8px; align-items: baseline; }
- .ov h2 .n { color: var(--lx-muted); font-weight: 400; }
- .tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
- .tile { display: block; background: var(--lx-card); border-radius: var(--lx-radius); box-shadow: var(--shadow); padding: 9px 11px; text-decoration: none; }
- .tile:hover { background: color-mix(in srgb, var(--lx-card) 94%, var(--ink)); }
- .tile .t { font-size: 13px; color: var(--lx-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
- .tile .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
- .ctr { display: grid; grid-template-columns: minmax(220px, 280px) 60px 1fr; gap: 6px 14px; align-items: center; }
- .ctr .nm a { text-decoration: none; font-weight: 500; } .ctr .nm a:hover { text-decoration: underline; }
- .ctr .tot { text-align: right; color: var(--lx-muted); font-variant-numeric: tabular-nums; }
- .bar { display: flex; height: 22px; border-radius: 5px; overflow: hidden; background: var(--bg2); }
- .bar span { background: var(--cc, var(--c-default)); min-width: 3px; }
- .legend { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; color: var(--lx-muted); grid-column: 3; margin: -2px 0 8px; }
- .legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--cc); margin-right: 4px; }
- .legend b { color: var(--ink); font-weight: 500; }
- .legend .over { color: var(--c-red); }
- .list { display: flex; flex-direction: column; gap: 4px; }
- .row { display: flex; gap: 8px; align-items: center; background: var(--lx-card); box-shadow: var(--shadow); border-radius: var(--lx-radius); padding: 6px 10px; text-decoration: none; }
- .row:hover { background: color-mix(in srgb, var(--lx-card) 94%, var(--ink)); }
- .row .t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
- .row .m { color: var(--lx-muted); font-size: 12px; white-space: nowrap; }
- .row.stuck .m.age { color: var(--c-red); font-weight: 600; }
- .cx-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; line-height: 20px; height: 20px; padding: 0 7px; border-radius: 10px; white-space: nowrap;
- background: var(--cb, var(--cb-default)); color: var(--cf, var(--cf-default)); flex-shrink: 0; }
- .cx-chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cc, var(--c-default)); }
- .cols2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; }
- .cols2 > div { min-width: 0; }
- @media (max-width: 900px) { .cols2 { grid-template-columns: minmax(0, 1fr); } .ctr { grid-template-columns: 1fr 50px; } .ctr .bar, .legend { grid-column: 1 / -1; } }
- .empty { color: var(--faint); font-size: 13px; }
- .cx-missing { padding: 24px; color: var(--lx-muted); max-width: 640px; }
- .cx-missing code { background: var(--bg2); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
- </style>
- <script>window.LENS_MANUAL = true;</script>
- <script src="{{lib}}/data.js"></script>
- <script src="{{lib}}/kit.js"></script>
- <script src="{{libLayer}}/overview.data.js"></script>
- </head>
- <body>
- <div class="ov" id="app"></div>
- <script>
- (function () {
- "use strict";
- const ROOT = "../"; // the root of the base from /<layer>/overview.html
- const app = document.getElementById("app");
- const O = (window.SHTUKS_LAYER || {}).overview;
- const COLORS = ["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "teal"];
- const tone = (c) => { c = COLORS.includes(c) ? c : "default"; return `--cc:var(--c-${c});--cb:var(--cb-${c});--cf:var(--cf-${c})`; };
- function h(tag, attrs, ...kids) {
- const e = document.createElement(tag);
- for (const [k, v] of Object.entries(attrs || {})) {
- if (v == null || v === false) continue;
- if (k.startsWith("on")) e.addEventListener(k.slice(2), v);
- else e.setAttribute(k, v === true ? "" : v);
- }
- for (const k of kids.flat(Infinity)) if (k != null && k !== false) e.append(k.nodeType ? k : String(k));
- return e;
- }
- const hasKit = () => !!(window.SHTUKS && window.Lens && Lens.open);
- const recLink = (id, cls, kids) => h("a", { class: cls, href: ROOT + encodeURI(id.replace(/^\//, "")), onclick: (e) => {
- if (hasKit() && window.SHTUKS.records[id] && !e.metaKey && !e.ctrlKey) { e.preventDefault(); Lens.open(id); }
- } }, kids);
- const plural = (n, a, b) => (n === 1 ? a : b);
- const IMPORTANCE = { critical: "important", normal: "medium", minor: "minor" }; // captions from the Questions schema
- const dd = (n) => n + " " + plural(n, "day", "days");
- if (!O) {
- app.append(h("div", { class: "cx-missing" }, h("h2", {}, "No overview data"),
- h("p", {}, "The lens reads ", h("code", {}, "lib/<layer>/overview.data.js"), ". Build it: ", h("code", {}, "build_overview_data.py --layer <layer>"))));
- return;
- }
- document.title = "Layer overview \"" + O.title + "\"";
- const now = Date.now() / 1000;
- const stuck = [];
- for (const c of O.contours) for (const s of c.stuck) {
- const d = Math.floor((now - s.since) / 86400);
- if (d > s.maxDays) stuck.push({ ...s, days: d, contour: c.title });
- }
- stuck.sort((a, b) => b.days - b.maxDays - (a.days - a.maxDays));
- const total = O.collections.reduce((a, c) => a + c.count, 0);
- const sub = h("div", { class: "sub" },
- h("span", {}, "Records: ", h("b", {}, total)), h("span", {}, "Contours: ", h("b", {}, O.contours.length)),
- h("span", {}, "Stuck: ", h("b", {}, stuck.length)), h("span", {}, "Open questions: ", h("b", {}, O.questions.length)),
- h("span", {}, "Owner gates: ", h("b", {}, O.gates.length)),
- O.ontology ? h("a", { href: O.ontology }, "Layer links →") : null,
- h("a", { href: ROOT + encodeURI(O.layer) + ".md" }, "Layer page →"));
- app.append(h("h1", {}, h("span", {}, O.icon || "🧭"), O.title), sub);
- app.append(h("h2", {}, "Collections", h("span", { class: "n" }, O.collections.length)),
- h("div", { class: "tiles" }, O.collections.map((c) => recLink(c.id, "tile", [h("div", { class: "t", title: c.id }, (c.icon ? c.icon + " " : "") + c.title), h("div", { class: "v" }, c.count)]))));
- const ctr = h("div", { class: "ctr" });
- for (const c of O.contours) {
- const bar = h("div", { class: "bar" });
- const legend = h("div", { class: "legend" });
- const over = {};
- for (const s of stuck) if (s.contour === c.title) over[s.state] = (over[s.state] || 0) + 1;
- for (const s of c.states) {
- if (s.count) bar.append(h("span", { style: tone(s.color) + ";flex:" + s.count, title: s.title + ": " + s.count }));
- legend.append(h("span", { style: tone(s.color) }, h("i", {}), s.title + " ", h("b", {}, s.count),
- s.maxDays != null ? " · norm " + dd(s.maxDays) : "", over[s.title] ? h("span", { class: "over" }, " · over the norm " + over[s.title]) : ""));
- }
- ctr.append(h("div", { class: "nm" }, h("a", { href: c.lens }, (c.icon || "🔁") + " " + c.title), c.cross ? " (cross-cutting)" : ""),
- h("div", { class: "tot" }, c.total), bar, h("div"), h("div"), legend);
- }
- app.append(h("h2", {}, "Contours", h("span", { class: "n" }, O.contours.length)), O.contours.length ? ctr : h("div", { class: "empty" }, "No contours"));
- app.append(h("h2", {}, "Stuck longer than the norm", h("span", { class: "n" }, stuck.length)),
- stuck.length ? h("div", { class: "list" }, stuck.map((s) => recLink(s.id, "row stuck", [
- h("span", { class: "cx-chip dot", style: tone(s.color) }, s.state), h("span", { class: "t" }, s.title),
- h("span", { class: "m" }, s.contour), h("span", { class: "m age" }, dd(s.days) + " / norm " + s.maxDays)])))
- : h("div", { class: "empty" }, O.contours.some((c) => c.states.some((s) => s.maxDays != null)) ? "Nothing is stuck." : "The states of the layer have no maxDays norms, so being stuck is not counted."));
- const qList = O.questions.map((q) => recLink(q.id, "row", [h("span", { class: "cx-chip dot", style: tone(q.color) }, q.status),
- h("span", { class: "t", title: q.title }, q.title),
- q.importance ? h("span", { class: "m" }, IMPORTANCE[q.importance] || q.importance) : null, q.due ? h("span", { class: "m" }, "by " + q.due) : null]));
- const gList = O.gates.map((g) => recLink(g.id, "row", [h("span", { class: "cx-chip dot", style: tone(g.color) }, g.status),
- h("span", { class: "t", title: g.title }, g.title),
- g.priority ? h("span", { class: "m" }, g.priority) : null, g.who ? h("span", { class: "m" }, g.who) : null, g.due ? h("span", { class: "m" }, "until " + g.due) : null]));
- app.append(h("div", { class: "cols2" },
- h("div", {}, h("h2", {}, "Open questions", h("span", { class: "n" }, qList.length)), qList.length ? h("div", { class: "list" }, qList) : h("div", { class: "empty" }, "The layer has no open questions.")),
- h("div", {}, h("h2", {}, "Owner gates", h("span", { class: "n" }, gList.length)), gList.length ? h("div", { class: "list" }, gList) : h("div", { class: "empty" }, "The layer has no owner tasks."))));
- const id = decodeURI(location.hash.slice(1));
- if (id && hasKit() && window.SHTUKS.records[id]) Lens.open(id);
- })();
- </script>
- </body>
- </html>