@jonandev/longbeard 0.12.2 → 0.14.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.
- package/AGENTS.md +5 -6
- package/CHANGELOG.md +51 -0
- package/README.md +3 -4
- package/beard.json +6 -20
- package/bin/long-beard.js +2 -2
- package/package.json +2 -2
- package/skills/design/SKILL.md +21 -37
- package/skills/design-brief/SKILL.md +7 -5
- package/skills/design-check/SKILL.md +1 -1
- package/skills/design-check/references/design-rules.md +28 -5
- package/skills/design-check/scripts/rules.mjs +143 -9
- package/skills/design-content/SKILL.md +2 -0
- package/skills/design-direction/SKILL.md +87 -95
- package/skills/design-direction/references/design-floor.md +118 -0
- package/skills/design-direction/references/graphic.md +5 -10
- package/skills/design-direction/references/library.md +8 -6
- package/skills/design-direction/references/screen-template.html +3 -3
- package/skills/design-direction/references/subject.md +2 -2
- package/skills/design-direction/references/variants.js +43 -0
- package/skills/design-direction/scripts/canvas.mjs +311 -0
- package/skills/design-direction/scripts/colours.mjs +247 -0
- package/skills/design-direction/scripts/moodboard.mjs +233 -93
- package/skills/design-direction/scripts/rules.mjs +747 -0
- package/skills/design-direction/scripts/sheet.mjs +3 -1
- package/skills/design-figma/SKILL.md +3 -1
- package/skills/design-identity/SKILL.md +17 -8
- package/skills/{design-direction → design-identity}/references/controls.md +10 -10
- package/skills/design-identity/references/design-floor.md +118 -0
- package/skills/design-identity/references/identity-board.html +2 -2
- package/skills/design-identity/scripts/colours.mjs +35 -1
- package/skills/design-identity/scripts/sheet.mjs +3 -1
- package/skills/design-moodboard/SKILL.md +44 -76
- package/skills/design-moodboard/references/graphic.md +1 -1
- package/skills/design-moodboard/references/sources.md +12 -1
- package/skills/design-moodboard/scripts/group.mjs +1 -1
- package/skills/design-moodboard/scripts/moodboard.mjs +233 -93
- package/skills/design-prototype/SKILL.md +66 -82
- package/skills/design-prototype/references/design-floor.md +118 -0
- package/skills/design-prototype/references/design-md-template.md +3 -0
- package/skills/design-prototype/references/graphic.md +6 -5
- package/skills/design-prototype/references/variants.js +43 -0
- package/skills/design-prototype/scripts/drift.mjs +273 -0
- package/skills/design-prototype/scripts/links.mjs +5 -4
- package/skills/design-prototype/scripts/rules.mjs +143 -9
- package/skills/design-prototype/scripts/sheet.mjs +3 -1
- package/skills/design-wordmark/SKILL.md +8 -2
- package/skills/design-wordmark/scripts/sheet.mjs +3 -1
- package/skills/idea/SKILL.md +3 -3
- package/skills/design-direction/references/design-rules.md +0 -203
- package/skills/design-direction/references/five-second.md +0 -47
- package/skills/design-direction/references/full-build.md +0 -19
- package/skills/design-direction/references/grid.md +0 -114
- package/skills/design-direction/scripts/layout-diff.mjs +0 -118
- package/skills/design-families/SKILL.md +0 -138
- package/skills/design-families/scripts/contact-sheet.mjs +0 -259
- package/skills/design-families/scripts/families.mjs +0 -607
- package/skills/design-families/scripts/measure.mjs +0 -1728
- package/skills/design-families/scripts/moodboard.mjs +0 -469
- package/skills/design-families/scripts/tag.mjs +0 -289
- package/skills/design-prototype/references/design-rules.md +0 -203
- package/skills/design-prototype/references/five-second.md +0 -47
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// What the key screens use, measured across all of them, so the set can be
|
|
3
|
+
// checked as one design. Opens each page headless at 1440 and reads every
|
|
4
|
+
// visible element's computed style: faces, colours (text, fills, borders),
|
|
5
|
+
// type sizes, corner radii and spacing steps. Node 22+, an installed Chrome,
|
|
6
|
+
// no dependencies.
|
|
7
|
+
//
|
|
8
|
+
// node drift.mjs "file://$PWD/.longbeard/design/prototype/home.html" "file://$PWD/.longbeard/design/prototype/menu.html" --identity docs/design/design-identity.md
|
|
9
|
+
//
|
|
10
|
+
// With --identity (the design-identity doc and its `json identity` block),
|
|
11
|
+
// every face and colour a screen uses that the identity does not have is
|
|
12
|
+
// listed as off, with the screens that use it. Without it, only the counts.
|
|
13
|
+
// Sizes, radii and spacing steps are counted, each with the screens that use
|
|
14
|
+
// it, and a value only one screen uses is marked "one screen": a likely drift,
|
|
15
|
+
// or a device the look needs. It never judges the look: it says what is there.
|
|
16
|
+
//
|
|
17
|
+
// Pictures, SVG drawings and anything marked data-standin are skipped. A
|
|
18
|
+
// colour within 3 of an identity colour on every channel is that colour; a
|
|
19
|
+
// colour drawn at an opacity counts as its colour.
|
|
20
|
+
//
|
|
21
|
+
// Exit 0 nothing off the identity, 1 a face or colour off it, 2 usage, 3 could not run.
|
|
22
|
+
// --width 1440, --wait 300 (ms), --json
|
|
23
|
+
import { spawn } from "node:child_process";
|
|
24
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
25
|
+
import { tmpdir } from "node:os";
|
|
26
|
+
import { join, resolve } from "node:path";
|
|
27
|
+
import { pathToFileURL } from "node:url";
|
|
28
|
+
|
|
29
|
+
const args = process.argv.slice(2);
|
|
30
|
+
const flag = (name, def = "") => {
|
|
31
|
+
const i = args.indexOf(`--${name}`);
|
|
32
|
+
return i === -1 ? def : (args.splice(i, 2)[1] ?? "");
|
|
33
|
+
};
|
|
34
|
+
const has = (name) => {
|
|
35
|
+
const i = args.indexOf(`--${name}`);
|
|
36
|
+
return i === -1 ? false : (args.splice(i, 1), true);
|
|
37
|
+
};
|
|
38
|
+
const identityArg = flag("identity");
|
|
39
|
+
const width = Number(flag("width", "1440"));
|
|
40
|
+
const wait = Number(flag("wait", "300"));
|
|
41
|
+
const json = has("json");
|
|
42
|
+
const urls = args.map((a) => (/^(https?|file):/.test(a) ? a : existsSync(a) ? pathToFileURL(resolve(a)).href : a));
|
|
43
|
+
if (!urls.length || urls.some((u) => !/^(https?|file):/.test(u)) || !(width >= 200 && width <= 3840) || !(wait >= 0 && wait <= 10000)) {
|
|
44
|
+
console.error('usage: node drift.mjs "<url or file>" … [--identity docs/design/design-identity.md] [--width 1440] [--wait 300] [--json]');
|
|
45
|
+
process.exit(2);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ---- the identity ----
|
|
49
|
+
const GENERIC = new Set(["serif", "sans-serif", "monospace", "cursive", "fantasy", "system-ui", "ui-sans-serif", "ui-serif", "ui-monospace", "-apple-system", "blinkmacsystemfont", "emoji", "math"]);
|
|
50
|
+
const hexOf = (s) => {
|
|
51
|
+
const m = String(s || "").trim().match(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
52
|
+
if (!m) return null;
|
|
53
|
+
const h = m[1].length === 3 ? [...m[1]].map((c) => c + c).join("") : m[1];
|
|
54
|
+
return `#${h.toLowerCase()}`;
|
|
55
|
+
};
|
|
56
|
+
const rgbOf = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16));
|
|
57
|
+
let identity = null;
|
|
58
|
+
if (identityArg) {
|
|
59
|
+
if (!existsSync(identityArg)) {
|
|
60
|
+
console.error(`drift: no identity at ${identityArg}`);
|
|
61
|
+
process.exit(2);
|
|
62
|
+
}
|
|
63
|
+
const block = readFileSync(identityArg, "utf8").match(/```json identity\s*\n([\s\S]*?)```/);
|
|
64
|
+
if (!block) {
|
|
65
|
+
console.error(`drift: ${identityArg} has no \`json identity\` block`);
|
|
66
|
+
process.exit(2);
|
|
67
|
+
}
|
|
68
|
+
let parsed;
|
|
69
|
+
try {
|
|
70
|
+
parsed = JSON.parse(block[1]);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
console.error(`drift: the json identity block in ${identityArg} could not be read: ${e.message}`);
|
|
73
|
+
process.exit(2);
|
|
74
|
+
}
|
|
75
|
+
const faces = [parsed.display?.face, parsed.body?.face, ...(parsed.faces || []).map((f) => f.face || f)].filter(Boolean).map((f) => String(f).toLowerCase());
|
|
76
|
+
const colours = (parsed.colours || []).map((c) => ({ name: c.name || "", hex: hexOf(c.hex) })).filter((c) => c.hex);
|
|
77
|
+
identity = { faces: new Set(faces), colours };
|
|
78
|
+
}
|
|
79
|
+
const near = (hex) => identity?.colours.find((c) => rgbOf(c.hex).every((v, i) => Math.abs(v - rgbOf(hex)[i]) <= 3));
|
|
80
|
+
|
|
81
|
+
// ---- the browser ----
|
|
82
|
+
let finished = false;
|
|
83
|
+
function couldNot(why) {
|
|
84
|
+
if (finished) return;
|
|
85
|
+
finished = true;
|
|
86
|
+
console.error(`drift: could not run: ${why}`);
|
|
87
|
+
console.log("not checked: drift (" + why + "). Report it as not checked, never as passed.");
|
|
88
|
+
process.exit(3);
|
|
89
|
+
}
|
|
90
|
+
const watchdog = setTimeout(() => couldNot("the run took more than 120 s"), 120000);
|
|
91
|
+
function findChrome() {
|
|
92
|
+
const env = process.env.CHROME_PATH;
|
|
93
|
+
if (env === "none") return null;
|
|
94
|
+
if (env && existsSync(env)) return env;
|
|
95
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
96
|
+
const pf = process.env.PROGRAMFILES || "C:\\Program Files";
|
|
97
|
+
return [
|
|
98
|
+
join(pf, "Google/Chrome/Application/chrome.exe"),
|
|
99
|
+
join(process.env.LOCALAPPDATA || "", "Google/Chrome/Application/chrome.exe"),
|
|
100
|
+
join(pf, "Microsoft/Edge/Application/msedge.exe"),
|
|
101
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
102
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
103
|
+
join(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
|
|
104
|
+
"/usr/bin/google-chrome",
|
|
105
|
+
"/usr/bin/google-chrome-stable",
|
|
106
|
+
"/usr/bin/chromium",
|
|
107
|
+
"/usr/bin/chromium-browser",
|
|
108
|
+
].find((path) => path && existsSync(path));
|
|
109
|
+
}
|
|
110
|
+
const exe = findChrome();
|
|
111
|
+
if (!exe) couldNot("No Chrome/Edge/Chromium found. Install one or set CHROME_PATH.");
|
|
112
|
+
const dir = mkdtempSync(join(tmpdir(), "drift-"));
|
|
113
|
+
const proc = spawn(exe, ["--headless=new", "--remote-debugging-port=0", `--user-data-dir=${dir}`, "--no-first-run", "--hide-scrollbars", "--allow-file-access-from-files", "about:blank"], { stdio: ["ignore", "ignore", "pipe"] });
|
|
114
|
+
process.once("exit", () => {
|
|
115
|
+
try {
|
|
116
|
+
proc.kill("SIGKILL");
|
|
117
|
+
} catch {}
|
|
118
|
+
try {
|
|
119
|
+
rmSync(dir, { recursive: true, force: true });
|
|
120
|
+
} catch {}
|
|
121
|
+
});
|
|
122
|
+
let buf = "";
|
|
123
|
+
const wsUrl = await new Promise((done, no) => {
|
|
124
|
+
const t = setTimeout(() => no(new Error("Chrome did not start within 20 s")), 20000);
|
|
125
|
+
proc.on("error", (e) => no(e));
|
|
126
|
+
proc.stderr.on("data", (d) => {
|
|
127
|
+
const m = (buf += d).match(/DevTools listening on (ws:\/\/\S+)/);
|
|
128
|
+
if (m) done(m[1], clearTimeout(t));
|
|
129
|
+
});
|
|
130
|
+
}).catch((e) => couldNot(e.message));
|
|
131
|
+
const ws = new WebSocket(wsUrl);
|
|
132
|
+
await new Promise((done, no) => {
|
|
133
|
+
const t = setTimeout(() => no(new Error("Chrome did not answer within 10 s")), 10000);
|
|
134
|
+
ws.onopen = () => done(clearTimeout(t));
|
|
135
|
+
ws.onerror = () => no(new Error("could not connect to Chrome"));
|
|
136
|
+
}).catch((e) => couldNot(e.message));
|
|
137
|
+
let nextId = 0;
|
|
138
|
+
const pending = new Map();
|
|
139
|
+
ws.onmessage = (ev) => {
|
|
140
|
+
const msg = JSON.parse(String(ev.data));
|
|
141
|
+
if (pending.has(msg.id)) pending.get(msg.id)(msg), pending.delete(msg.id);
|
|
142
|
+
};
|
|
143
|
+
const send = (method, params = {}, sessionId, ms = 15000) =>
|
|
144
|
+
new Promise((done, no) => {
|
|
145
|
+
const id = ++nextId;
|
|
146
|
+
const t = setTimeout(() => (pending.delete(id), no(new Error(`${method} took more than ${ms / 1000} s`))), ms);
|
|
147
|
+
pending.set(id, (m) => (clearTimeout(t), m.error ? no(new Error(`${method}: ${m.error.message}`)) : done(m)));
|
|
148
|
+
ws.send(JSON.stringify({ id, method, params, sessionId }));
|
|
149
|
+
});
|
|
150
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
151
|
+
|
|
152
|
+
// Sent to the page as text: it may use nothing outside itself.
|
|
153
|
+
function readPage() {
|
|
154
|
+
const out = { faces: [], colours: [], sizes: [], radii: [], steps: [] };
|
|
155
|
+
const toHex = (c) => {
|
|
156
|
+
const m = c.match(/rgba?\(([^)]+)\)/);
|
|
157
|
+
if (!m) return null;
|
|
158
|
+
const p = m[1].split(/[ ,/]+/).filter(Boolean).map(Number);
|
|
159
|
+
const a = p.length > 3 ? p[3] : 1;
|
|
160
|
+
if (!(a > 0)) return null;
|
|
161
|
+
return { hex: "#" + p.slice(0, 3).map((v) => Math.round(v).toString(16).padStart(2, "0")).join(""), a: Math.round(a * 100) / 100 };
|
|
162
|
+
};
|
|
163
|
+
const px = (v) => Math.round(parseFloat(v) * 2) / 2;
|
|
164
|
+
for (const el of document.querySelectorAll("body *")) {
|
|
165
|
+
if (el.closest("svg, picture, video, canvas, [data-standin], script, style, noscript, template")) continue;
|
|
166
|
+
if (el.tagName === "IMG") continue;
|
|
167
|
+
const r = el.getBoundingClientRect();
|
|
168
|
+
if (!(r.width > 0 && r.height > 0)) continue;
|
|
169
|
+
const cs = getComputedStyle(el);
|
|
170
|
+
if (cs.visibility === "hidden" || cs.display === "none" || Number(cs.opacity) === 0) continue;
|
|
171
|
+
const hasText = [...el.childNodes].some((n) => n.nodeType === 3 && n.textContent.trim());
|
|
172
|
+
if (hasText) {
|
|
173
|
+
out.faces.push(cs.fontFamily.split(",")[0].trim().replace(/^["']|["']$/g, ""));
|
|
174
|
+
out.sizes.push(px(cs.fontSize));
|
|
175
|
+
const c = toHex(cs.color);
|
|
176
|
+
if (c) out.colours.push({ ...c, as: "text" });
|
|
177
|
+
}
|
|
178
|
+
const bg = toHex(cs.backgroundColor);
|
|
179
|
+
if (bg) out.colours.push({ ...bg, as: "fill" });
|
|
180
|
+
for (const side of ["Top", "Right", "Bottom", "Left"]) {
|
|
181
|
+
if (parseFloat(cs[`border${side}Width`]) > 0 && cs[`border${side}Style`] !== "none") {
|
|
182
|
+
const b = toHex(cs[`border${side}Color`]);
|
|
183
|
+
if (b) out.colours.push({ ...b, as: "border" });
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
const radius = px(cs.borderTopLeftRadius);
|
|
188
|
+
if (radius > 0 && radius < 9999) out.radii.push(radius >= r.height / 2 - 1 && radius >= r.width / 2 - 1 ? "round" : radius >= r.height / 2 - 1 ? "pill" : radius);
|
|
189
|
+
for (const v of [cs.rowGap, cs.columnGap, cs.paddingTop, cs.paddingLeft, cs.marginTop, cs.marginBottom]) {
|
|
190
|
+
const n = px(v);
|
|
191
|
+
if (n > 0) out.steps.push(n);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return out;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const target = await send("Target.createTarget", { url: "about:blank" }).catch((e) => couldNot(e.message));
|
|
198
|
+
const { sessionId } = (await send("Target.attachToTarget", { targetId: target.result.targetId, flatten: true }).catch((e) => couldNot(e.message))).result;
|
|
199
|
+
await send("Page.enable", {}, sessionId);
|
|
200
|
+
await send("Runtime.enable", {}, sessionId);
|
|
201
|
+
await send("Emulation.setDeviceMetricsOverride", { width, height: 900, deviceScaleFactor: 1, mobile: false }, sessionId);
|
|
202
|
+
|
|
203
|
+
const screens = [];
|
|
204
|
+
for (const url of urls) {
|
|
205
|
+
const name = decodeURIComponent(url.split(/[?#]/)[0].split("/").pop() || url).replace(/\.html?$/, "") + (url.includes("?") ? "?" + url.split("?")[1] : "");
|
|
206
|
+
try {
|
|
207
|
+
const loaded = new Promise((done) => {
|
|
208
|
+
const prev = ws.onmessage;
|
|
209
|
+
ws.onmessage = (ev) => {
|
|
210
|
+
prev(ev);
|
|
211
|
+
const msg = JSON.parse(String(ev.data));
|
|
212
|
+
if (msg.method === "Page.loadEventFired" && msg.sessionId === sessionId) (ws.onmessage = prev), done();
|
|
213
|
+
};
|
|
214
|
+
});
|
|
215
|
+
await send("Page.navigate", { url }, sessionId);
|
|
216
|
+
await Promise.race([loaded, sleep(15000)]);
|
|
217
|
+
await send("Runtime.evaluate", { expression: "document.fonts ? document.fonts.ready.then(() => true) : true", awaitPromise: true }, sessionId).catch(() => {});
|
|
218
|
+
await sleep(wait);
|
|
219
|
+
const res = await send("Runtime.evaluate", { expression: `(${readPage})()`, returnByValue: true }, sessionId);
|
|
220
|
+
if (res.result.exceptionDetails) throw new Error(res.result.exceptionDetails.text);
|
|
221
|
+
screens.push({ name, ...res.result.result.value });
|
|
222
|
+
} catch (e) {
|
|
223
|
+
screens.push({ name, failed: e.message });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
clearTimeout(watchdog);
|
|
227
|
+
finished = true;
|
|
228
|
+
|
|
229
|
+
// ---- the report ----
|
|
230
|
+
const tally = (key, norm = (v) => v) => {
|
|
231
|
+
const map = new Map();
|
|
232
|
+
for (const s of screens) {
|
|
233
|
+
if (s.failed) continue;
|
|
234
|
+
for (const v of s[key]) {
|
|
235
|
+
const k = norm(v);
|
|
236
|
+
if (k == null) continue;
|
|
237
|
+
if (!map.has(k)) map.set(k, new Set());
|
|
238
|
+
map.get(k).add(s.name);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return [...map.entries()].map(([value, on]) => ({ value, screens: [...on] }));
|
|
242
|
+
};
|
|
243
|
+
const read = screens.filter((s) => !s.failed);
|
|
244
|
+
const faces = tally("faces", (f) => (GENERIC.has(f.toLowerCase()) ? null : f));
|
|
245
|
+
const colours = tally("colours", (c) => {
|
|
246
|
+
const same = near(c.hex);
|
|
247
|
+
return same ? `${same.hex}${same.name ? ` ${same.name}` : ""}` : c.hex;
|
|
248
|
+
});
|
|
249
|
+
const sizes = tally("sizes").sort((a, b) => a.value - b.value);
|
|
250
|
+
const radii = tally("radii").sort((a, b) => String(a.value).localeCompare(String(b.value), undefined, { numeric: true }));
|
|
251
|
+
const steps = tally("steps").sort((a, b) => a.value - b.value);
|
|
252
|
+
const offFaces = identity ? faces.filter((f) => !identity.faces.has(String(f.value).toLowerCase())) : [];
|
|
253
|
+
const offColours = identity ? colours.filter((c) => !near(String(c.value).split(" ")[0])) : [];
|
|
254
|
+
const report = { screens: screens.map((s) => (s.failed ? { name: s.name, failed: s.failed } : { name: s.name })), identity: Boolean(identity), offFaces, offColours, faces, colours, sizes, radii, steps };
|
|
255
|
+
|
|
256
|
+
if (json) console.log(JSON.stringify(report, null, 1));
|
|
257
|
+
else {
|
|
258
|
+
const one = (r) => (read.length > 1 && r.screens.length === 1 ? ` (one screen: ${r.screens[0]})` : "");
|
|
259
|
+
const line = (label, list, unit = "") => `${label} ${list.length}: ${list.map((r) => `${r.value}${typeof r.value === "number" ? unit : ""}${one(r)}`).join(", ") || "none"}`;
|
|
260
|
+
console.log(`Drift across ${read.length} screen${read.length === 1 ? "" : "s"} at ${width}px${identity ? `, against ${identityArg}` : ""}`);
|
|
261
|
+
for (const s of screens.filter((s) => s.failed)) console.log(`not checked: ${s.name} (${s.failed})`);
|
|
262
|
+
if (identity) {
|
|
263
|
+
console.log(offFaces.length || offColours.length ? "Off the identity:" : "Off the identity: nothing");
|
|
264
|
+
for (const f of offFaces) console.log(`- face ${f.value}: ${f.screens.join(", ")}`);
|
|
265
|
+
for (const c of offColours) console.log(`- colour ${c.value}: ${c.screens.join(", ")}`);
|
|
266
|
+
}
|
|
267
|
+
console.log(line("Faces", faces));
|
|
268
|
+
console.log(line("Colours", colours));
|
|
269
|
+
console.log(line("Type sizes", sizes, "px"));
|
|
270
|
+
console.log(line("Radii", radii, "px"));
|
|
271
|
+
console.log(line("Spacing steps", steps, "px"));
|
|
272
|
+
}
|
|
273
|
+
process.exit(screens.some((s) => s.failed) && !read.length ? 3 : offFaces.length || offColours.length ? 1 : 0);
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Scan a clickable prototype: every page in its folder, from its first page on, for
|
|
3
3
|
// links that break and pages with no way on, and for what it still stands in for.
|
|
4
|
-
// Whether a person can reach each screen is the flow walks' job, not this one's.
|
|
5
4
|
// Node 22+, an installed Chrome, no dependencies.
|
|
6
5
|
//
|
|
7
6
|
// node links.mjs "file://$PWD/.longbeard/design/prototype/home.html"
|
|
8
7
|
//
|
|
9
8
|
// Pages are rendered (links a script builds count). Links are followed from the first page, then
|
|
10
9
|
// every other page in the prototype's folder is opened too, so a page behind a state (an empty
|
|
11
|
-
// basket) is still scanned. A link elsewhere (a real site, mailto:) is listed, never followed. A form that submits to another page is a way on, and so is
|
|
10
|
+
// basket) is still scanned. A sheet of screenshots that sheet.mjs made there is skipped. A link elsewhere (a real site, mailto:) is listed, never followed. A form that submits to another page is a way on, and so is
|
|
12
11
|
// a button whose script navigates: each is clicked, and the page it lands on is followed. A query (?state=empty) or a hash is the same page, but the
|
|
13
12
|
// page is opened with the query it was first reached by, so state a prototype keeps in
|
|
14
13
|
// the address (a basket, a chosen slot) carries on as it does for a person.
|
|
@@ -238,8 +237,10 @@ const seen = new Set([startPath]);
|
|
|
238
237
|
const firstUrl = new Map([[startPath, start.split("#")[0]]]);
|
|
239
238
|
const queue = [startPath];
|
|
240
239
|
const broken = [], nowhere = [], deadEnds = [], outside = new Set();
|
|
241
|
-
// When the links run out, every page in the folder not reached yet is opened by itself
|
|
242
|
-
|
|
240
|
+
// When the links run out, every page in the folder not reached yet is opened by itself,
|
|
241
|
+
// except a sheet of screenshots (sheet.mjs marks it): it shows the prototype, it is not a page of it.
|
|
242
|
+
const isSheet = (path) => { try { return /<meta name="generator" content="longbeard sheet">/.test(readFileSync(path, "utf8")); } catch { return false; } };
|
|
243
|
+
const rest = () => readdirSync(dirname(startPath)).filter((f) => /\.html?$/i.test(f)).sort().map((f) => join(dirname(startPath), f)).filter((p) => !seen.has(p) && !isSheet(p));
|
|
243
244
|
while (queue.length || (queue.push(...rest().slice(0, 1)), queue.length)) {
|
|
244
245
|
const path = queue.shift();
|
|
245
246
|
seen.add(path);
|
|
@@ -18,6 +18,15 @@
|
|
|
18
18
|
// 11 Copy no lorem ipsum, and no text that is only "Title", "Button", "User Name"...
|
|
19
19
|
// 5 Typography text cut by its container, including an ellipsis. Text cut on purpose
|
|
20
20
|
// carries data-crop on the element (or one above it) and is skipped
|
|
21
|
+
// 5 Typography text size: nothing under 12px; text a person acts on (links, buttons,
|
|
22
|
+
// labels, fields, navigation) at least 14px; body (running text of 60
|
|
23
|
+
// characters or more) at least 16px. Text marked data-board-size (on it or
|
|
24
|
+
// above it: the board shows it that small and the person kept it) is a
|
|
25
|
+
// warning with its measure, not a block
|
|
26
|
+
// Soft (reported, never blocking):
|
|
27
|
+
// 6 Colour proportion on the first screen, text and pictures left out: the ground
|
|
28
|
+
// (the largest colour) under 50%, or the accent over 20% (--accent "#hex"
|
|
29
|
+
// names it; else the most saturated colour). A board that does otherwise wins
|
|
21
30
|
// Not checked, on purpose: overlap, collision, alignment, empty space, section height. They are
|
|
22
31
|
// the look's own moves. Not checked either: contrast (screen-contrast.mjs), states, hierarchy.
|
|
23
32
|
//
|
|
@@ -37,7 +46,8 @@
|
|
|
37
46
|
// run. A check that could not run is "not checked", never passed. The first failure on a screen
|
|
38
47
|
// says what to do; the second says to report it as not checked and go on.
|
|
39
48
|
// --widths 1440,390, --screen name, --app, --cookie "a=b; c=d", --wait 300 (ms), --timeout 120000
|
|
40
|
-
// (ms for the whole run; every browser call also has its own 15 s limit), --rounds 2, --dir,
|
|
49
|
+
// (ms for the whole run; every browser call also has its own 15 s limit), --rounds 2, --dir,
|
|
50
|
+
// --accent "#hex" (the accent from DESIGN.md, for the proportion), --json
|
|
41
51
|
import { spawn } from "node:child_process";
|
|
42
52
|
import { createHash } from "node:crypto";
|
|
43
53
|
import { existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
|
|
@@ -65,11 +75,12 @@ const reason = flag("reason");
|
|
|
65
75
|
const shipWords = flag("ship");
|
|
66
76
|
const app = has("app");
|
|
67
77
|
const json = has("json");
|
|
78
|
+
const accentArg = flag("accent");
|
|
68
79
|
const [url] = args;
|
|
69
|
-
const usage = 'usage: node rules.mjs "<file:// or http(s):// url>" [--screen name] [--widths 1440,390] [--app] [--cookie "a=b"] [--wait 300] [--timeout 120000] [--rounds 2] [--dir .longbeard/design] [--json]\n node rules.mjs --screen name --waive <id> --reason "why this finding is false"\n node rules.mjs --screen name --ship "the person\'s words"';
|
|
80
|
+
const usage = 'usage: node rules.mjs "<file:// or http(s):// url>" [--screen name] [--widths 1440,390] [--app] [--cookie "a=b"] [--wait 300] [--timeout 120000] [--rounds 2] [--dir .longbeard/design] [--accent "#hex"] [--json]\n node rules.mjs --screen name --waive <id> --reason "why this finding is false"\n node rules.mjs --screen name --ship "the person\'s words"';
|
|
70
81
|
const recording = Boolean(waiveId || shipWords);
|
|
71
82
|
const usageOk = recording ? Boolean(screenArg || url) && args.length <= 1 : url && args.length === 1 && /^(https?|file):/.test(url);
|
|
72
|
-
if (!usageOk || widths.some((w) => !(w >= 200 && w <= 3840)) || !(wait >= 0 && wait <= 10000) || !(totalMs >= 5000) || !(limit >= 1) || (waiveId && shipWords) || (reason && !waiveId)) {
|
|
83
|
+
if (!usageOk || widths.some((w) => !(w >= 200 && w <= 3840)) || !(wait >= 0 && wait <= 10000) || !(totalMs >= 5000) || !(limit >= 1) || (waiveId && shipWords) || (reason && !waiveId) || (accentArg && !/^#?[0-9a-f]{6}$/i.test(accentArg))) {
|
|
73
84
|
console.error(usage);
|
|
74
85
|
process.exit(2);
|
|
75
86
|
}
|
|
@@ -125,7 +136,7 @@ if (shipWords) {
|
|
|
125
136
|
console.error(`rules: ${screen} has not been checked yet. Run it once, so the open findings are on record.`);
|
|
126
137
|
process.exit(2);
|
|
127
138
|
}
|
|
128
|
-
record.closed = { words: shipWords.trim(), at: today(), open: record.found.filter((f) => !waivers.some((w) => w.screen === screen && w.id === f.id)) };
|
|
139
|
+
record.closed = { words: shipWords.trim(), at: today(), open: record.found.filter((f) => (f.level || "hard") === "hard" && !waivers.some((w) => w.screen === screen && w.id === f.id)) };
|
|
129
140
|
rounds[screen] = record;
|
|
130
141
|
writeJson(roundsFile, rounds);
|
|
131
142
|
console.log(`${screen} closed by the person: "${record.closed.words}". Open findings, to report as open:`);
|
|
@@ -430,9 +441,102 @@ function staticChecks(opt) {
|
|
|
430
441
|
}
|
|
431
442
|
});
|
|
432
443
|
|
|
444
|
+
// 5: text size. Nothing under 12px; what a person acts on 14px; body 16px.
|
|
445
|
+
run("5 size", () => {
|
|
446
|
+
const act = 'a, button, label, input, select, textarea, summary, legend, nav, [role=button], [role=link], [role=tab], [role=menuitem], [role=option]';
|
|
447
|
+
const done = new Set();
|
|
448
|
+
const size = (el) => parseFloat(getComputedStyle(el).fontSize);
|
|
449
|
+
const judge = (el, text) => {
|
|
450
|
+
if (done.has(el)) return;
|
|
451
|
+
done.add(el);
|
|
452
|
+
const px = size(el);
|
|
453
|
+
const acts = !!el.closest(act);
|
|
454
|
+
const block = el.closest("p, li, dd, blockquote");
|
|
455
|
+
const body = !acts && block && !el.closest("figcaption, small, footer, aside, sup, sub") && (block.innerText || "").trim().length >= 60;
|
|
456
|
+
const [floor, role] = acts ? [14, "text a person acts on"] : body ? [16, "body text"] : [12, "text"];
|
|
457
|
+
if (px >= floor - 0.05) return;
|
|
458
|
+
const board = !!el.closest("[data-board-size]");
|
|
459
|
+
found.push({ rule: "5 Typography", check: "size", level: board ? "warn" : "hard", path: path(el), desc: desc(el), detail: `${Math.round(px * 10) / 10}px ${role}, floor ${floor}px${board ? " (data-board-size: the board's size, kept)" : ""}` });
|
|
460
|
+
};
|
|
461
|
+
const walker = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);
|
|
462
|
+
for (let n = walker.nextNode(); n; n = walker.nextNode()) {
|
|
463
|
+
const el = n.parentElement;
|
|
464
|
+
if (!el || !n.textContent.trim() || el instanceof SVGElement || /^(SCRIPT|STYLE|NOSCRIPT|TEMPLATE|OPTION)$/.test(el.tagName) || !visible(el)) continue;
|
|
465
|
+
const box = el.getBoundingClientRect();
|
|
466
|
+
if (box.width <= 2 || box.height <= 2) continue; // visually hidden text, read by screen readers
|
|
467
|
+
judge(el);
|
|
468
|
+
}
|
|
469
|
+
for (const el of document.body.querySelectorAll("input:not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea")) if (visible(el)) judge(el);
|
|
470
|
+
});
|
|
471
|
+
|
|
433
472
|
return { found, notChecked };
|
|
434
473
|
}
|
|
435
474
|
|
|
475
|
+
// Colour proportion of the first screen, from a shot with the text hidden. Pictures are left out.
|
|
476
|
+
// Returns { shares: [{ hex, share, chroma }], ground, accent } in shares of the pixels counted.
|
|
477
|
+
async function colourProportion(opt) {
|
|
478
|
+
const out = [];
|
|
479
|
+
for (const el of document.body.querySelectorAll("*")) {
|
|
480
|
+
const s = getComputedStyle(el);
|
|
481
|
+
if (el.matches("img, video, canvas, picture, iframe, svg image, object, embed") || /url\(/.test(s.backgroundImage)) {
|
|
482
|
+
const r = el.getBoundingClientRect();
|
|
483
|
+
if (r.width >= 1 && r.height >= 1) out.push(r);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
const img = new Image();
|
|
487
|
+
img.src = `data:image/png;base64,${opt.png}`;
|
|
488
|
+
await img.decode();
|
|
489
|
+
const c = document.createElement("canvas");
|
|
490
|
+
c.width = img.naturalWidth;
|
|
491
|
+
c.height = img.naturalHeight;
|
|
492
|
+
const g = c.getContext("2d", { willReadFrequently: true });
|
|
493
|
+
g.drawImage(img, 0, 0);
|
|
494
|
+
const px = g.getImageData(0, 0, c.width, c.height).data;
|
|
495
|
+
const lin = (v) => ((v /= 255) <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4);
|
|
496
|
+
const lab = (r, gr, b) => {
|
|
497
|
+
const [R, G, B] = [lin(r), lin(gr), lin(b)];
|
|
498
|
+
const l = Math.cbrt(0.4122214708 * R + 0.5363325363 * G + 0.0514459929 * B), m = Math.cbrt(0.2119034982 * R + 0.6806995451 * G + 0.1073969566 * B), s2 = Math.cbrt(0.0883024619 * R + 0.2817188376 * G + 0.6299787005 * B);
|
|
499
|
+
return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s2, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s2, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s2];
|
|
500
|
+
};
|
|
501
|
+
const buckets = new Map();
|
|
502
|
+
let total = 0;
|
|
503
|
+
const step = 2;
|
|
504
|
+
for (let y = 0; y < c.height; y += step)
|
|
505
|
+
for (let x = 0; x < c.width; x += step) {
|
|
506
|
+
if (out.some((r) => x >= r.left && x < r.right && y >= r.top && y < r.bottom)) continue;
|
|
507
|
+
const i = (y * c.width + x) * 4;
|
|
508
|
+
const key = ((px[i] >> 3) << 10) | ((px[i + 1] >> 3) << 5) | (px[i + 2] >> 3);
|
|
509
|
+
const b = buckets.get(key) || { n: 0, r: px[i], g: px[i + 1], b: px[i + 2] };
|
|
510
|
+
b.n++;
|
|
511
|
+
buckets.set(key, b);
|
|
512
|
+
total++;
|
|
513
|
+
}
|
|
514
|
+
if (!total) return { shares: [], ground: null, accent: null };
|
|
515
|
+
// Near colours are one colour: a bucket joins the biggest cluster within a small distance.
|
|
516
|
+
const clusters = [];
|
|
517
|
+
for (const b of [...buckets.values()].sort((a, z) => z.n - a.n)) {
|
|
518
|
+
const L = lab(b.r, b.g, b.b);
|
|
519
|
+
const near = clusters.find((k) => Math.hypot(k.lab[0] - L[0], k.lab[1] - L[1], k.lab[2] - L[2]) < 0.06);
|
|
520
|
+
if (near) near.n += b.n;
|
|
521
|
+
else clusters.push({ n: b.n, lab: L, rgb: [b.r, b.g, b.b] });
|
|
522
|
+
}
|
|
523
|
+
const hex = (rgb) => `#${rgb.map((v) => v.toString(16).padStart(2, "0")).join("")}`;
|
|
524
|
+
const shares = clusters.sort((a, z) => z.n - a.n).map((k) => ({ hex: hex(k.rgb), share: k.n / total, chroma: Math.hypot(k.lab[1], k.lab[2]), lab: k.lab }));
|
|
525
|
+
const ground = shares[0];
|
|
526
|
+
let accent = null;
|
|
527
|
+
if (opt.accent) {
|
|
528
|
+
const h = opt.accent.replace("#", "");
|
|
529
|
+
const A = lab(parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16));
|
|
530
|
+
const near = shares.filter((k) => Math.hypot(k.lab[0] - A[0], k.lab[1] - A[1], k.lab[2] - A[2]) < 0.06);
|
|
531
|
+
accent = { hex: `#${h.toLowerCase()}`, share: near.reduce((a, k) => a + k.share, 0), named: true };
|
|
532
|
+
} else {
|
|
533
|
+
// Unnamed, the accent is the most saturated colour other than the ground.
|
|
534
|
+
const pick = shares.slice(1).filter((k) => k.chroma >= 0.1 && k.share >= 0.005).sort((a, z) => z.chroma - a.chroma)[0];
|
|
535
|
+
if (pick) accent = { hex: pick.hex, share: pick.share, named: false };
|
|
536
|
+
}
|
|
537
|
+
return { shares: shares.slice(0, 4).map(({ hex: h, share }) => ({ hex: h, share })), ground: { hex: ground.hex, share: ground.share }, accent };
|
|
538
|
+
}
|
|
539
|
+
|
|
436
540
|
// The focus check. Called once to take the baseline, then after each Tab.
|
|
437
541
|
function focusBaseline() {
|
|
438
542
|
const sig = (el) => {
|
|
@@ -494,10 +598,13 @@ const FIX = {
|
|
|
494
598
|
focus: "Give it a visible :focus-visible style with 3:1 contrast against what is around it (an outline or ring). Never outline: none alone.",
|
|
495
599
|
placeholder: "Write the real copy, in the product's voice.",
|
|
496
600
|
clipped: "Let the box grow or the text wrap, so no word is cut. If the cut is the look, mark that element data-crop.",
|
|
601
|
+
size: "Scale the step up, keeping the reference's proportions between sizes. If the board shows it this small and the person kept it, mark it data-board-size.",
|
|
602
|
+
proportion: "Let the ground dominate, the primary support and the accent stay small (about 60/30/10). If the board clearly does otherwise, keep it and say so in a note.",
|
|
497
603
|
};
|
|
498
604
|
const RULE_OF = { focus: "10 Accessibility" };
|
|
499
605
|
const found = new Map();
|
|
500
606
|
const notChecked = [];
|
|
607
|
+
const proportions = [];
|
|
501
608
|
const checkedAt = new Map();
|
|
502
609
|
const evaluate = async (expression, call) => {
|
|
503
610
|
const r = await call("Runtime.evaluate", { expression, returnByValue: true, awaitPromise: true });
|
|
@@ -521,7 +628,7 @@ try {
|
|
|
521
628
|
}
|
|
522
629
|
const record1 = (item, w, check) => {
|
|
523
630
|
const key = `${item.rule || RULE_OF[check] || ""}|${check}|${item.path}`;
|
|
524
|
-
if (!found.has(key)) found.set(key, { rule: item.rule || RULE_OF[check], check, path: item.path, desc: item.desc, detail: item.detail || "", widths: [] });
|
|
631
|
+
if (!found.has(key)) found.set(key, { rule: item.rule || RULE_OF[check], check, level: item.level || "hard", path: item.path, desc: item.desc, detail: item.detail || "", widths: [] });
|
|
525
632
|
const f = found.get(key);
|
|
526
633
|
if (!f.widths.includes(w)) f.widths.push(w);
|
|
527
634
|
};
|
|
@@ -554,6 +661,25 @@ try {
|
|
|
554
661
|
} catch (e) {
|
|
555
662
|
notChecked.push({ check: "10 focus", width: w, why: String(e.message).slice(0, 80) });
|
|
556
663
|
}
|
|
664
|
+
// Colour proportion, last: it hides the text. The first screen only, as a person meets it.
|
|
665
|
+
try {
|
|
666
|
+
await evaluate(`(() => {
|
|
667
|
+
window.scrollTo(0, 0);
|
|
668
|
+
if (document.activeElement) document.activeElement.blur();
|
|
669
|
+
const s = document.createElement("style");
|
|
670
|
+
s.textContent = "* { color: transparent !important; text-shadow: none !important; -webkit-text-fill-color: transparent !important; text-decoration-color: transparent !important; caret-color: transparent !important; outline: none !important; }";
|
|
671
|
+
document.head.appendChild(s);
|
|
672
|
+
return new Promise((done) => requestAnimationFrame(() => requestAnimationFrame(() => done(true))));
|
|
673
|
+
})()`, call);
|
|
674
|
+
const shot = await call("Page.captureScreenshot", { format: "png" });
|
|
675
|
+
const p = await evaluate(`(${colourProportion})(${JSON.stringify({ png: shot.result.data, accent: accentArg })})`, call);
|
|
676
|
+
proportions.push({ width: w, ...p });
|
|
677
|
+
const pct = (x) => `${Math.round(x * 100)}%`;
|
|
678
|
+
if (p.ground && p.ground.share < 0.5) record1({ rule: "6 Colour", level: "soft", path: "ground", desc: "first screen", detail: `the ground (${p.ground.hex}) covers ${pct(p.ground.share)}; it should dominate (about 60%)` }, w, "proportion");
|
|
679
|
+
if (p.accent && p.accent.share > 0.2) record1({ rule: "6 Colour", level: "soft", path: "accent", desc: "first screen", detail: `the accent (${p.accent.hex}${p.accent.named ? "" : ", read as the most saturated colour"}) covers ${pct(p.accent.share)}; it should stay small (about 10%)` }, w, "proportion");
|
|
680
|
+
} catch (e) {
|
|
681
|
+
notChecked.push({ check: "6 proportion", width: w, why: String(e.message).slice(0, 80) });
|
|
682
|
+
}
|
|
557
683
|
checkedAt.set(w, true);
|
|
558
684
|
}
|
|
559
685
|
ws.close();
|
|
@@ -567,7 +693,9 @@ finished = true;
|
|
|
567
693
|
const id = (f) => createHash("sha1").update(`${f.rule}|${f.check}|${f.path}`).digest("hex").slice(0, 6);
|
|
568
694
|
const rows = [...found.values()].map((f) => ({ ...f, id: id(f), where: `${f.desc}: ${f.detail} (at ${f.widths.sort((a, b) => b - a).join(", ")})` }));
|
|
569
695
|
const waived = rows.filter((f) => waivers.some((w) => w.screen === screen && w.id === f.id));
|
|
570
|
-
|
|
696
|
+
// Hard findings block. Warnings (the board's own small text) and soft ones are reported only.
|
|
697
|
+
const open = rows.filter((f) => !waived.includes(f) && f.level === "hard");
|
|
698
|
+
const reported = rows.filter((f) => !waived.includes(f) && f.level !== "hard");
|
|
571
699
|
|
|
572
700
|
// A run on a changed page is a round; the same page again is the same round. Each url of a screen
|
|
573
701
|
// (a state: ?menu=open) keeps its own fingerprint, so the first look at another state is part of
|
|
@@ -580,15 +708,15 @@ const changed = seen && fps[key] !== fingerprint;
|
|
|
580
708
|
const round = !used ? 1 : changed && used < limit ? used + 1 : used;
|
|
581
709
|
const beyond = changed && used >= limit;
|
|
582
710
|
const closed = changed ? null : record.closed || null;
|
|
583
|
-
rounds[screen] = { round, fps: { ...fps, [key]: fingerprint }, at: today(), failed: 0, found: rows.map((f) => ({ id: f.id, rule: f.rule, where: f.where })), ...(closed ? { closed } : {}) };
|
|
711
|
+
rounds[screen] = { round, fps: { ...fps, [key]: fingerprint }, at: today(), failed: 0, found: rows.map((f) => ({ id: f.id, rule: f.rule, level: f.level, where: f.where })), ...(closed ? { closed } : {}) };
|
|
584
712
|
writeJson(roundsFile, rounds);
|
|
585
713
|
|
|
586
714
|
const widthNote = widths.join(" and ");
|
|
587
|
-
const checks = [["13 sideways", "13 sideways scroll (phone width)"], ["10 targets", `10 targets (${app ? "44 on phone, 24 otherwise" : "24"})`], ["10 labels", "10 visible labels"], ["10 focus", "10 focus shown (not its contrast)"], ["11 copy", "11 placeholder copy"], ["5 clipped", "5 clipped text (data-crop skipped)"]];
|
|
715
|
+
const checks = [["13 sideways", "13 sideways scroll (phone width)"], ["10 targets", `10 targets (${app ? "44 on phone, 24 otherwise" : "24"})`], ["10 labels", "10 visible labels"], ["10 focus", "10 focus shown (not its contrast)"], ["11 copy", "11 placeholder copy"], ["5 clipped", "5 clipped text (data-crop skipped)"], ["5 size", "5 text size (12 / 14 / 16)"], ["6 proportion", "6 colour proportion (soft)"]];
|
|
588
716
|
if (!widths.some((w) => w <= 480)) notChecked.push({ check: "13 sideways", width: widths.join(","), why: "no phone width (480 or less) in --widths" });
|
|
589
717
|
const done = checks.filter(([key]) => !notChecked.some((n) => n.check === key)).map(([, label]) => label);
|
|
590
718
|
if (json) {
|
|
591
|
-
console.log(JSON.stringify({ screen, round, limit, roundsUsedUp: round >= limit && open.length > 0, closed, open, waived, notChecked, checked: done }, null, 1));
|
|
719
|
+
console.log(JSON.stringify({ screen, round, limit, roundsUsedUp: round >= limit && open.length > 0, closed, open, reported, waived, proportions, notChecked, checked: done }, null, 1));
|
|
592
720
|
} else {
|
|
593
721
|
console.log(`rules: ${screen} at ${widthNote}, round ${round} of ${limit}${beyond ? " (this page changed after the last round: not counted)" : changed || !used ? "" : seen ? " (the page has not changed since the last run)" : " (another state of this screen: same round)"}`);
|
|
594
722
|
if (closed) console.log(`closed by the person on ${closed.at}: "${closed.words}". Do not fix more. Report what is open.`);
|
|
@@ -602,6 +730,12 @@ if (json) {
|
|
|
602
730
|
}
|
|
603
731
|
for (const [check, n] of Object.entries(shown)) if (n > 10) console.log(`(${n - 10} more ${check} findings with the same fix, not listed: fix these, run again, or use --json for all)`);
|
|
604
732
|
} else console.log(`passes: ${done.join("; ")}`);
|
|
733
|
+
if (reported.length) {
|
|
734
|
+
console.log("reported, not blocking:\n| Rule | Hard/soft | Where | Fix |\n|---|---|---|---|");
|
|
735
|
+
for (const f of reported.slice(0, 20)) console.log(`| ${f.rule} | ${f.level} | ${f.where.replace(/\|/g, "/")} [${f.id}] | ${FIX[f.check]} |`);
|
|
736
|
+
if (reported.length > 20) console.log(`(${reported.length - 20} more, not listed: --json has all)`);
|
|
737
|
+
}
|
|
738
|
+
for (const p of proportions) if (p.ground) console.log(`colour proportion at ${p.width}: ground ${p.ground.hex} ${Math.round(p.ground.share * 100)}%${p.shares.slice(1).map((k) => `, ${k.hex} ${Math.round(k.share * 100)}%`).join("")}${p.accent ? `; accent ${p.accent.hex} ${Math.round(p.accent.share * 100)}%` : ""}`);
|
|
605
739
|
if (waived.length) {
|
|
606
740
|
console.log(`waived (${waived.length}), listed so the person sees them:`);
|
|
607
741
|
for (const f of waived) console.log(`- ${f.rule}: ${f.where} [${f.id}]: ${waivers.find((w) => w.screen === screen && w.id === f.id).reason}`);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Lay screenshots out as one numbered sheet, so a round of first screens can
|
|
3
3
|
// be seen and picked from together. It writes an HTML page; capture.mjs turns
|
|
4
|
-
// that into the picture to show.
|
|
4
|
+
// that into the picture to show. The page is marked as a sheet, so links.mjs never
|
|
5
|
+
// counts it as a page of the prototype. No dependencies.
|
|
5
6
|
//
|
|
6
7
|
// node sheet.mjs .longbeard/design/direction/grid/sheet.html .longbeard/design/direction/grid/1.png .longbeard/design/direction/grid/2.png …
|
|
7
8
|
// node sheet.mjs .longbeard/design/direction/grid/vary.html --cols 5 .longbeard/design/direction/grid/v*.png
|
|
@@ -49,6 +50,7 @@ writeFileSync(
|
|
|
49
50
|
out,
|
|
50
51
|
`<!doctype html>
|
|
51
52
|
<meta charset="utf-8">
|
|
53
|
+
<meta name="generator" content="longbeard sheet">
|
|
52
54
|
<title>Sheet</title>
|
|
53
55
|
<style>
|
|
54
56
|
body { margin: 0; padding: 24px; background: #6f6f6f; font: 600 22px/1 system-ui, sans-serif; }
|
|
@@ -19,6 +19,8 @@ A product does not need a mark to be designed: until then, the name is set in th
|
|
|
19
19
|
|
|
20
20
|
Comes out: the chosen mark as SVG in `docs/design/wordmark.svg`, a section in `design-identity.md`, and the mark on the identity board. Options live in `.longbeard/design/wordmark/`.
|
|
21
21
|
|
|
22
|
+
**At every stop,** say what is new and the one question, in up to five lines: a path or a sheet instead of pasted content, one line per option, nothing they already know.
|
|
23
|
+
|
|
22
24
|
## Gate
|
|
23
25
|
|
|
24
26
|
1. No `docs/design/design-direction.md` → `design-direction` first: a mark is judged where the name actually sits. No `docs/design/design-identity.md` → `design-identity`. Stop.
|
|
@@ -26,9 +28,13 @@ Comes out: the chosen mark as SVG in `docs/design/wordmark.svg`, a section in `d
|
|
|
26
28
|
|
|
27
29
|
Read the identity, the brief's name and identity nouns, and the design brief's personality.
|
|
28
30
|
|
|
31
|
+
## 0. Marks they like
|
|
32
|
+
|
|
33
|
+
Ask once which marks they like and why: the cards on their board that show a mark, to pick from, or, when there are none, a search for marks (`design-moodboard`'s one piece). "None, just the name" is a fine answer. A liked mark lends only the kind of device (a cut, a ligature, a case, a rule); its letterforms and shapes never.
|
|
34
|
+
|
|
29
35
|
## 1. Marks, one sheet
|
|
30
36
|
|
|
31
|
-
Four to six marks, each a small HTML page in `.longbeard/design/wordmark/`, made only from the identity's faces and colours and devices that belong to them: a cut, a ligature, a case, a rule, a shape, the accent. One of them is the name set plainly in the display face, so not making a mark is a choice too. Never a stock icon, a generic symbol, or
|
|
37
|
+
Four to six marks, each a small HTML page in `.longbeard/design/wordmark/`, made only from the identity's faces and colours and devices that belong to them: a cut, a ligature, a case, a rule, a shape, the accent. One of them is the name set plainly in the display face, so not making a mark is a choice too. Never a stock icon, a generic symbol, or a reference's letterforms or shapes; a kind of device they liked in step 0 is fine.
|
|
32
38
|
|
|
33
39
|
Each is shown where the name actually sits in the chosen screen (`.longbeard/design/direction/prototype/first.html`), at that size and on that ground, and once large on its own. Where the chosen screen does not show the name at all, that stays so: the mark is for the places that do (the navigation, the tab, the favicon). Capture them and set them on one sheet:
|
|
34
40
|
|
|
@@ -37,7 +43,7 @@ node <skill>/scripts/capture.mjs "file://$PWD/.longbeard/design/wordmark/1.html"
|
|
|
37
43
|
node <skill>/scripts/sheet.mjs .longbeard/design/wordmark/sheet.html .longbeard/design/wordmark/1.png … --cols 3
|
|
38
44
|
```
|
|
39
45
|
|
|
40
|
-
Each with one line of what it does ("the A's crossbar is the accent bar"). Numbered, never ranked.
|
|
46
|
+
Each with one line of what it does ("the A's crossbar is the accent bar"), and a fact when it breaks one of the direction's principles. Numbered, never ranked.
|
|
41
47
|
|
|
42
48
|
> Which mark? Or one to push further ("2, but tighter").
|
|
43
49
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// Lay screenshots out as one numbered sheet, so a round of first screens can
|
|
3
3
|
// be seen and picked from together. It writes an HTML page; capture.mjs turns
|
|
4
|
-
// that into the picture to show.
|
|
4
|
+
// that into the picture to show. The page is marked as a sheet, so links.mjs never
|
|
5
|
+
// counts it as a page of the prototype. No dependencies.
|
|
5
6
|
//
|
|
6
7
|
// node sheet.mjs .longbeard/design/direction/grid/sheet.html .longbeard/design/direction/grid/1.png .longbeard/design/direction/grid/2.png …
|
|
7
8
|
// node sheet.mjs .longbeard/design/direction/grid/vary.html --cols 5 .longbeard/design/direction/grid/v*.png
|
|
@@ -49,6 +50,7 @@ writeFileSync(
|
|
|
49
50
|
out,
|
|
50
51
|
`<!doctype html>
|
|
51
52
|
<meta charset="utf-8">
|
|
53
|
+
<meta name="generator" content="longbeard sheet">
|
|
52
54
|
<title>Sheet</title>
|
|
53
55
|
<style>
|
|
54
56
|
body { margin: 0; padding: 24px; background: #6f6f6f; font: 600 22px/1 system-ui, sans-serif; }
|
package/skills/idea/SKILL.md
CHANGED
|
@@ -19,7 +19,7 @@ The brief says what and for whom, never how. No framework, database, host or lib
|
|
|
19
19
|
|
|
20
20
|
Look at the repo. Do not ask what is there.
|
|
21
21
|
|
|
22
|
-
1. `docs/brief.md` exists and they bring a feature → not this skill. Grill the feature: they type `/grill-with-docs` when it brings new terms, otherwise load `grilling`. Then they type `/to-spec
|
|
22
|
+
1. `docs/brief.md` exists and they bring a feature → not this skill. Grill the feature: they type `/grill-with-docs` when it brings new terms, otherwise load `grilling`. Then they type `/to-spec` and `/to-tickets` in the same session: `to-spec` asks nothing and writes from the conversation. The brief stays as it is.
|
|
23
23
|
2. `docs/brief.md` exists and the product itself changes (new people, new surface, a flow dropped) → **Change**.
|
|
24
24
|
3. No brief, and the repo has code or a README → **Existing project**.
|
|
25
25
|
4. Otherwise → **New idea**.
|
|
@@ -103,8 +103,8 @@ Read the brief. Grill only what changes and what hangs off it: a new surface reo
|
|
|
103
103
|
Offer the next stage in one line, from the stages the router lists. A stage whose file already exists is done, so go past it:
|
|
104
104
|
|
|
105
105
|
- Site, app or graphic, no `DESIGN.md` → `design`, which suggests the first design skill (`design-brief`).
|
|
106
|
-
- No UI, or `DESIGN.md` exists → Design is skipped. Next is Architecture: they type `/grill-with-docs`.
|
|
107
|
-
-
|
|
106
|
+
- No UI, or `DESIGN.md` exists → Design is skipped. Next is Architecture: they type `/grill-with-docs`. Its design tree is the stack (language, framework, data, hosting) and the words the brief and any Figma screens already use. It ends with the stack as an ADR in `docs/adr/`.
|
|
107
|
+
- A stack ADR exists too → next is Plan: grill the first flow with `grilling`, then they type `/to-spec` and `/to-tickets` in the same session.
|
|
108
108
|
|
|
109
109
|
With no Architecture stage in the router (a design-only install), the next stage is `design` for a site or app. Otherwise the brief is the result.
|
|
110
110
|
|