página del paquete→ /base/packages.html
pages/base/packages.html
411 líneas, 24.8 KB. Abrir tal cual (en un proyecto hay otros archivos a su lado; aquí pueden faltar).
El archivo tal como está en el paquete: el código y sus comentarios no se traducen.
- <!--
- ---
- type: Lens
- title: "Project packages"
- icon: "📦"
- description: "The package map: every installed package on a canvas, by group or by dependency layer; a click shows its version, source, dependencies, actions, checks and norms."
- template: custom
- layout: canvas
- lensType: map
- render: live
- sources: [".shtukbase/packages.lock", ".shtukbase/packages/*/package.md"]
- generator: "shtuk run lenses build"
- ---
- A service lens of `lenses`, read from `lib/base/packages.data.js` (`shtuk run lenses build`). A canvas: drag to pan,
- Ctrl or Cmd and the wheel to zoom, F to fit. The card presets and the arrangement are in the right panel.
- -->
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <title>Project packages</title>
- <link rel="stylesheet" href="../lib/kit.css">
- <link rel="stylesheet" href="../lib/explore.css">
- <script src="../lib/data.js"></script>
- <script src="../lib/base/packages.data.js"></script>
- <script src="../lib/design/components.data.js"></script>
- <script src="../lib/explore.js"></script>
- <script src="../lib/kit.js"></script>
- <style>
- /* The map, modelled on the explore kit's "Core and packages": groups of cards on a canvas. Contract names only, each with a
- fallback; the settings land on .pm as data-<name> and --x-<name>. */
- .pm { --pm-fg: var(--foreground, var(--ink, #191919)); --pm-mute: var(--muted-foreground, var(--lx-muted, #6f6e69)); --pm-line: var(--border, var(--line, #e9e9e7));
- --pm-bg: var(--background, var(--bg, #fff)); --pm-r: var(--x-radius, 8px);
- display: flex; flex-wrap: wrap; align-items: flex-start; gap: 56px 64px; padding: 48px; width: max-content; max-width: 1320px; color: var(--pm-fg); box-sizing: border-box; }
- .pm *, .pm *::before, .pm *::after { box-sizing: border-box; }
- .pm[data-arrange="layers"] { flex-direction: column; flex-wrap: nowrap; gap: 56px; max-width: none; }
- /* the canvas under the map */
- .pm-scroll[data-canvas="dots"] { background: var(--background, var(--bg, #fff)) radial-gradient(circle, color-mix(in srgb, var(--foreground, var(--ink, #191919)) 16%, transparent) 1px, transparent 1.3px) 0 0 / 22px 22px; }
- .pm-scroll[data-canvas="grid"] { background: linear-gradient(color-mix(in srgb, var(--foreground, var(--ink, #191919)) 6%, transparent) 1px, transparent 1px) 0 0 / 24px 24px,
- linear-gradient(90deg, color-mix(in srgb, var(--foreground, var(--ink, #191919)) 6%, transparent) 1px, transparent 1px) 0 0 / 24px 24px, var(--background, var(--bg, #fff)); }
- /* a group: a quiet heading (name, count, one line) above its cards; groups are told apart by space only, no border, no fill */
- .pm-area { --ac: var(--chart-2, #2383e2); flex: none; }
- .pm-area > h2 { margin: 0 0 4px; font-size: 15px; font-weight: 600; display: flex; align-items: baseline; gap: 8px; }
- .pm-area > h2 span { font-size: 12px; font-weight: 400; color: var(--pm-mute); }
- .pm-area > p { margin: 0 0 14px; width: 0; min-width: 100%; color: var(--pm-mute); font-size: 12.5px; line-height: 1.4; }
- .pm-area > h2 + .pm-cards { margin-top: 12px; }
- .pm-cards { display: grid; grid-template-columns: repeat(var(--cols, 1), var(--card-w, 300px)); gap: 10px; }
- .pm[data-size="s"] { --card-w: 236px; }
- .pm[data-size="l"] { --card-w: 340px; }
- .pm[data-arrange="layers"] .pm-cards { display: flex; flex-wrap: nowrap; }
- .pm[data-arrange="layers"] .pm-card { width: var(--card-w, 300px); }
- /* a card */
- .pm-card { all: unset; box-sizing: border-box; position: relative; overflow: hidden; display: flex; gap: 12px; padding: 12px; min-width: 0;
- background: var(--pm-bg); border-radius: var(--pm-r); cursor: pointer; transition: box-shadow var(--sb-dur, .18s) var(--sb-ease, ease); }
- .pm[data-edge="shadow"] .pm-card { box-shadow: var(--sb-edge, 0 0 0 1px color-mix(in srgb, var(--pm-fg) 12%, transparent), 0 0 8px color-mix(in srgb, var(--pm-fg) 5%, transparent)); }
- .pm[data-edge="shadow"] .pm-card:hover { box-shadow: var(--sb-shadow-lift, 0 0 0 1px color-mix(in srgb, var(--pm-fg) 16%, transparent), 0 2px 12px color-mix(in srgb, var(--pm-fg) 9%, transparent)); }
- .pm[data-edge="border"] .pm-card { box-shadow: 0 0 0 1px var(--pm-line); }
- .pm[data-edge="border"] .pm-card:hover { box-shadow: 0 0 0 1px color-mix(in srgb, var(--pm-fg) 24%, transparent); }
- .pm[data-edge="none"] .pm-card:hover { background: color-mix(in srgb, var(--pm-fg) 4%, var(--pm-bg)); }
- .pm .pm-card.on { box-shadow: 0 0 0 2px var(--ring, #e04a72); }
- .pm .pm-card:focus-visible { box-shadow: 0 0 0 2px var(--ring, #e04a72); }
- .pm[data-form="top"] .pm-card { flex-direction: column; }
- .pm-ic { flex: none; width: 40px; height: 40px; display: grid; place-items: center; font-size: 26px; line-height: 1; }
- .pm-ic img { width: 100%; height: 100%; object-fit: contain; display: block; }
- .pm[data-size="s"] .pm-ic { width: 28px; height: 28px; font-size: 20px; }
- .pm[data-size="l"] .pm-ic { width: 52px; height: 52px; font-size: 34px; }
- .pm-t { min-width: 0; flex: 1; display: flex; flex-direction: column; }
- .pm-t b { font-size: 13.5px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
- .pm-d { color: var(--pm-mute); font-size: 12px; line-height: 1.4; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
- .pm[data-size="s"] .pm-d { display: none; }
- .pm[data-size="l"] .pm-d { -webkit-line-clamp: 3; }
- [data-cover="hair"] .pm-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--ac); }
- [data-cover="tint"] .pm-card { background: linear-gradient(180deg, color-mix(in srgb, var(--ac) 9%, var(--pm-bg)), var(--pm-bg) 60%); }
- [data-cover="stripe"] .pm-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--ac); }
- .pm-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
- .pm-chip { font: 11px/1 var(--font-mono, ui-monospace, monospace); padding: 4px 6px; border-radius: min(var(--pm-r), 99px); white-space: nowrap; }
- [data-chips="outline"] .pm-chip { box-shadow: inset 0 0 0 1px var(--pm-line); color: var(--pm-mute); }
- [data-chips="tone"] .pm-chip { background: color-mix(in srgb, var(--pm-fg) 6%, var(--pm-bg)); color: var(--pm-mute); }
- [data-chips="juicy"] .pm-chip { background: color-mix(in srgb, var(--ac) 16%, var(--pm-bg)); color: color-mix(in srgb, var(--ac) 60%, var(--pm-fg)); }
- .pm .pm-chip.miss { box-shadow: inset 0 0 0 1px var(--destructive, #e85339); color: var(--destructive, #e85339); background: none; }
- .pm[data-size="l"] .pm-t b { font-size: 15px; }
- .pm-area > .pm-layer-h { font-size: 12.5px; color: var(--pm-mute); margin: 0 0 12px; width: auto; min-width: 0; }
- /* Package details inside the shared peek. */
- .pm-det { display: flex; flex-direction: column; gap: 14px; font-size: 13px; line-height: 1.4; }
- .pm-det p { margin: 0; }
- .pm-det .k { font-size: 12px; color: var(--muted-foreground, #6f6e69); margin-bottom: 4px; }
- .pm-det .mono { font-family: var(--font-mono, ui-monospace, monospace); font-size: 12px; overflow-wrap: anywhere; color: var(--muted-foreground, #6f6e69); }
- .pm-det .links { display: flex; flex-wrap: wrap; gap: 4px 10px; }
- .pm-det .links a { text-decoration: underline; text-decoration-color: var(--border, #e9e9e7); text-underline-offset: 3px; }
- .pm-det .links .miss { color: var(--destructive, #e85339); }
- .pm-det ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 6px; }
- .pm-det li { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 0 8px; }
- .pm-det li code { font-size: 12px; }
- .pm-det li .chk { color: var(--muted-foreground, #6f6e69); font-size: 12px; }
- .pm-det .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--muted-foreground, #6f6e69); }
- .pm-det .dot.enforce { background: var(--chart-3, #01a26f); }
- .pm-det .dot.observe { background: var(--chart-4, #ef7f16); }
- .pm-det a { color: inherit; cursor: pointer; }
- .pm-warn { color: var(--destructive, #e85339); font-size: 12.5px; margin: 0 0 6px; }
- </style>
- <script>
- (function () {
- const { h } = Lens;
- const keys = (o) => Object.keys(o || {});
- const HUES = ["var(--chart-1, #e04a72)", "var(--chart-2, #2383e2)", "var(--chart-3, #01a26f)", "var(--chart-4, #ef7f16)", "var(--chart-5, #975cdc)"];
- const href = (p) => Lens.rootHref + String(p).replace(/^\//, "");
- // A source is a folder, a git address or a registry name; only its last two parts are shown (no home paths on screen).
- const shortSource = (s) => { const parts = String(s || "").replace(/[\\/]+$/, "").split(/[\\/]/); return parts.length > 2 ? "…/" + parts.slice(-2).join("/") : String(s || ""); };
- const firstSentence = (s) => { const m = /^(.+?[.!?])(\s|$)/.exec(String(s || "")); return m ? m[1] : String(s || ""); };
- Lens.templates.custom = function (cfg) {
- const ui = Lens.page(Object.assign({ layout: "canvas" }, cfg));
- const D = window.SHTUK_PACKAGES;
- if (!D) { ui.main.append(h("p", { class: "pm-warn", style: "padding:24px" }, "There is no package data. Build it from the project root: shtuk run lenses build")); return; }
- const P = D.packages, byId = Object.setPrototypeOf(Object.fromEntries(P.map((p) => [p.id, p])), null);
- const isSet = (p) => keys(p.includes).length > 0 || p.kind === "set";
- const usedBy = (id) => P.filter((p) => keys(p.requires).includes(id)).map((p) => p.id);
- const inSets = (id) => P.filter((s) => isSet(s) && keys(s.includes).includes(id)).map((s) => s.id);
- // ---------- groups: a set and what it includes; then families by the first part of the id; then the rest ----------
- const groups = [], placed = new Set();
- for (const s of P.filter(isSet)) {
- const ids = [s.id, ...keys(s.includes).filter((i) => byId[i] && !placed.has(i))];
- ids.forEach((i) => placed.add(i));
- groups.push({ title: s.title, note: firstSentence(s.description), ids });
- }
- const fam = {};
- for (const p of P) if (!placed.has(p.id)) { const f = p.id.split("-")[0]; (fam[f] = fam[f] || []).push(p.id); }
- const rest = [];
- for (const [f, ids] of Object.entries(fam)) {
- if (ids.length < 2) { rest.push(...ids); continue; }
- groups.push({ title: f[0].toUpperCase() + f.slice(1), note: "", ids });
- }
- if (rest.length) groups.push({ title: groups.length ? "Other packages" : "Packages", note: "", ids: rest });
- groups.forEach((g, i) => { g.ac = HUES[i % HUES.length]; });
- const acOf = {};
- for (const g of groups) for (const id of g.ids) acOf[id] = g.ac;
- // ---------- layers: a package stands one row below the deepest package it requires ----------
- const depth = {};
- const deep = (id, seen) => {
- if (depth[id] !== undefined) return depth[id];
- if (seen.has(id)) return 0;
- seen.add(id);
- const up = keys(byId[id].requires).filter((r) => byId[r]).map((r) => deep(r, seen) + 1);
- return (depth[id] = up.length ? Math.max(...up) : 0);
- };
- P.forEach((p) => deep(p.id, new Set()));
- // ---------- what is wrong ----------
- const warns = [];
- for (const p of P) {
- for (const r of keys(p.requires)) if (!byId[r]) warns.push(p.title + " requires " + r + ", which is not installed.");
- if (!p.manifest) warns.push(p.title + " has no package.md in .shtukbase/packages/" + p.id + "/.");
- }
- // ---------- a card ----------
- const cards = Object.create(null);
- function card(p) {
- const missing = keys(p.requires).filter((r) => !byId[r]);
- const checks = p.actions.filter((a) => a.check).length;
- const el = h("button", { type: "button", class: "pm-card", "data-node": p.id, "data-id-pkg": p.id, title: p.title, style: "--ac:" + (acOf[p.id] || HUES[0]),
- "aria-haspopup": "dialog", "aria-expanded": p.id === sel ? "true" : "false",
- onclick: (e) => {
- e.stopPropagation();
- choose(p.id, e.detail ? { clientX: e.clientX, clientY: e.clientY } : el, el);
- } },
- h("span", { class: "pm-ic" }, p.icon ? h("img", { src: href(p.icon), alt: "" }) : "📦"),
- h("span", { class: "pm-t" }, h("b", {}, p.title), p.description ? h("span", { class: "pm-d" }, firstSentence(p.description)) : null,
- h("span", { class: "pm-chips" }, h("span", { class: "pm-chip" }, "v" + p.version),
- isSet(p) ? h("span", { class: "pm-chip" }, "set") : null,
- checks ? h("span", { class: "pm-chip" }, "checks " + checks) : null,
- p.norms.length ? h("span", { class: "pm-chip" }, "norms " + p.norms.length) : null,
- missing.length ? h("span", { class: "pm-chip miss", title: "Not installed: " + missing.join(", ") }, "missing " + missing.length) : null)));
- cards[p.id] = el;
- return el;
- }
- // ---------- the map ----------
- const map = h("div", { class: "pm" });
- const scroller = ui.main;
- scroller.classList.add("pm-scroll");
- let edgesApi = null;
- function arrange(how) {
- if (edgesApi && edgesApi.destroy) edgesApi.destroy();
- map.querySelectorAll(":scope > svg, .lx-edges").forEach((x) => x.remove());
- edgesApi = null;
- map.replaceChildren();
- if (how === "layers") {
- const rows = [];
- for (const p of P) (rows[depth[p.id]] = rows[depth[p.id]] || []).push(p);
- rows.forEach((r, i) => map.append(h("section", { class: "pm-area" },
- h("p", { class: "pm-layer-h" }, i === 0 ? "Layer 1: needs nothing" : "Layer " + (i + 1)),
- h("div", { class: "pm-cards" }, (r || []).map(card)))));
- const edges = P.flatMap((p) => keys(p.requires).filter((r) => byId[r]).map((r) => ({ from: p.id, to: r, kind: "requires" })));
- requestAnimationFrame(() => { edgesApi = Lens.edges(map, edges, { kinds: { requires: { label: "requires", color: "blue" } } }); });
- } else {
- for (const g of groups) {
- const cols = g.ids.length > 4 ? 2 : 1;
- map.append(h("section", { class: "pm-area", style: "--ac:" + g.ac },
- h("h2", {}, g.title, h("span", {}, String(g.ids.length))), g.note ? h("p", {}, g.note) : null,
- h("div", { class: "pm-cards", style: "--cols:" + cols }, g.ids.map((id) => card(byId[id])))));
- }
- }
- if (sel && cards[sel]) cards[sel].classList.add("on");
- }
- scroller.append(map);
- // ---------- the card host and the package details ----------
- const frame = ui.layout;
- const template = h("template", {});
- const bundledPeek = "/design/shtukbase-ui-html/components/block/peek/peek.html";
- const specimen = (window.SB_COMPONENTS?.components || []).find((c) => c.id === "peek")?.html;
- const loadPeek = specimen?.templates?.default
- ? Promise.resolve(specimen.templates.default)
- : fetch(href(specimen?.source || bundledPeek)).then(async (response) => {
- if (!response.ok) return null;
- const doc = new DOMParser().parseFromString(await response.text(), "text/html");
- return doc.querySelector('template[data-state="default"]')?.innerHTML;
- }).catch(() => null);
- const modes = ["side", "center", "card"];
- const prefKey = "lx-open-mode";
- const preferred = new URLSearchParams(location.search).get("peek-mode") || Lens.prefs.get(prefKey, "side");
- let sel = null, handle = null, peek = null, mode = modes.includes(preferred) ? preferred : "side", request = 0;
- let sourceCard = null;
- const panelMode = () => mode === "card" ? "peek" : mode;
- const part = (name) => peek.querySelector(`[data-slot="peek-${name}"]`);
- const packageLink = (p) => href(p.pages.find((page) => page.path.endsWith("/" + p.id + ".md"))?.path
- || "/.shtukbase/packages/" + encodeURIComponent(p.id) + "/package.md");
- const mapLink = (id) => {
- const url = new URL(location.href);
- if (mode !== "side") url.searchParams.set("peek-mode", mode);
- else url.searchParams.delete("peek-mode");
- if (id) url.searchParams.set("package", id);
- else url.searchParams.delete("package");
- return url;
- };
- function select(id) {
- sel = id;
- for (const [key, el] of Object.entries(cards)) {
- el.classList.toggle("on", key === sel);
- el.setAttribute("aria-expanded", String(key === sel));
- }
- history.replaceState(null, "", mapLink(id));
- }
- function showMode(anchor) {
- if (!peek || !sel) return;
- peek.dataset.mode = mode;
- for (const el of part("modes").children)
- el.setAttribute("aria-pressed", String(el.dataset.mode === mode));
- handle = frame.openCard(peek, { mode: panelMode(), anchor });
- }
- function setMode(value) {
- if (!modes.includes(value) || value === mode) return;
- mode = value;
- Lens.prefs.set(prefKey, mode);
- modePicker.value = mode;
- history.replaceState(null, "", mapLink(sel));
- showMode();
- }
- if (frame?.cardHost) new MutationObserver(() => {
- if (!handle || frame.cardHost.dataset.state !== "closed") return;
- handle = null;
- select(null);
- if (sourceCard) {
- const target = sourceCard.el.isConnected ? sourceCard.el : cards[sourceCard.id];
- target?.focus({ preventScroll: true });
- }
- sourceCard = null;
- }).observe(frame.cardHost, { attributes: true, attributeFilter: ["data-state"] });
- function makePeek(markup) {
- template.innerHTML = markup;
- const el = template.content.querySelector('[data-slot="peek"]');
- if (!el) return null;
- // The lens build joins CSS into lib/kit.css, so resolve registry assets from the project root.
- for (const icon of el.querySelectorAll("[data-icon]")) {
- const url = href("/design/shtukbase-icons/flat/" + icon.dataset.icon + ".svg");
- icon.style.setProperty("--peek-icon", `url("${url}")`);
- }
- el.addEventListener("click", (event) => {
- const control = event.target.closest('[data-slot="peek-mode"], [data-slot="peek-close"]');
- if (!control) return;
- if (control.dataset.slot === "peek-close") handle?.close();
- else setMode(control.dataset.mode);
- });
- return el;
- }
- function sec(title, ...nodes) { const n = nodes.flat().filter(Boolean); return n.length ? h("div", {}, h("div", { class: "k" }, title), n) : null; }
- const linkList = (ids) => h("div", { class: "links" }, ids.map((id) => byId[id]
- ? h("a", { href: mapLink(id).href, onclick: (event) => {
- if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return;
- event.preventDefault();
- choose(id);
- } }, byId[id].title)
- : h("span", { class: "miss" }, id)));
- function details(p) {
- const req = keys(p.requires);
- return h("div", { class: "pm-det" },
- h("p", { class: "mono" }, p.id + " · v" + p.version),
- p.description ? h("p", {}, p.description) : null,
- sec("Source", h("div", { class: "mono", title: p.source }, shortSource(p.source)), p.installed ? h("div", { class: "mono" }, "installed " + p.installed) : null),
- req.length ? sec("Requires", linkList(req)) : null,
- usedBy(p.id).length ? sec("Required by", linkList(usedBy(p.id))) : null,
- keys(p.includes).length ? sec("Includes", linkList(keys(p.includes))) : null,
- inSets(p.id).length ? sec("In sets", linkList(inSets(p.id))) : null,
- p.actions.length ? sec("Actions", h("ul", {}, p.actions.map((a) => h("li", {}, h("code", {}, a.name), h("span", {}, a.title || a.run, a.check ? h("span", { class: "chk" }, " · check") : null))))) : null,
- p.norms.length ? sec("Norms", h("ul", {}, p.norms.map((n) => h("li", {}, h("span", { class: "dot " + (n.enforcers && n.enforcers.length ? n.mode : "") , title: n.enforcers && n.enforcers.length ? n.mode : "no enforcer" }),
- h("a", { href: href(n.path) }, n.id + " — " + n.title))))) : null,
- p.pages.length ? sec("Pages", h("div", { class: "mono" }, p.pages.length + " pages" + (p.pages.some((x) => x.state !== "clean") ? ", " + p.pages.filter((x) => x.state !== "clean").length + " edited" : ""))) : null);
- }
- async function choose(id, anchor, source) {
- const p = byId[id];
- if (!p) return;
- const ticket = ++request;
- const markup = peek ? null : await loadPeek;
- if (ticket !== request) return;
- if (!peek && markup) peek = makePeek(markup);
- if (!peek || !frame?.openCard) {
- location.assign(packageLink(p));
- return;
- }
- if (source) sourceCard = { id, el: source };
- select(id);
- const title = part("title");
- title.textContent = p.title;
- part("page").href = packageLink(p);
- const body = part("body");
- body.replaceChildren(details(p));
- (body.closest('[data-slot="scroll-area-viewport"]') || body).scrollTop = 0;
- part("footer").replaceChildren();
- showMode(anchor);
- if (!source) title.focus({ preventScroll: true });
- }
- scroller.addEventListener("click", (event) => {
- if (!event.target.closest(".pm-card, .lx-zoomctl")) handle?.close();
- });
- const counts = [["Packages", String(P.filter((p) => !isSet(p)).length)], ["Sets", String(P.filter(isSet).length)],
- ["Checks", String(P.reduce((n, p) => n + p.actions.filter((a) => a.check).length, 0))], ["Norms", String(P.reduce((n, p) => n + p.norms.length, 0))]];
- ui.section("Overview", warns.map((w) => h("p", { class: "pm-warn" }, w)), h("div", { class: "lx-stats" }, Lens.stats(counts)));
- const modeLabel = "Open in";
- const modeControl = Lens.select([["side", "Side"], ["center", "Center"], ["card", "Card"]], mode, setMode,
- { id: "pm-peek-mode" });
- const modePicker = modeControl.querySelector("select");
- ui.section("Settings", h("div", { class: "panel-section-row", "data-slot": "panel-section-row" },
- h("label", { for: modePicker.id, class: "panel-section-label", "data-slot": "panel-section-label" }, modeLabel),
- h("div", { class: "panel-section-control", "data-slot": "panel-section-control" }, modeControl)));
- if (mode !== "side") history.replaceState(null, "", mapLink(new URLSearchParams(location.search).get("package")));
- const opts = {
- title: "Settings",
- target: map,
- storageKey: "packages-map",
- sections: [
- { title: "Layout", controls: {
- arrange: { kind: "segment", label: "Arrange", options: [["groups", "groups"], ["layers", "layers"]], default: "groups" },
- canvas: { kind: "segment", label: "Canvas", options: [["dots", "dots"], ["grid", "grid"], ["plain", "plain"]], default: "dots" } } },
- { title: "Cards", controls: {
- form: { kind: "segment", label: "Icon", options: [["left", "left"], ["top", "on top"]], default: "left" },
- size: { kind: "segment", options: [["s", "S"], ["m", "M"], ["l", "L"]], default: "m" },
- cover: { kind: "select", options: [["none", "none"], ["hair", "line on top"], ["tint", "tint from the top"], ["stripe", "stripe on the left"]], default: "none" },
- edge: { kind: "segment", options: ["shadow", "border", "none"], default: "shadow" },
- chips: { kind: "select", options: [["outline", "grey outline"], ["tone", "grey tone"], ["juicy", "group colour"]], default: "outline" },
- radius: { kind: "range", label: "Rounding", min: 0, max: 16, step: 1, unit: "px", default: 8 } } },
- ],
- presets: {
- main: {},
- editorial: { form: "top", size: "l", cover: "tint", chips: "tone", radius: 12, edge: "shadow", canvas: "plain" },
- quiet: { cover: "none", edge: "border", chips: "tone", canvas: "plain" },
- juicy: { cover: "stripe", chips: "juicy", radius: 14, canvas: "grid" },
- },
- onChange: (v) => {
- scroller.dataset.canvas = v.canvas || "dots";
- if (v.arrange !== map.dataset.arranged) { map.dataset.arranged = v.arrange; arrange(v.arrange); }
- else if (edgesApi && edgesApi.redraw) requestAnimationFrame(() => edgesApi.redraw());
- },
- };
- if (ui.settings) ui.settings(opts);
- else if (window.Explore && !window.Explore.standIn) window.Explore.panel(Object.assign({}, opts, { container: ui.section() }));
- else {
- const d = { arrange: "groups", canvas: "dots", form: "left", size: "m", cover: "none", edge: "shadow", chips: "outline" };
- for (const [k, v] of Object.entries(d)) map.dataset[k] = v;
- opts.onChange(d);
- }
- if (!map.dataset.arranged) { map.dataset.arranged = map.dataset.arrange || "groups"; arrange(map.dataset.arranged); }
- // ---------- the canvas: pan, zoom, fit ----------
- const zoom = ui.zoom || Lens.zoom(scroller, map, { pan: true });
- const want = new URLSearchParams(location.search).get("package");
- // Fit first so a linked package can anchor to its final position.
- requestAnimationFrame(() => {
- if (zoom && !zoom.restored && zoom.fit) zoom.fit();
- if (byId[want]) choose(want, cards[want], cards[want]);
- });
- Lens.on("search", (q) => {
- for (const [id, c] of Object.entries(cards)) {
- const p = byId[id], hit = !q || (p.title + " " + p.id + " " + p.description).toLowerCase().includes(q);
- c.style.opacity = hit ? "" : ".25";
- }
- });
- };
- })();
- </script>
- </head>
- <body><p class="lx-missing">The lens "Project packages". There is no data yet: build it from the project root with <code>shtuk run lenses build</code>.</p></body>
- </html>