archivo del paquete→ .shtukbase/packages/lenses/kit/templates/contour.html
kit/templates/contour.html
239 líneas, 15.0 KB.
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- <!--
- ---
- type: Lens
- title: {{title}}
- icon: {{icon}}
- description: {{description}}
- lensType: board
- render: live
- sources: {{sources}}
- generator: {{generator}}
- template: custom
- contour: {{contour}}
- data: {{data}}
- ---
- A contour board: columns are the states in order, cards are the records of the collection. A card shows the gates
- (where it can go; the condition is in the tooltip; the `needs` fields with a mark whether they are filled in)
- and how many days the record has been in this state (from git). Longer than the state norm `maxDays` - the card
- is highlighted. A cross-cutting contour (`spans`) is drawn the same way: columns are stages, cards come from several collections.
- The shell is placed by the generator from templates/contour.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>Contour</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; }
- .cx-app { display: flex; flex-direction: column; height: 100%; }
- .cx-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; flex-wrap: wrap; }
- .cx-top h1 { font-size: 20px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
- .cx-crumbs { color: var(--lx-muted); font-size: 13px; width: 100%; }
- .cx-crumbs a { text-decoration: none; } .cx-crumbs a:hover { text-decoration: underline; }
- .cx-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; }
- .cx-tools input[type=search] { font: inherit; font-size: 13px; padding: 4px 8px; border: 1px solid var(--line2); border-radius: 6px; width: 220px; background: var(--bg); color: var(--ink); }
- .cx-tools label { font-size: 13px; color: var(--lx-muted); display: flex; gap: 4px; align-items: center; cursor: pointer; }
- .cx-stats { display: flex; gap: 14px; padding: 0 16px 8px; color: var(--lx-muted); font-size: 13px; flex-wrap: wrap; }
- .cx-stats b { color: var(--ink); font-weight: 600; }
- .cx-stats .bad b { color: var(--c-red); }
- .lx-board { display: grid; grid-auto-flow: column; grid-auto-columns: 272px; gap: 10px; padding: 4px 16px 16px; overflow: auto; flex: 1 1 auto; align-items: start; }
- .lx-col { background: var(--ct, var(--ct-default)); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
- .lx-col .ch { display: flex; align-items: center; gap: 6px; padding: 2px 2px 0; font-weight: 500; min-height: 24px; }
- .lx-col .ch .n { color: var(--lx-muted); font-weight: 400; font-size: 13px; }
- .lx-col .ch .norm { margin-left: auto; color: var(--lx-muted); font-size: 12px; font-weight: 400; }
- .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)); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
- .cx-chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cc, var(--c-default)); flex-shrink: 0; }
- .cx-chip.sq { border-radius: 4px; padding: 0 6px; }
- .cx-gates { font-size: 12px; color: var(--lx-muted); padding: 0 4px; }
- .cx-gates summary { cursor: pointer; list-style: none; } .cx-gates summary::-webkit-details-marker { display: none; }
- .cx-gates summary::before { content: "▸ "; } .cx-gates[open] summary::before { content: "▾ "; }
- .cx-gates li { margin: 3px 0; } .cx-gates ul { margin: 4px 0 2px; padding-left: 14px; }
- .cx-inc { font-size: 12px; color: var(--lx-muted); padding: 0 4px; display: flex; flex-wrap: wrap; gap: 4px; }
- .lx-card { display: block; position: relative; background: var(--lx-card); border-radius: var(--lx-radius); padding: 7px 9px; box-shadow: var(--shadow); cursor: pointer; text-decoration: none; color: var(--ink); min-width: 0; }
- .lx-card:hover { background: color-mix(in srgb, var(--lx-card) 94%, var(--ink)); }
- .lx-card .ttl { font-weight: 500; font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }
- .lx-card .ft { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
- .lx-card .age { margin-left: auto; font-size: 12px; color: var(--lx-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
- .lx-card.stuck { box-shadow: 0 0 0 1.5px var(--c-red), var(--shadow); background: var(--ct-red); }
- .lx-card.stuck .age { color: var(--c-red); font-weight: 600; }
- .cx-need { font-size: 11px; padding: 0 5px; border-radius: 4px; line-height: 18px; background: var(--cb-default); color: var(--cf-default); font-family: ui-monospace, Menlo, monospace; }
- .cx-need.ok { background: var(--cb-green); color: var(--cf-green); }
- .cx-need.no { background: var(--cb-orange); color: var(--cf-orange); }
- .cx-to { font-size: 11px; color: var(--lx-muted); white-space: nowrap; }
- .cx-more { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--lx-muted); cursor: pointer; padding: 4px; text-align: left; }
- .cx-more:hover { color: var(--ink); }
- .cx-empty { color: var(--faint); font-size: 12.5px; padding: 6px 4px; }
- .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; }
- .cx-hide { display: none !important; }
- </style>
- <script>window.LENS_MANUAL = true;</script>
- <script src="{{lib}}/data.js"></script>
- <script src="{{lib}}/kit.js"></script>
- <script src="{{libLayer}}/contours.data.js"></script>
- </head>
- <body>
- <div class="cx-app" id="app"></div>
- <script>
- (function () {
- "use strict";
- const ROOT = "../../"; // the root of the base from /<layer>/contours/<type>.html
- const app = document.getElementById("app");
- const head = (function () { // the lens header: the first comment
- const w = document.createTreeWalker(document, NodeFilter.SHOW_COMMENT);
- const c = w.nextNode();
- return c ? c.data : "";
- })();
- const field = (k) => { const m = new RegExp("^" + k + ":\\s*\"?([^\"\\n]*)\"?\\s*$", "m").exec(head); return m ? m[1].trim() : ""; };
- const CID = field("contour");
- const L = (window.SHTUKS_LAYER || {}).contours;
- const C = L && L.contours && L.contours[CID];
- 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});--ct:var(--ct-${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 if (k === "style") e.setAttribute("style", 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);
- function recLink(id, cls, kids) {
- return h("a", { class: cls, href: ROOT + encodeURI(id.replace(/^\//, "")), "data-id": id, onclick: (e) => {
- if (hasKit() && window.SHTUKS.records[id] && !e.metaKey && !e.ctrlKey) { e.preventDefault(); Lens.open(id); }
- } }, kids);
- }
- const days = (since) => (since ? Math.floor((Date.now() / 1000 - since) / 86400) : null);
- const plural = (n, a, b) => (n === 1 ? a : b);
- const dd = (n) => n + " " + plural(n, "day", "days");
- if (!C) {
- document.title = "Contour - no data";
- app.append(h("div", { class: "cx-missing" }, h("h2", {}, "No contour data"),
- h("p", {}, "The lens reads ", h("code", {}, "lib/<layer>/contours.data.js"), "; it has no contour ", h("code", {}, CID || "(the contour field is empty)"), "."),
- h("p", {}, "Build the data: ", h("code", {}, field("generator") || "build_contour_data.py"))));
- return;
- }
- document.title = C.title + " - contour";
- const layerHref = "../overview.html";
- const top = h("div", { class: "cx-top" },
- h("div", { class: "cx-crumbs" }, h("a", { href: layerHref }, "Layer " + C.layer), " · Contours · ",
- recLink(C.id, "", C.id)),
- h("h1", {}, h("span", {}, C.icon || "🔁"), C.title, C.cross ? h("span", { class: "cx-chip sq", style: tone("purple") }, "cross-cutting") : null));
- const q = h("input", { type: "search", placeholder: "Find a card...", "aria-label": "Find a card" });
- const onlyStuck = h("input", { type: "checkbox" });
- top.append(h("div", { class: "cx-tools" }, q, h("label", {}, onlyStuck, "only stuck ones")));
- const stats = h("div", { class: "cx-stats" });
- const board = h("div", { class: "lx-board" });
- app.append(top, stats, board);
- const cols = C.columns.map((c) => ({ ...c, cards: [] }));
- for (const card of C.cards) if (cols[card.col]) cols[card.col].cards.push(card);
- let stuckTotal = 0;
- for (const col of cols) {
- for (const c of col.cards) {
- c.days = days(c.since);
- c.stuck = col.maxDays != null && c.days != null && c.days > col.maxDays;
- if (c.stuck) stuckTotal++;
- }
- col.cards.sort((a, b) => (b.stuck - a.stuck) || ((b.days ?? -1) - (a.days ?? -1)));
- }
- const S = (k, v, cls) => h("span", { class: cls || "" }, k + " ", h("b", {}, v));
- stats.append(S("Cards", C.cards.length), S(C.cross ? "Stages" : "States", C.columns.length),
- S("Over the norm", stuckTotal, stuckTotal ? "bad" : ""),
- C.collections.length > 1 || C.cross ? h("span", {}, "Collections: ", C.collections.map((x, i) => [i ? ", " : "", recLink(x.id, "", x.title)])) :
- C.collections[0] ? h("span", {}, "Collection ", recLink(C.collections[0].id, "", C.collections[0].title)) : null);
- function cardEl(c, col) {
- const ft = h("div", { class: "ft" });
- if (c.state) ft.append(h("span", { class: "cx-chip dot", style: tone(c.state.color), title: c.state.contour }, c.state.title));
- if (c.value) ft.append(h("span", { class: "cx-chip sq", title: "the field value is not from the contour" }, c.value));
- for (const g of col.gates || []) {
- const t = "→ " + g.title + (g.cond ? ": " + g.cond : "") + (g.needs ? " (needs: " + g.needs.join(", ") + ")" : "") + (g.gate ? " · decides: " + g.gate : "");
- ft.append(h("span", { class: "cx-to", title: t }, "→ " + g.title));
- for (const n of g.needs || []) {
- const ok = c.has && c.has[n];
- ft.append(h("span", { class: "cx-need " + (ok ? "ok" : "no"), title: (ok ? "filled in: " : "not filled in: ") + n }, (ok ? "✓ " : "✗ ") + n));
- }
- }
- const age = c.days == null ? "—" : c.days === 0 ? "today" : dd(c.days);
- ft.append(h("span", { class: "age", title: c.since ? "in the state since " + new Date(c.since * 1000).toLocaleDateString("en-US") + (col.maxDays != null ? ", norm " + dd(col.maxDays) : "") : "the date is unknown: the record is not in git" }, age));
- const a = recLink(c.id, "lx-card" + (c.stuck ? " stuck" : ""), [h("div", { class: "ttl" }, c.icon ? c.icon + " " : "", c.title), ft]);
- a.dataset.text = (c.title + " " + c.id).toLowerCase();
- a.dataset.stuck = c.stuck ? "1" : "";
- return a;
- }
- const PAGE = 60;
- for (const col of cols) {
- const el = h("div", { class: "lx-col", style: tone(col.color) });
- el.append(h("div", { class: "ch" }, h("span", { class: "cx-chip dot", style: tone(col.color) }, col.title),
- h("span", { class: "n" }, col.cards.length),
- col.maxDays != null ? h("span", { class: "norm", title: "maxDays of the state" }, "norm " + dd(col.maxDays)) : null));
- if (col.includes && col.includes.length)
- el.append(h("div", { class: "cx-inc" }, col.includes.map((x) => h("span", { class: "cx-chip dot", style: tone(x.color), title: x.contour }, x.title))));
- if (col.gates && col.gates.length)
- el.append(h("details", { class: "cx-gates" }, h("summary", {}, "Gates · " + col.gates.length),
- h("ul", {}, col.gates.map((g) => h("li", {}, h("b", {}, "→ " + g.title), g.cond ? " — " + g.cond : "",
- g.needs ? h("span", {}, " · needs: ", g.needs.join(", ")) : null, g.gate ? " · decides: " + g.gate : "")))));
- const list = h("div", { style: "display:flex;flex-direction:column;gap:6px" });
- let shown = 0;
- const more = h("button", { class: "cx-more", onclick: () => page() });
- function page() {
- const next = col.cards.slice(shown, shown + (shown ? 200 : PAGE));
- next.forEach((c) => list.append(cardEl(c, col)));
- shown += next.length;
- more.textContent = "Show " + (col.cards.length - shown) + " more";
- more.classList.toggle("cx-hide", shown >= col.cards.length);
- filter();
- }
- el.append(list, more);
- if (!col.cards.length) el.append(h("div", { class: "cx-empty" }, "Empty"));
- board.append(el);
- col.page = page;
- col.list = list;
- }
- function filter() {
- const s = q.value.trim().toLowerCase();
- const st = onlyStuck.checked;
- board.querySelectorAll(".lx-card").forEach((a) => {
- a.classList.toggle("cx-hide", (s && !a.dataset.text.includes(s)) || (st && !a.dataset.stuck));
- });
- }
- cols.forEach((c) => c.page());
- // the search and "only stuck ones" look at all cards: we load the columns whole
- const all = () => cols.forEach((c) => { while (c.cards.length > c.list.childElementCount) c.page(); });
- q.addEventListener("input", () => { if (q.value) all(); filter(); });
- onlyStuck.addEventListener("change", () => { if (onlyStuck.checked) all(); filter(); });
- const id = decodeURI(location.hash.slice(1));
- if (id && hasKit() && window.SHTUKS.records[id]) Lens.open(id);
- })();
- </script>
- </body>
- </html>