ShtukbaseStandard
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.

  1. <!--
  2. ---
  3. type: Lens
  4. title: {{title}}
  5. icon: {{icon}}
  6. description: {{description}}
  7. lensType: board
  8. render: live
  9. sources: {{sources}}
  10. generator: {{generator}}
  11. template: custom
  12. contour: {{contour}}
  13. data: {{data}}
  14. ---
  15. A contour board: columns are the states in order, cards are the records of the collection. A card shows the gates
  16. (where it can go; the condition is in the tooltip; the `needs` fields with a mark whether they are filled in)
  17. and how many days the record has been in this state (from git). Longer than the state norm `maxDays` - the card
  18. is highlighted. A cross-cutting contour (`spans`) is drawn the same way: columns are stages, cards come from several collections.
  19. The shell is placed by the generator from templates/contour.html of the shtukbase-html-lenses kit; do not edit by hand.
  20. -->
  21. <!doctype html>
  22. <html lang="en">
  23. <head>
  24. <meta charset="utf-8">
  25. <meta name="viewport" content="width=device-width, initial-scale=1">
  26. <title>Contour</title>
  27. <link rel="stylesheet" href="{{lib}}/kit.css">
  28. <style>
  29. :root {
  30. --bg: #ffffff; --bg2: #f9f8f7; --lx-card: #ffffff; --ink: #2c2c2b; --lx-muted: #7d7a75; --faint: #a19e99;
  31. --line: #e6e5e3; --line2: #d4d3cf; --wash: rgba(33,27,23,.05); --lx-accent: #2783de; --lx-radius: 8px;
  32. --shadow: 0 0 0 1px rgba(15,15,15,.07), 0 1px 2px rgba(15,15,15,.06);
  33. --c-default: #8e8b87; --cb-default: rgba(42,28,0,.07); --cf-default: #494846; --ct-default: #f9f8f8;
  34. --c-gray: #8e8b87; --cb-gray: rgba(28,19,1,.11); --cf-gray: #494846; --ct-gray: #f2f2f1;
  35. --c-brown: #9f6b53; --cb-brown: rgba(127,51,0,.157); --cf-brown: #584437; --ct-brown: #f7f1ee;
  36. --c-orange: #d9730d; --cb-orange: rgba(196,88,0,.204); --cf-orange: #6a4222; --ct-orange: #fdf0e7;
  37. --c-yellow: #cb912f; --cb-yellow: rgba(209,156,0,.282); --cf-yellow: #655121; --ct-yellow: #fef6e6;
  38. --c-green: #448361; --cb-green: rgba(0,96,38,.157); --cf-green: #2a533c; --ct-green: #eff7ef;
  39. --c-blue: #337ea9; --cb-blue: rgba(0,118,217,.204); --cf-blue: #264a72; --ct-blue: #ebf3f8;
  40. --c-purple: #9065b0; --cb-purple: rgba(92,0,163,.14); --cf-purple: #553b69; --ct-purple: #f5f0f7;
  41. --c-pink: #c14c8a; --cb-pink: rgba(183,0,78,.153); --cf-pink: #68354e; --ct-pink: #fbf1f5;
  42. --c-red: #d44c47; --cb-red: rgba(206,24,0,.165); --cf-red: #6d3531; --ct-red: #fff2f0;
  43. --c-teal: #2b8a85; --cb-teal: rgba(0,128,120,.15); --cf-teal: #22524f; --ct-teal: #ecf6f5;
  44. font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  45. }
  46. * { box-sizing: border-box; }
  47. html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
  48. body { font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
  49. a { color: inherit; }
  50. .cx-app { display: flex; flex-direction: column; height: 100%; }
  51. .cx-top { display: flex; align-items: center; gap: 10px; padding: 10px 16px 6px; flex-wrap: wrap; }
  52. .cx-top h1 { font-size: 20px; font-weight: 600; margin: 0; display: flex; align-items: center; gap: 8px; }
  53. .cx-crumbs { color: var(--lx-muted); font-size: 13px; width: 100%; }
  54. .cx-crumbs a { text-decoration: none; } .cx-crumbs a:hover { text-decoration: underline; }
  55. .cx-tools { display: flex; gap: 8px; align-items: center; margin-left: auto; }
  56. .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); }
  57. .cx-tools label { font-size: 13px; color: var(--lx-muted); display: flex; gap: 4px; align-items: center; cursor: pointer; }
  58. .cx-stats { display: flex; gap: 14px; padding: 0 16px 8px; color: var(--lx-muted); font-size: 13px; flex-wrap: wrap; }
  59. .cx-stats b { color: var(--ink); font-weight: 600; }
  60. .cx-stats .bad b { color: var(--c-red); }
  61. .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; }
  62. .lx-col { background: var(--ct, var(--ct-default)); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
  63. .lx-col .ch { display: flex; align-items: center; gap: 6px; padding: 2px 2px 0; font-weight: 500; min-height: 24px; }
  64. .lx-col .ch .n { color: var(--lx-muted); font-weight: 400; font-size: 13px; }
  65. .lx-col .ch .norm { margin-left: auto; color: var(--lx-muted); font-size: 12px; font-weight: 400; }
  66. .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;
  67. background: var(--cb, var(--cb-default)); color: var(--cf, var(--cf-default)); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  68. .cx-chip.dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--cc, var(--c-default)); flex-shrink: 0; }
  69. .cx-chip.sq { border-radius: 4px; padding: 0 6px; }
  70. .cx-gates { font-size: 12px; color: var(--lx-muted); padding: 0 4px; }
  71. .cx-gates summary { cursor: pointer; list-style: none; } .cx-gates summary::-webkit-details-marker { display: none; }
  72. .cx-gates summary::before { content: "▸ "; } .cx-gates[open] summary::before { content: "▾ "; }
  73. .cx-gates li { margin: 3px 0; } .cx-gates ul { margin: 4px 0 2px; padding-left: 14px; }
  74. .cx-inc { font-size: 12px; color: var(--lx-muted); padding: 0 4px; display: flex; flex-wrap: wrap; gap: 4px; }
  75. .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; }
  76. .lx-card:hover { background: color-mix(in srgb, var(--lx-card) 94%, var(--ink)); }
  77. .lx-card .ttl { font-weight: 500; font-size: 13.5px; line-height: 1.35; overflow-wrap: anywhere; }
  78. .lx-card .ft { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; align-items: center; }
  79. .lx-card .age { margin-left: auto; font-size: 12px; color: var(--lx-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
  80. .lx-card.stuck { box-shadow: 0 0 0 1.5px var(--c-red), var(--shadow); background: var(--ct-red); }
  81. .lx-card.stuck .age { color: var(--c-red); font-weight: 600; }
  82. .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; }
  83. .cx-need.ok { background: var(--cb-green); color: var(--cf-green); }
  84. .cx-need.no { background: var(--cb-orange); color: var(--cf-orange); }
  85. .cx-to { font-size: 11px; color: var(--lx-muted); white-space: nowrap; }
  86. .cx-more { font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--lx-muted); cursor: pointer; padding: 4px; text-align: left; }
  87. .cx-more:hover { color: var(--ink); }
  88. .cx-empty { color: var(--faint); font-size: 12.5px; padding: 6px 4px; }
  89. .cx-missing { padding: 24px; color: var(--lx-muted); max-width: 640px; }
  90. .cx-missing code { background: var(--bg2); padding: 1px 4px; border-radius: 4px; font-size: 12px; }
  91. .cx-hide { display: none !important; }
  92. </style>
  93. <script>window.LENS_MANUAL = true;</script>
  94. <script src="{{lib}}/data.js"></script>
  95. <script src="{{lib}}/kit.js"></script>
  96. <script src="{{libLayer}}/contours.data.js"></script>
  97. </head>
  98. <body>
  99. <div class="cx-app" id="app"></div>
  100. <script>
  101. (function () {
  102. "use strict";
  103. const ROOT = "../../"; // the root of the base from /<layer>/contours/<type>.html
  104. const app = document.getElementById("app");
  105. const head = (function () { // the lens header: the first comment
  106. const w = document.createTreeWalker(document, NodeFilter.SHOW_COMMENT);
  107. const c = w.nextNode();
  108. return c ? c.data : "";
  109. })();
  110. const field = (k) => { const m = new RegExp("^" + k + ":\\s*\"?([^\"\\n]*)\"?\\s*$", "m").exec(head); return m ? m[1].trim() : ""; };
  111. const CID = field("contour");
  112. const L = (window.SHTUKS_LAYER || {}).contours;
  113. const C = L && L.contours && L.contours[CID];
  114. const COLORS = ["default", "gray", "brown", "orange", "yellow", "green", "blue", "purple", "pink", "red", "teal"];
  115. 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})`; };
  116. function h(tag, attrs, ...kids) {
  117. const e = document.createElement(tag);
  118. for (const [k, v] of Object.entries(attrs || {})) {
  119. if (v == null || v === false) continue;
  120. if (k.startsWith("on")) e.addEventListener(k.slice(2), v);
  121. else if (k === "style") e.setAttribute("style", v);
  122. else e.setAttribute(k, v === true ? "" : v);
  123. }
  124. for (const k of kids.flat(Infinity)) if (k != null && k !== false) e.append(k.nodeType ? k : String(k));
  125. return e;
  126. }
  127. const hasKit = () => !!(window.SHTUKS && window.Lens && Lens.open);
  128. function recLink(id, cls, kids) {
  129. return h("a", { class: cls, href: ROOT + encodeURI(id.replace(/^\//, "")), "data-id": id, onclick: (e) => {
  130. if (hasKit() && window.SHTUKS.records[id] && !e.metaKey && !e.ctrlKey) { e.preventDefault(); Lens.open(id); }
  131. } }, kids);
  132. }
  133. const days = (since) => (since ? Math.floor((Date.now() / 1000 - since) / 86400) : null);
  134. const plural = (n, a, b) => (n === 1 ? a : b);
  135. const dd = (n) => n + " " + plural(n, "day", "days");
  136. if (!C) {
  137. document.title = "Contour - no data";
  138. app.append(h("div", { class: "cx-missing" }, h("h2", {}, "No contour data"),
  139. h("p", {}, "The lens reads ", h("code", {}, "lib/<layer>/contours.data.js"), "; it has no contour ", h("code", {}, CID || "(the contour field is empty)"), "."),
  140. h("p", {}, "Build the data: ", h("code", {}, field("generator") || "build_contour_data.py"))));
  141. return;
  142. }
  143. document.title = C.title + " - contour";
  144. const layerHref = "../overview.html";
  145. const top = h("div", { class: "cx-top" },
  146. h("div", { class: "cx-crumbs" }, h("a", { href: layerHref }, "Layer " + C.layer), " · Contours · ",
  147. recLink(C.id, "", C.id)),
  148. h("h1", {}, h("span", {}, C.icon || "🔁"), C.title, C.cross ? h("span", { class: "cx-chip sq", style: tone("purple") }, "cross-cutting") : null));
  149. const q = h("input", { type: "search", placeholder: "Find a card...", "aria-label": "Find a card" });
  150. const onlyStuck = h("input", { type: "checkbox" });
  151. top.append(h("div", { class: "cx-tools" }, q, h("label", {}, onlyStuck, "only stuck ones")));
  152. const stats = h("div", { class: "cx-stats" });
  153. const board = h("div", { class: "lx-board" });
  154. app.append(top, stats, board);
  155. const cols = C.columns.map((c) => ({ ...c, cards: [] }));
  156. for (const card of C.cards) if (cols[card.col]) cols[card.col].cards.push(card);
  157. let stuckTotal = 0;
  158. for (const col of cols) {
  159. for (const c of col.cards) {
  160. c.days = days(c.since);
  161. c.stuck = col.maxDays != null && c.days != null && c.days > col.maxDays;
  162. if (c.stuck) stuckTotal++;
  163. }
  164. col.cards.sort((a, b) => (b.stuck - a.stuck) || ((b.days ?? -1) - (a.days ?? -1)));
  165. }
  166. const S = (k, v, cls) => h("span", { class: cls || "" }, k + " ", h("b", {}, v));
  167. stats.append(S("Cards", C.cards.length), S(C.cross ? "Stages" : "States", C.columns.length),
  168. S("Over the norm", stuckTotal, stuckTotal ? "bad" : ""),
  169. C.collections.length > 1 || C.cross ? h("span", {}, "Collections: ", C.collections.map((x, i) => [i ? ", " : "", recLink(x.id, "", x.title)])) :
  170. C.collections[0] ? h("span", {}, "Collection ", recLink(C.collections[0].id, "", C.collections[0].title)) : null);
  171. function cardEl(c, col) {
  172. const ft = h("div", { class: "ft" });
  173. if (c.state) ft.append(h("span", { class: "cx-chip dot", style: tone(c.state.color), title: c.state.contour }, c.state.title));
  174. if (c.value) ft.append(h("span", { class: "cx-chip sq", title: "the field value is not from the contour" }, c.value));
  175. for (const g of col.gates || []) {
  176. const t = "→ " + g.title + (g.cond ? ": " + g.cond : "") + (g.needs ? " (needs: " + g.needs.join(", ") + ")" : "") + (g.gate ? " · decides: " + g.gate : "");
  177. ft.append(h("span", { class: "cx-to", title: t }, "→ " + g.title));
  178. for (const n of g.needs || []) {
  179. const ok = c.has && c.has[n];
  180. ft.append(h("span", { class: "cx-need " + (ok ? "ok" : "no"), title: (ok ? "filled in: " : "not filled in: ") + n }, (ok ? "✓ " : "✗ ") + n));
  181. }
  182. }
  183. const age = c.days == null ? "—" : c.days === 0 ? "today" : dd(c.days);
  184. 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));
  185. const a = recLink(c.id, "lx-card" + (c.stuck ? " stuck" : ""), [h("div", { class: "ttl" }, c.icon ? c.icon + " " : "", c.title), ft]);
  186. a.dataset.text = (c.title + " " + c.id).toLowerCase();
  187. a.dataset.stuck = c.stuck ? "1" : "";
  188. return a;
  189. }
  190. const PAGE = 60;
  191. for (const col of cols) {
  192. const el = h("div", { class: "lx-col", style: tone(col.color) });
  193. el.append(h("div", { class: "ch" }, h("span", { class: "cx-chip dot", style: tone(col.color) }, col.title),
  194. h("span", { class: "n" }, col.cards.length),
  195. col.maxDays != null ? h("span", { class: "norm", title: "maxDays of the state" }, "norm " + dd(col.maxDays)) : null));
  196. if (col.includes && col.includes.length)
  197. 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))));
  198. if (col.gates && col.gates.length)
  199. el.append(h("details", { class: "cx-gates" }, h("summary", {}, "Gates · " + col.gates.length),
  200. h("ul", {}, col.gates.map((g) => h("li", {}, h("b", {}, "→ " + g.title), g.cond ? " — " + g.cond : "",
  201. g.needs ? h("span", {}, " · needs: ", g.needs.join(", ")) : null, g.gate ? " · decides: " + g.gate : "")))));
  202. const list = h("div", { style: "display:flex;flex-direction:column;gap:6px" });
  203. let shown = 0;
  204. const more = h("button", { class: "cx-more", onclick: () => page() });
  205. function page() {
  206. const next = col.cards.slice(shown, shown + (shown ? 200 : PAGE));
  207. next.forEach((c) => list.append(cardEl(c, col)));
  208. shown += next.length;
  209. more.textContent = "Show " + (col.cards.length - shown) + " more";
  210. more.classList.toggle("cx-hide", shown >= col.cards.length);
  211. filter();
  212. }
  213. el.append(list, more);
  214. if (!col.cards.length) el.append(h("div", { class: "cx-empty" }, "Empty"));
  215. board.append(el);
  216. col.page = page;
  217. col.list = list;
  218. }
  219. function filter() {
  220. const s = q.value.trim().toLowerCase();
  221. const st = onlyStuck.checked;
  222. board.querySelectorAll(".lx-card").forEach((a) => {
  223. a.classList.toggle("cx-hide", (s && !a.dataset.text.includes(s)) || (st && !a.dataset.stuck));
  224. });
  225. }
  226. cols.forEach((c) => c.page());
  227. // the search and "only stuck ones" look at all cards: we load the columns whole
  228. const all = () => cols.forEach((c) => { while (c.cards.length > c.list.childElementCount) c.page(); });
  229. q.addEventListener("input", () => { if (q.value) all(); filter(); });
  230. onlyStuck.addEventListener("change", () => { if (onlyStuck.checked) all(); filter(); });
  231. const id = decodeURI(location.hash.slice(1));
  232. if (id && hasKit() && window.SHTUKS.records[id]) Lens.open(id);
  233. })();
  234. </script>
  235. </body>
  236. </html>