@jonandev/longbeard 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/AGENTS.md +3 -4
  2. package/CHANGELOG.md +72 -0
  3. package/README.md +63 -43
  4. package/beard.json +113 -26
  5. package/bin/long-beard.js +172 -36
  6. package/package.json +1 -1
  7. package/skills/design/SKILL.md +51 -122
  8. package/skills/design-brief/SKILL.md +146 -0
  9. package/skills/design-brief/references/graphic.md +59 -0
  10. package/skills/design-check/SKILL.md +27 -11
  11. package/skills/design-check/references/design-rules.md +21 -7
  12. package/skills/design-check/scripts/capture.mjs +121 -37
  13. package/skills/design-check/scripts/contrast.mjs +23 -9
  14. package/skills/design-check/scripts/rules.mjs +613 -0
  15. package/skills/design-check/scripts/screen-contrast.mjs +428 -0
  16. package/skills/design-check/scripts/tokens.mjs +346 -0
  17. package/skills/design-content/SKILL.md +118 -0
  18. package/skills/design-content/scripts/contact-sheet.mjs +259 -0
  19. package/skills/design-content/scripts/pictures.mjs +197 -0
  20. package/skills/design-direction/SKILL.md +117 -145
  21. package/skills/design-direction/references/controls.md +58 -0
  22. package/skills/{design → design-direction}/references/design-rules.md +21 -7
  23. package/skills/design-direction/references/five-second.md +47 -0
  24. package/skills/design-direction/references/full-build.md +19 -0
  25. package/skills/design-direction/references/graphic.md +35 -0
  26. package/skills/design-direction/references/grid.md +114 -0
  27. package/skills/design-direction/references/library.md +75 -0
  28. package/skills/design-direction/references/screen-template.html +233 -0
  29. package/skills/design-direction/references/subject.md +33 -0
  30. package/skills/design-direction/scripts/capture.mjs +121 -37
  31. package/skills/design-direction/scripts/contact-sheet.mjs +18 -7
  32. package/skills/design-direction/scripts/fonts.mjs +276 -0
  33. package/skills/design-direction/scripts/layout-diff.mjs +118 -0
  34. package/skills/design-direction/scripts/measure.mjs +1728 -0
  35. package/skills/design-direction/scripts/moodboard.mjs +123 -32
  36. package/skills/design-direction/scripts/picture-cast.mjs +270 -0
  37. package/skills/design-direction/scripts/pictures.mjs +197 -0
  38. package/skills/design-direction/scripts/screen-contrast.mjs +428 -0
  39. package/skills/design-direction/scripts/sheet.mjs +67 -0
  40. package/skills/design-direction/scripts/subject-colours.mjs +410 -0
  41. package/skills/design-families/SKILL.md +138 -0
  42. package/skills/design-families/scripts/contact-sheet.mjs +259 -0
  43. package/skills/design-families/scripts/families.mjs +606 -0
  44. package/skills/design-families/scripts/measure.mjs +1728 -0
  45. package/skills/design-families/scripts/moodboard.mjs +467 -0
  46. package/skills/design-families/scripts/tag.mjs +289 -0
  47. package/skills/design-figma/SKILL.md +69 -0
  48. package/skills/design-figma/references/graphic.md +26 -0
  49. package/skills/design-identity/SKILL.md +134 -0
  50. package/skills/design-identity/references/graphic.md +8 -0
  51. package/skills/design-identity/references/identity-board.html +140 -0
  52. package/skills/{design → design-identity}/scripts/capture.mjs +121 -37
  53. package/skills/design-identity/scripts/colours.mjs +213 -0
  54. package/skills/design-identity/scripts/contrast.mjs +41 -0
  55. package/skills/design-identity/scripts/fonts.mjs +276 -0
  56. package/skills/design-identity/scripts/measure.mjs +1728 -0
  57. package/skills/design-identity/scripts/sheet.mjs +67 -0
  58. package/skills/design-identity/scripts/subject-colours.mjs +410 -0
  59. package/skills/design-moodboard/SKILL.md +184 -0
  60. package/skills/design-moodboard/references/graphic.md +25 -0
  61. package/skills/{design-direction → design-moodboard}/references/sources.md +17 -11
  62. package/skills/design-moodboard/scripts/capture.mjs +893 -0
  63. package/skills/design-moodboard/scripts/contact-sheet.mjs +259 -0
  64. package/skills/design-moodboard/scripts/crops.mjs +256 -0
  65. package/skills/design-moodboard/scripts/dribbble-cards.mjs +418 -0
  66. package/skills/design-moodboard/scripts/families.mjs +606 -0
  67. package/skills/design-moodboard/scripts/group.mjs +221 -0
  68. package/skills/design-moodboard/scripts/measure.mjs +1728 -0
  69. package/skills/design-moodboard/scripts/moodboard.mjs +467 -0
  70. package/skills/{design-direction → design-moodboard}/scripts/picker.mjs +121 -20
  71. package/skills/design-moodboard/scripts/pictures.mjs +197 -0
  72. package/skills/design-moodboard/scripts/tag.mjs +289 -0
  73. package/skills/design-prototype/SKILL.md +149 -0
  74. package/skills/design-prototype/references/design-md-template.md +82 -0
  75. package/skills/design-prototype/references/design-rules.md +203 -0
  76. package/skills/design-prototype/references/five-second.md +47 -0
  77. package/skills/design-prototype/references/graphic.md +27 -0
  78. package/skills/design-prototype/scripts/capture.mjs +893 -0
  79. package/skills/design-prototype/scripts/contrast.mjs +41 -0
  80. package/skills/design-prototype/scripts/links.mjs +308 -0
  81. package/skills/design-prototype/scripts/pictures.mjs +197 -0
  82. package/skills/design-prototype/scripts/rules.mjs +613 -0
  83. package/skills/design-prototype/scripts/screen-contrast.mjs +428 -0
  84. package/skills/design-prototype/scripts/sheet.mjs +67 -0
  85. package/skills/design-prototype/scripts/tokens.mjs +346 -0
  86. package/skills/design-wordmark/SKILL.md +65 -0
  87. package/skills/design-wordmark/scripts/capture.mjs +893 -0
  88. package/skills/design-wordmark/scripts/sheet.mjs +67 -0
  89. package/skills/idea/SKILL.md +13 -7
  90. package/skills/idea/references/graphic.md +64 -0
  91. package/skills/design/references/design-md-template.md +0 -58
  92. package/skills/design/scripts/contrast.mjs +0 -27
  93. package/skills/design-direction/scripts/dribbble-cards.mjs +0 -356
@@ -0,0 +1,467 @@
1
+ #!/usr/bin/env node
2
+ // A moodboard of the references, built to be marked: every card with a shot
3
+ // or recorded frames, grouped by its topic (the family it looks like, or the
4
+ // one piece it is for), with Lead, Like and No, a note per tile, and a
5
+ // copy-out for the chat. The
6
+ // layout is this file. It shows what we saw. It does not paint a brand.
7
+ //
8
+ // A card's fields in board.md: link, shot, frames (a folder that
9
+ // capture.mjs --frames wrote, played on hover), topic (or part), pattern (or move), measured
10
+ // (its traits from measure.mjs, shown small under the pattern), why, like (the
11
+ // person's own words from the picker: what they like in it, and why; shown on
12
+ // the card and put in its note until they change it).
13
+ //
14
+ // node moodboard.mjs .longbeard/design/moodboard/board.md --out .longbeard/design/moodboard/moodboard.html
15
+ // node moodboard.mjs .longbeard/design/pricing/board.md --out .longbeard/design/pricing/moodboard.html
16
+ //
17
+ // A big pool is chosen in two steps. --overview 6 shows each family as its
18
+ // first six tiles (families.mjs writes the most typical first), how many more
19
+ // it has, and its measured ranges from a "Families:" header line, with one
20
+ // Take button and a note per family. The copy-out lists the families taken.
21
+ // Then a board of only those families is marked as usual.
22
+ // node moodboard.mjs .longbeard/design/moodboard/board.md --overview 6 --out .longbeard/design/families/families.html
23
+ import { execSync } from "node:child_process";
24
+ import { existsSync, mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
25
+ import { dirname, isAbsolute, join, relative, resolve } from "node:path";
26
+
27
+ const args = process.argv.slice(2);
28
+ const outAt = args.indexOf("--out");
29
+ const outArg = outAt === -1 ? "" : (args.splice(outAt, 2)[1] ?? "");
30
+ const overAt = args.indexOf("--overview");
31
+ const overview = overAt === -1 ? 0 : Number(args.splice(overAt, 2)[1]);
32
+ if (overAt !== -1 && !(Number.isInteger(overview) && overview >= 1 && overview <= 24)) {
33
+ console.error("moodboard: --overview takes how many tiles to show per family, 1 to 24");
34
+ process.exit(2);
35
+ }
36
+ const boardArg = args[0];
37
+ if (!boardArg || !outArg || args.length !== 1) {
38
+ console.error("usage: node moodboard.mjs .longbeard/design/<step>/board.md --out .longbeard/design/<step>/moodboard.html");
39
+ process.exit(2);
40
+ }
41
+
42
+ function projectRoot() {
43
+ try {
44
+ return execSync("git rev-parse --show-toplevel", { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim();
45
+ } catch {
46
+ return process.cwd();
47
+ }
48
+ }
49
+
50
+ const root = projectRoot();
51
+ const resolvePath = (path) => (isAbsolute(path) ? path : resolve(root, path));
52
+ const boardPath = resolvePath(boardArg);
53
+ const outPath = resolvePath(outArg);
54
+ if (!existsSync(boardPath)) {
55
+ console.error(`moodboard: no board at ${boardArg}`);
56
+ process.exit(1);
57
+ }
58
+
59
+ const esc = (s) =>
60
+ String(s ?? "")
61
+ .replace(/&/g, "&amp;")
62
+ .replace(/</g, "&lt;")
63
+ .replace(/>/g, "&gt;")
64
+ .replace(/"/g, "&quot;")
65
+ .replace(/'/g, "&#39;");
66
+ // A local path in a src or href: each part encoded, so # ? % and spaces stay in the name.
67
+ const href = (abs) => {
68
+ const src = relative(dirname(outPath), abs)
69
+ .split("\\")
70
+ .join("/")
71
+ .split("/")
72
+ .map(encodeURIComponent)
73
+ .join("/");
74
+ return src.startsWith(".") ? src : `./${src}`;
75
+ };
76
+
77
+ function fieldsOf(text) {
78
+ const fields = {};
79
+ for (const line of text.split(/\r?\n/)) {
80
+ const m = line.match(/^- ([a-z][a-z /-]*):\s*(.*)$/i);
81
+ if (m) fields[m[1].toLowerCase()] = m[2].trim();
82
+ }
83
+ return fields;
84
+ }
85
+
86
+ // The parts of a site, in the order a visitor meets them. A topic not here
87
+ // (an app's key screen, say) keeps the order it first appears in on the board.
88
+ const TOPICS = [
89
+ ["Home", /^(home|homepage|landing|hero)$/],
90
+ // "menu" is left out: for a restaurant or a bakery it is the list of dishes, not the navigation.
91
+ ["Navigation", /^(nav|navigation|nav menu|header)$/],
92
+ ["Index", /^(index|listing|list|work|archive|grid|catalogue|catalog)$/],
93
+ ["Case study", /^(case[ -]?stud(y|ies)|project|work detail)$/],
94
+ ["Article", /^(article|editorial|reading|long[ -]?read|story)$/],
95
+ ["Blog", /^(blog|journal|news|notes)$/],
96
+ ["Photography", /^(photo|photos|photography|imagery|image|pictures)$/],
97
+ ["Motion", /^(motion|animation|transition|transitions|interaction)$/],
98
+ ];
99
+ function topicOf(raw) {
100
+ const t = String(raw || "").trim().toLowerCase();
101
+ if (!t) return { key: "", label: "Other", rank: 1e6 };
102
+ const at = TOPICS.findIndex(([, re]) => re.test(t));
103
+ if (at !== -1) return { key: t, label: TOPICS[at][0], rank: at };
104
+ return { key: t, label: t.charAt(0).toUpperCase() + t.slice(1), rank: 1000 };
105
+ }
106
+
107
+ // Frames from capture.mjs --frames: 01-00000ms.jpg, 02-00500ms.jpg…
108
+ function framesOf(folder) {
109
+ const abs = resolvePath(folder.trim().replace(/\/$/, ""));
110
+ if (!existsSync(abs) || !statSync(abs).isDirectory()) return null;
111
+ const files = readdirSync(abs)
112
+ .filter((f) => /\.(jpe?g|png|webp)$/i.test(f))
113
+ .sort();
114
+ if (!files.length) return null;
115
+ return files.map((f, i) => ({ src: href(join(abs, f)), ms: Number(f.match(/(\d+)ms\./)?.[1] ?? i * 500) }));
116
+ }
117
+
118
+ const md = readFileSync(boardPath, "utf8");
119
+ // Ranges per family, from board.md's header: "Families: f1 (light · empty 55–70%) — 42; f2 (…) — 18".
120
+ const ranges = new Map();
121
+ const familiesLine = md.match(/^Families:\s*(.*)$/m)?.[1] || "";
122
+ for (const part of familiesLine.split(";")) {
123
+ const m = part.trim().match(/^(.+?)\s*\((.+)\)/);
124
+ if (m) ranges.set(m[1].trim().toLowerCase(), m[2].trim());
125
+ }
126
+ const cards = md
127
+ .split(/^### /m)
128
+ .slice(1)
129
+ .map((chunk) => {
130
+ const nl = chunk.indexOf("\n");
131
+ const name = (nl === -1 ? chunk : chunk.slice(0, nl)).trim();
132
+ return { name, ...fieldsOf((nl === -1 ? "" : chunk.slice(nl + 1)).split(/^## /m)[0]) };
133
+ });
134
+
135
+ const sections = new Map();
136
+ let n = 0;
137
+ // A mark is saved under the card's name, so adding or dropping a card never
138
+ // moves a mark onto another. Two cards with one name tell apart by order.
139
+ const names = new Map();
140
+ for (const card of cards) {
141
+ const frames = card.frames ? framesOf(card.frames) : null;
142
+ if (card.frames && !frames) console.error(`moodboard: no frames in ${card.frames.trim()}`);
143
+ let poster = "";
144
+ if (card.shot) {
145
+ const abs = resolvePath(card.shot.trim());
146
+ if (existsSync(abs)) poster = href(abs);
147
+ else console.error(`moodboard: missing shot ${card.shot.trim()}`);
148
+ }
149
+ if (!poster && frames) poster = frames[frames.length - 1].src;
150
+ if (!poster) continue;
151
+ const id = `m${++n}`;
152
+ const seenName = (names.get(card.name) ?? 0) + 1;
153
+ names.set(card.name, seenName);
154
+ const markKey = seenName > 1 ? `${card.name} #${seenName}` : card.name;
155
+ const topic = topicOf(card.topic || card.part);
156
+ // A seed shared in chat has no URL, so its name is not a link.
157
+ const url = (card.link || "").trim().split(/\s+/)[0];
158
+ const name = /^https?:\/\//i.test(url)
159
+ ? `<a class="name" href="${esc(url)}" target="_blank" rel="noopener noreferrer">${esc(card.name)}</a>`
160
+ : `<span class="name">${esc(card.name)}</span>`;
161
+ const like = (card.like || "").trim();
162
+ const line = ((card.pattern || card.move) ? `<p class="line">${esc(card.pattern || card.move)}</p>` : "") + (card.measured ? `<p class="measured">${esc(card.measured)}</p>` : "") + (like ? `<p class="liked">You liked: ${esc(like)}</p>` : "");
163
+ const play = frames
164
+ ? `<button type="button" class="play" aria-label="Play ${esc(card.name)}">Play</button><span class="clock"></span>`
165
+ : "";
166
+ const tile = `<figure class="tile" data-id="${id}" data-title="${esc(card.name)}" data-topic="${esc(topic.label)}" data-key="${esc(markKey)}"${like ? ` data-like="${esc(like)}"` : ""}${
167
+ frames ? ` data-frames="${esc(JSON.stringify(frames))}"` : ""
168
+ }>
169
+ <div class="frame"><a class="open" href="${esc(poster)}" target="_blank" rel="noopener" aria-label="Open the shot of ${esc(card.name)}"><img src="${esc(poster)}" alt="${esc(card.name)}" loading="lazy"></a><span class="id">${id}</span>${play}</div>
170
+ <figcaption>
171
+ ${name}${line}
172
+ <div class="marks" role="group" aria-label="Mark ${esc(card.name)}">
173
+ <button type="button" data-mark="lead" aria-pressed="false">Lead</button>
174
+ <button type="button" data-mark="like" aria-pressed="false">Like</button>
175
+ <button type="button" data-mark="no" aria-pressed="false">No</button>
176
+ </div>
177
+ <input class="why" type="text" placeholder="Note (optional)" aria-label="Note on ${esc(card.name)}">
178
+ </figcaption>
179
+ </figure>`;
180
+ // In the overview each family is its own section, named by its id as written (f1, not F1), so the
181
+ // copy-out names the list on disk (families/f1.tsv) and the board's Families: line finds its ranges.
182
+ const at = overview ? topic.key : topic.label;
183
+ if (!sections.has(at)) sections.set(at, { label: topic.label, key: topic.key, rank: topic.rank, order: sections.size, tiles: [] });
184
+ sections.get(at).tiles.push(tile);
185
+ }
186
+
187
+ if (!n) {
188
+ console.error("moodboard: no card on the board has a shot or frames");
189
+ process.exit(1);
190
+ }
191
+
192
+ const ordered = [...sections.entries()].sort(([, a], [, b]) => a.rank - b.rank || a.order - b.order);
193
+ const slug = (s) => `t-${s.toLowerCase().replace(/[^a-z0-9]+/g, "-")}`;
194
+ const jump = ordered
195
+ .map(([at, s]) => `<a href="#${slug(at)}">${esc(s.label)} <span>${s.tiles.length}</span></a>`)
196
+ .join("");
197
+ const body = ordered
198
+ .map(([at, s]) => {
199
+ const { label, key } = s;
200
+ const shown = overview ? s.tiles.slice(0, overview) : s.tiles;
201
+ const more = s.tiles.length - shown.length;
202
+ const head = overview
203
+ ? `<h2>${esc(label)} <span>${s.tiles.length}</span></h2>
204
+ ${ranges.has(key) ? `<p class="ranges">${esc(ranges.get(key))}</p>` : ""}
205
+ <div class="take"><button type="button" class="fam" data-family="${esc(key || label)}" aria-pressed="false">Take this family</button><input class="fam-note" type="text" data-family="${esc(key || label)}" placeholder="Note (optional): two looks in one, belongs with another…" aria-label="Note on ${esc(label)}">${more ? `<span class="more">+${more} more not shown</span>` : ""}</div>`
206
+ : `<h2>${esc(label)} <span>${s.tiles.length}</span></h2>`;
207
+ return `<section id="${slug(at)}">
208
+ ${head}
209
+ <div class="grid">
210
+ ${shown.join("\n ")}
211
+ </div>
212
+ </section>`;
213
+ })
214
+ .join("\n ");
215
+
216
+ const html = `<!DOCTYPE html>
217
+ <html lang="en">
218
+ <head>
219
+ <meta charset="utf-8">
220
+ <meta name="viewport" content="width=device-width, initial-scale=1">
221
+ <title>Moodboard</title>
222
+ <style>
223
+ :root { --canvas: #e4e4e2; --paper: #ffffff; --ink: #1c1c1a; --muted: #6f6f6a; --line: #c8c8c4; --lead: #8a5a00; --like: #1f7a3a; --no: #b3261e; }
224
+ * { box-sizing: border-box; }
225
+ html { color-scheme: light; scroll-padding-top: 64px; }
226
+ body { margin: 0; background: var(--canvas); color: var(--ink); font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
227
+ main { max-width: 1400px; margin: 0 auto; padding: 0 24px 300px; }
228
+ header { position: sticky; top: 0; z-index: 2; background: var(--canvas); padding: 20px 2px 12px; }
229
+ h1 { margin: 0 0 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: var(--muted); }
230
+ .how { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
231
+ nav { display: flex; flex-wrap: wrap; gap: 8px; }
232
+ nav a, .filters button { font-size: 13px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none; cursor: pointer; font-family: inherit; }
233
+ nav a span, h2 span { color: var(--muted); }
234
+ .filters { display: flex; gap: 8px; margin-top: 8px; }
235
+ .filters button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
236
+ section { margin-top: 28px; }
237
+ section[hidden] { display: none; }
238
+ h2 { margin: 0 0 12px 2px; font-size: 18px; font-weight: 600; }
239
+ .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
240
+ .tile { margin: 0; display: flex; flex-direction: column; background: var(--paper); border-radius: 18px; overflow: hidden; outline: 3px solid transparent; outline-offset: -3px; }
241
+ .tile[hidden] { display: none; }
242
+ .tile[data-state="lead"] { outline-color: var(--lead); }
243
+ .tile[data-state="like"] { outline-color: var(--like); }
244
+ .tile[data-state="no"] .frame img { opacity: 0.3; filter: grayscale(1); }
245
+ /* A tall page shows its top, where a person starts; the picture opens in full. */
246
+ .frame { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: #141414; }
247
+ .frame .open { position: absolute; inset: 0; display: block; }
248
+ .frame img { width: 100%; height: 100%; object-fit: cover; object-position: top center; display: block; }
249
+ .id, .clock, .play { position: absolute; font-size: 11px; font-weight: 600; padding: 3px 7px; border-radius: 6px; background: rgba(0,0,0,0.65); color: #fff; }
250
+ .id { top: 8px; left: 8px; pointer-events: none; }
251
+ .play { bottom: 8px; left: 8px; border: 0; cursor: pointer; font-family: inherit; }
252
+ .clock { bottom: 8px; right: 8px; pointer-events: none; }
253
+ .clock:empty { display: none; }
254
+ figcaption { flex: 1; display: flex; flex-direction: column; gap: 8px; padding: 12px 14px 14px; }
255
+ .name { font-size: 15px; line-height: 1.3; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
256
+ a.name:hover { text-decoration: underline; }
257
+ .line { margin: -4px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); }
258
+ .measured { margin: -6px 0 0; font-size: 11px; line-height: 1.4; color: var(--muted); font-variant-numeric: tabular-nums; }
259
+ .liked { margin: -4px 0 0; font-size: 13px; line-height: 1.4; color: var(--like); }
260
+ [data-overview] .liked { display: none; }
261
+ .marks { display: flex; gap: 6px; margin-top: auto; }
262
+ .marks button { flex: 1; font: inherit; font-size: 13px; font-weight: 600; padding: 7px 0; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
263
+ .marks button[data-mark="lead"][aria-pressed="true"] { background: var(--lead); border-color: var(--lead); color: #fff; }
264
+ .marks button[data-mark="like"][aria-pressed="true"] { background: var(--like); border-color: var(--like); color: #fff; }
265
+ .marks button[data-mark="no"][aria-pressed="true"] { background: var(--no); border-color: var(--no); color: #fff; }
266
+ button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid #2f6fdb; outline-offset: 2px; }
267
+ .why { font: inherit; font-size: 13px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }
268
+ .bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; background: var(--paper); border-top: 1px solid var(--line); box-shadow: 0 -6px 24px rgba(0,0,0,0.08); }
269
+ .bar-in { max-width: 1400px; margin: 0 auto; padding: 14px 24px 16px; display: grid; grid-template-columns: 1fr 1.4fr auto; gap: 14px; align-items: start; }
270
+ .bar label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
271
+ .bar textarea { width: 100%; font: 13px/1.4 ui-monospace, Menlo, monospace; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; resize: vertical; height: 96px; }
272
+ #note { font-family: inherit; font-size: 14px; }
273
+ #out { background: #f6f6f4; }
274
+ .side { display: flex; flex-direction: column; gap: 8px; padding-top: 22px; min-width: 150px; }
275
+ #count { font-size: 13px; color: var(--muted); }
276
+ [data-overview] .marks, [data-overview] .why, [data-overview] .filters { display: none; }
277
+ .ranges { margin: -6px 0 10px 2px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
278
+ .take { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 12px 2px; }
279
+ .fam { font: inherit; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); cursor: pointer; }
280
+ .fam[aria-pressed="true"] { background: var(--like); border-color: var(--like); color: #fff; }
281
+ .fam-note { flex: 1 1 260px; font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
282
+ .more { font-size: 13px; color: var(--muted); }
283
+ #copy { font: inherit; font-size: 14px; font-weight: 600; padding: 10px 16px; border-radius: 10px; border: 0; background: var(--ink); color: var(--paper); cursor: pointer; }
284
+ @media (max-width: 800px) { .bar-in { grid-template-columns: 1fr; } .side { padding-top: 0; } main { padding-bottom: 480px; } header { position: static; } }
285
+ </style>
286
+ </head>
287
+ <body${overview ? " data-overview" : ""}>
288
+ <main>
289
+ <header>
290
+ <h1>${overview ? "Families" : "Moodboard"}</h1>
291
+ ${overview ? `<p class="how">Each family shows its most typical ${overview}. Take the ones you want to see in full, any number. Note a family that looks like two, or that belongs with another.</p>` : ""}
292
+ <p class="how"${overview ? " hidden" : ""}>Lead what should set the tone for its group (one per group: a part, or a direction), Like what belongs, No what feels wrong. Add a note where you have one; a tile in the wrong group gets the note "move to" and the group's name. The picture opens the shot, the name opens the source, and Play runs recorded motion.</p>
293
+ <nav aria-label="Parts">${jump}</nav>
294
+ <div class="filters" role="group" aria-label="Show">
295
+ <button type="button" data-show="all" aria-pressed="true">All</button>
296
+ <button type="button" data-show="open" aria-pressed="false">Not marked</button>
297
+ <button type="button" data-show="marked" aria-pressed="false">Marked</button>
298
+ </div>
299
+ </header>
300
+ ${body}
301
+ </main>
302
+ <div class="bar">
303
+ <div class="bar-in">
304
+ <div><label for="note">Overall, in your words (optional)</label><textarea id="note" placeholder="What the board says, what is missing, what to leave behind"></textarea></div>
305
+ <div><label for="out">Copy this into the chat</label><textarea id="out" readonly></textarea></div>
306
+ <div class="side"><span id="count"></span><button type="button" id="copy">Copy picks</button></div>
307
+ </div>
308
+ </div>
309
+ <script>
310
+ (() => {
311
+ const key = "longbeard-moodboard:" + location.pathname;
312
+ const tiles = [...document.querySelectorAll(".tile")];
313
+ const note = document.getElementById("note");
314
+ const out = document.getElementById("out");
315
+ const count = document.getElementById("count");
316
+ let saved = {};
317
+ try { saved = JSON.parse(localStorage.getItem(key) || "{}"); } catch (e) { saved = {}; }
318
+ // Saved under the card's name, so a card added or dropped and the board
319
+ // rebuilt never moves a mark. A mark an earlier board saved under a running
320
+ // number and the name is still read.
321
+ const tag = (t) => t.dataset.key;
322
+ const old = (t) => t.dataset.id + "|" + t.dataset.title;
323
+ const marks = saved.marks || {};
324
+ const notes = saved.notes || {};
325
+ const read = (from, t) => (tag(t) in from ? from[tag(t)] : from[old(t)]) || "";
326
+ note.value = saved.note || "";
327
+ for (const t of tiles) {
328
+ const mark = read(marks, t);
329
+ if (mark) t.dataset.state = mark;
330
+ // Their words from the picker fill the note until they change it; a note they cleared stays cleared.
331
+ t.querySelector(".why").value = tag(t) in notes || old(t) in notes ? read(notes, t) : t.dataset.like || "";
332
+ }
333
+ let show = "all";
334
+ const short = (s) => (s.length > 48 ? s.slice(0, 47) + "…" : s);
335
+ const label = (t) => t.dataset.id + " " + short(t.dataset.title) + " (" + t.dataset.topic + ")";
336
+ const list = (state) => tiles.filter((t) => t.dataset.state === state).map(label);
337
+ const fams = [...document.querySelectorAll(".fam")];
338
+ const famNotes = [...document.querySelectorAll(".fam-note")];
339
+ if (fams.length) {
340
+ const taken = new Set(saved.taken || []);
341
+ for (const b of fams) if (taken.has(b.dataset.family)) b.setAttribute("aria-pressed", "true");
342
+ for (const i of famNotes) i.value = (saved.famNotes || {})[i.dataset.family] || "";
343
+ }
344
+ function renderFamilies() {
345
+ const taken = fams.filter((b) => b.getAttribute("aria-pressed") === "true").map((b) => b.dataset.family);
346
+ const lines = ["Family picks", "take: " + (taken.join("; ") || "none")];
347
+ const written = famNotes.filter((i) => i.value.trim());
348
+ if (written.length) {
349
+ lines.push("notes:");
350
+ for (const i of written) lines.push("- " + i.dataset.family + ": " + i.value.trim().replace(/\\s+/g, " "));
351
+ }
352
+ if (note.value.trim()) lines.push("note: " + note.value.trim().replace(/\\s+/g, " "));
353
+ out.value = lines.join("\\n");
354
+ count.textContent = taken.length + " of " + fams.length + " families taken";
355
+ const keep = {};
356
+ for (const i of written) keep[i.dataset.family] = i.value;
357
+ try { localStorage.setItem(key, JSON.stringify({ taken, famNotes: keep, note: note.value })); } catch (e) {}
358
+ }
359
+ for (const b of fams) b.addEventListener("click", () => { b.setAttribute("aria-pressed", b.getAttribute("aria-pressed") === "true" ? "false" : "true"); render(); });
360
+ for (const i of famNotes) i.addEventListener("input", () => render());
361
+ function render() {
362
+ if (fams.length) return renderFamilies();
363
+ const lines = ["Moodboard picks", "lead: " + (list("lead").join("; ") || "none"), "like: " + (list("like").join("; ") || "none"), "no: " + (list("no").join("; ") || "none")];
364
+ const written = tiles.filter((t) => t.querySelector(".why").value.trim());
365
+ if (written.length) {
366
+ lines.push("notes:");
367
+ for (const t of written) lines.push("- " + t.dataset.id + " " + short(t.dataset.title) + ": " + t.querySelector(".why").value.trim().replace(/\\s+/g, " "));
368
+ }
369
+ if (note.value.trim()) lines.push("note: " + note.value.trim().replace(/\\s+/g, " "));
370
+ out.value = lines.join("\\n");
371
+ const marked = tiles.filter((t) => t.dataset.state).length;
372
+ count.textContent = list("lead").length + " lead · " + list("like").length + " like · " + list("no").length + " no · " + (tiles.length - marked) + " open";
373
+ const keepMarks = {};
374
+ const keepNotes = {};
375
+ for (const t of tiles) {
376
+ const s = t.dataset.state || "";
377
+ for (const b of t.querySelectorAll(".marks button")) b.setAttribute("aria-pressed", b.dataset.mark === s ? "true" : "false");
378
+ t.hidden = !(show === "all" || (show === "open" ? !s : !!s));
379
+ if (s) keepMarks[tag(t)] = s;
380
+ const w = t.querySelector(".why").value;
381
+ if (w.trim() || t.dataset.like) keepNotes[tag(t)] = w;
382
+ }
383
+ for (const sec of document.querySelectorAll("section")) sec.hidden = ![...sec.querySelectorAll(".tile")].some((t) => !t.hidden);
384
+ try { localStorage.setItem(key, JSON.stringify({ marks: keepMarks, notes: keepNotes, note: note.value })); } catch (e) {}
385
+ }
386
+ for (const t of tiles) {
387
+ for (const b of t.querySelectorAll(".marks button")) {
388
+ b.addEventListener("click", () => {
389
+ const mark = b.dataset.mark;
390
+ if (t.dataset.state === mark) delete t.dataset.state;
391
+ else {
392
+ // One lead per group (a family, or a piece): a new lead turns the old one into a like.
393
+ if (mark === "lead") for (const o of tiles) if (o !== t && o.dataset.topic === t.dataset.topic && o.dataset.state === "lead") o.dataset.state = "like";
394
+ t.dataset.state = mark;
395
+ }
396
+ render();
397
+ });
398
+ }
399
+ t.querySelector(".why").addEventListener("input", render);
400
+ }
401
+ for (const b of document.querySelectorAll(".filters button")) {
402
+ b.addEventListener("click", () => {
403
+ show = b.dataset.show;
404
+ for (const o of document.querySelectorAll(".filters button")) o.setAttribute("aria-pressed", o === b ? "true" : "false");
405
+ render();
406
+ });
407
+ }
408
+ note.addEventListener("input", render);
409
+ // Recorded frames play at the times they were taken, on hover or on Play.
410
+ for (const t of tiles) {
411
+ if (!t.dataset.frames) continue;
412
+ const frames = JSON.parse(t.dataset.frames);
413
+ const img = t.querySelector(".frame img");
414
+ const clock = t.querySelector(".clock");
415
+ const button = t.querySelector(".play");
416
+ const poster = img.getAttribute("src");
417
+ let timer = 0;
418
+ let playing = false;
419
+ for (const f of frames) new Image().src = f.src;
420
+ const stop = () => {
421
+ clearTimeout(timer);
422
+ playing = false;
423
+ img.src = poster;
424
+ clock.textContent = "";
425
+ button.textContent = "Play";
426
+ };
427
+ const step = (i) => {
428
+ img.src = frames[i].src;
429
+ clock.textContent = (frames[i].ms / 1000).toFixed(1) + " s";
430
+ const next = (i + 1) % frames.length;
431
+ const wait = next ? Math.max(80, frames[next].ms - frames[i].ms) : 1200;
432
+ timer = setTimeout(() => step(next), wait);
433
+ };
434
+ const start = () => {
435
+ if (playing) return;
436
+ playing = true;
437
+ button.textContent = "Stop";
438
+ step(0);
439
+ };
440
+ button.addEventListener("click", () => (playing ? stop() : start()));
441
+ // Hover plays only for people who have not asked for less motion; Play always works.
442
+ if (!matchMedia("(prefers-reduced-motion: reduce)").matches) {
443
+ t.querySelector(".frame").addEventListener("mouseenter", start);
444
+ t.querySelector(".frame").addEventListener("mouseleave", stop);
445
+ }
446
+ }
447
+ // The text box is the real path: the clipboard API can be refused on a file:// page.
448
+ document.getElementById("copy").addEventListener("click", async (e) => {
449
+ out.focus();
450
+ out.select();
451
+ let ok = false;
452
+ try { await navigator.clipboard.writeText(out.value); ok = true; } catch (err) {}
453
+ if (!ok) { try { ok = document.execCommand("copy"); } catch (err) {} }
454
+ e.target.textContent = ok ? "Copied" : "Selected, press Cmd/Ctrl+C";
455
+ setTimeout(() => { e.target.textContent = "Copy picks"; }, 1800);
456
+ });
457
+ render();
458
+ })();
459
+ </script>
460
+ </body>
461
+ </html>
462
+ `;
463
+
464
+ mkdirSync(dirname(outPath), { recursive: true });
465
+ writeFileSync(outPath, html);
466
+ console.error(`moodboard: ${n} tiles in ${ordered.length} parts`);
467
+ console.log(outArg);