@jonandev/longbeard 0.5.1 → 0.5.2
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 +2 -2
- package/CHANGELOG.md +4 -0
- package/README.md +13 -13
- package/beard.json +1 -1
- package/bin/long-beard.js +1 -1
- package/package.json +1 -1
- package/skills/design-md/SKILL.md +24 -15
- package/skills/design-reference-hunt/SKILL.md +78 -34
- package/skills/design-reference-hunt/references/quality.md +18 -4
- package/skills/design-reference-hunt/references/shots.md +17 -7
- package/skills/design-reference-hunt/scripts/capture.mjs +151 -11
- package/skills/design-reference-hunt/scripts/contact-sheet.mjs +247 -0
- package/skills/design-reference-hunt/scripts/contrast.mjs +27 -0
- package/skills/design-reference-hunt/scripts/dribbble-cards.mjs +204 -0
- package/skills/design-reference-hunt/scripts/moodboard.mjs +447 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// List Dribbble search/popular cards from a listing URL.
|
|
3
|
+
// Headless Chrome; prints TSV: id-slug\tviews\timageURL\ttitle
|
|
4
|
+
//
|
|
5
|
+
// node dribbble-cards.mjs "https://dribbble.com/search/shots/popular/product-design?q=writing+app&timeframe=year" --scrolls 4
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
8
|
+
import { tmpdir } from "node:os";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
|
|
11
|
+
const args = process.argv.slice(2);
|
|
12
|
+
const flag = (name, def) => {
|
|
13
|
+
const i = args.indexOf(`--${name}`);
|
|
14
|
+
if (i === -1) return def;
|
|
15
|
+
const v = args[i + 1];
|
|
16
|
+
args.splice(i, 2);
|
|
17
|
+
return v;
|
|
18
|
+
};
|
|
19
|
+
const url = args[0];
|
|
20
|
+
const scrolls = Math.max(0, Number(flag("scrolls", "3")) || 3);
|
|
21
|
+
if (!url || !/^https?:\/\/(www\.)?dribbble\.com\//i.test(url)) {
|
|
22
|
+
console.error(
|
|
23
|
+
'usage: node dribbble-cards.mjs "https://dribbble.com/search/..." [--scrolls 4]',
|
|
24
|
+
);
|
|
25
|
+
process.exit(2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function findChrome() {
|
|
29
|
+
const env = process.env.CHROME_PATH;
|
|
30
|
+
if (env && existsSync(env)) return env;
|
|
31
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
32
|
+
const local = process.env.LOCALAPPDATA || "";
|
|
33
|
+
const pf = process.env.PROGRAMFILES || "C:\\Program Files";
|
|
34
|
+
const pf86 = process.env["PROGRAMFILES(X86)"] || "C:\\Program Files (x86)";
|
|
35
|
+
const candidates = [
|
|
36
|
+
join(pf, "Google/Chrome/Application/chrome.exe"),
|
|
37
|
+
join(pf86, "Google/Chrome/Application/chrome.exe"),
|
|
38
|
+
join(local, "Google/Chrome/Application/chrome.exe"),
|
|
39
|
+
join(pf, "Microsoft/Edge/Application/msedge.exe"),
|
|
40
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
41
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
42
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
43
|
+
join(home, "Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),
|
|
44
|
+
"/usr/bin/google-chrome",
|
|
45
|
+
"/usr/bin/google-chrome-stable",
|
|
46
|
+
"/usr/bin/chromium",
|
|
47
|
+
"/usr/bin/chromium-browser",
|
|
48
|
+
];
|
|
49
|
+
return candidates.find((path) => path && existsSync(path)) || null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
53
|
+
const exe = findChrome();
|
|
54
|
+
if (!exe) {
|
|
55
|
+
console.error("No Chrome/Edge/Chromium found. Install one or set CHROME_PATH.");
|
|
56
|
+
process.exit(1);
|
|
57
|
+
}
|
|
58
|
+
if (typeof WebSocket === "undefined") {
|
|
59
|
+
console.error("Node 22+ is required.");
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const dir = mkdtempSync(join(tmpdir(), "hunt-dribbble-"));
|
|
64
|
+
let proc;
|
|
65
|
+
const drop = () => {
|
|
66
|
+
try {
|
|
67
|
+
if (proc?.pid) process.kill(proc.pid, "SIGKILL");
|
|
68
|
+
} catch {}
|
|
69
|
+
try {
|
|
70
|
+
rmSync(dir, { recursive: true, force: true });
|
|
71
|
+
} catch {}
|
|
72
|
+
};
|
|
73
|
+
process.once("exit", drop);
|
|
74
|
+
|
|
75
|
+
proc = spawn(
|
|
76
|
+
exe,
|
|
77
|
+
[
|
|
78
|
+
"--headless=new",
|
|
79
|
+
"--remote-debugging-port=0",
|
|
80
|
+
`--user-data-dir=${dir}`,
|
|
81
|
+
"--no-first-run",
|
|
82
|
+
"--hide-scrollbars",
|
|
83
|
+
"--mute-audio",
|
|
84
|
+
"--force-color-profile=srgb",
|
|
85
|
+
"--window-size=1440,900",
|
|
86
|
+
"about:blank",
|
|
87
|
+
],
|
|
88
|
+
{ stdio: ["ignore", "ignore", "pipe"] },
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
let buf = "";
|
|
92
|
+
const wsUrl = await new Promise((resolveWs, reject) => {
|
|
93
|
+
const t = setTimeout(() => reject(new Error("Chrome did not start")), 20000);
|
|
94
|
+
proc.stderr.on("data", (d) => {
|
|
95
|
+
buf += d.toString();
|
|
96
|
+
const m = buf.match(/DevTools listening on (ws:\/\/[^\s]+)/);
|
|
97
|
+
if (m) {
|
|
98
|
+
clearTimeout(t);
|
|
99
|
+
resolveWs(m[1]);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
proc.on("exit", (code) => {
|
|
103
|
+
clearTimeout(t);
|
|
104
|
+
reject(new Error(`Chrome exited ${code}`));
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const ws = new WebSocket(wsUrl);
|
|
109
|
+
await new Promise((res, rej) => {
|
|
110
|
+
ws.onopen = res;
|
|
111
|
+
ws.onerror = () => rej(new Error("CDP socket failed"));
|
|
112
|
+
});
|
|
113
|
+
let nextId = 1;
|
|
114
|
+
const pending = new Map();
|
|
115
|
+
ws.onmessage = (ev) => {
|
|
116
|
+
const msg = JSON.parse(typeof ev.data === "string" ? ev.data : Buffer.from(ev.data).toString());
|
|
117
|
+
if (msg.id && pending.has(msg.id)) {
|
|
118
|
+
const { resolve: ok, reject: bad } = pending.get(msg.id);
|
|
119
|
+
pending.delete(msg.id);
|
|
120
|
+
if (msg.error) bad(new Error(msg.error.message));
|
|
121
|
+
else ok(msg.result);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const send = (method, params = {}, sessionId, timeoutMs = 30000) => {
|
|
125
|
+
const id = nextId++;
|
|
126
|
+
return new Promise((resolveSend, reject) => {
|
|
127
|
+
const timer = setTimeout(() => {
|
|
128
|
+
pending.delete(id);
|
|
129
|
+
reject(new Error(`CDP timeout: ${method}`));
|
|
130
|
+
}, timeoutMs);
|
|
131
|
+
pending.set(id, {
|
|
132
|
+
resolve: (v) => {
|
|
133
|
+
clearTimeout(timer);
|
|
134
|
+
resolveSend(v);
|
|
135
|
+
},
|
|
136
|
+
reject: (e) => {
|
|
137
|
+
clearTimeout(timer);
|
|
138
|
+
reject(e);
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
ws.send(JSON.stringify(sessionId ? { id, method, params, sessionId } : { id, method, params }));
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const { targetId } = await send("Target.createTarget", { url: "about:blank" });
|
|
146
|
+
const { sessionId } = await send("Target.attachToTarget", { targetId, flatten: true });
|
|
147
|
+
const page = (method, params, timeoutMs) => send(method, params, sessionId, timeoutMs);
|
|
148
|
+
|
|
149
|
+
await page("Page.enable");
|
|
150
|
+
await page("Runtime.enable");
|
|
151
|
+
await page("Emulation.setDeviceMetricsOverride", {
|
|
152
|
+
width: 1440,
|
|
153
|
+
height: 900,
|
|
154
|
+
deviceScaleFactor: 1,
|
|
155
|
+
mobile: false,
|
|
156
|
+
});
|
|
157
|
+
await page("Page.navigate", { url }, 40000);
|
|
158
|
+
await sleep(3000);
|
|
159
|
+
|
|
160
|
+
for (let i = 0; i < scrolls; i++) {
|
|
161
|
+
await page("Runtime.evaluate", {
|
|
162
|
+
expression: "window.scrollBy(0, Math.round(window.innerHeight * 0.9))",
|
|
163
|
+
returnByValue: true,
|
|
164
|
+
});
|
|
165
|
+
await sleep(900);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const { result } = await page("Runtime.evaluate", {
|
|
169
|
+
expression: `(() => {
|
|
170
|
+
const rows = [];
|
|
171
|
+
const seen = new Set();
|
|
172
|
+
for (const li of document.querySelectorAll("li")) {
|
|
173
|
+
const a = li.querySelector('a[href*="/shots/"]');
|
|
174
|
+
if (!a) continue;
|
|
175
|
+
const m = (a.getAttribute("href") || "").match(/\\/shots\\/([^/?#]+)/);
|
|
176
|
+
if (!m) continue;
|
|
177
|
+
const idSlug = m[1];
|
|
178
|
+
if (seen.has(idSlug)) continue;
|
|
179
|
+
const img = li.querySelector("img");
|
|
180
|
+
if (!img) continue;
|
|
181
|
+
const raw = img.getAttribute("data-src") || img.currentSrc || img.src || "";
|
|
182
|
+
const imageURL = raw.replace(/\\?.*$/, "");
|
|
183
|
+
if (!imageURL) continue;
|
|
184
|
+
seen.add(idSlug);
|
|
185
|
+
const text = (li.innerText || "").replace(/\\s+/g, " ");
|
|
186
|
+
const vm = text.match(/([\\d.]+\\s*[kKmM]?)\\s*views?/i) || text.match(/([\\d.]+\\s*[kKmM]?)/);
|
|
187
|
+
const views = vm ? vm[1].replace(/\\s+/g, "") : "";
|
|
188
|
+
const title = (img.getAttribute("alt") || a.getAttribute("title") || idSlug).replace(/\\t/g, " ").trim();
|
|
189
|
+
rows.push([idSlug, views, imageURL, title].join("\\t"));
|
|
190
|
+
}
|
|
191
|
+
return rows.join("\\n");
|
|
192
|
+
})()`,
|
|
193
|
+
returnByValue: true,
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
const tsv = result?.value || "";
|
|
197
|
+
if (!tsv.trim()) {
|
|
198
|
+
console.error("0 cards (empty listing or rate limit — retry once after a pause)");
|
|
199
|
+
drop();
|
|
200
|
+
process.exit(1);
|
|
201
|
+
}
|
|
202
|
+
console.log(tsv);
|
|
203
|
+
drop();
|
|
204
|
+
process.exit(0);
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// A moodboard of the references that lead. The layout is this file.
|
|
3
|
+
// It shows what we saw. It does not paint a brand, a logo, a line, or a stat.
|
|
4
|
+
//
|
|
5
|
+
// node moodboard.mjs .design/board.md --out .design/moodboard.html --leads "North Room" --also "Margin"
|
|
6
|
+
import { execSync } from "node:child_process";
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
8
|
+
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const flag = (name) => {
|
|
12
|
+
const i = args.indexOf(`--${name}`);
|
|
13
|
+
if (i === -1) return "";
|
|
14
|
+
const v = args[i + 1] ?? "";
|
|
15
|
+
args.splice(i, 2);
|
|
16
|
+
return v;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const outArg = flag("out");
|
|
20
|
+
const leadsArg = flag("leads");
|
|
21
|
+
const alsoArg = flag("also");
|
|
22
|
+
const boardArg = args[0];
|
|
23
|
+
if (!boardArg || !outArg || args.length !== 1) {
|
|
24
|
+
console.error('usage: node moodboard.mjs .design/board.md --out .design/moodboard.html --leads "Name" [--also "Name"]');
|
|
25
|
+
process.exit(2);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function projectRoot() {
|
|
29
|
+
try {
|
|
30
|
+
return execSync("git rev-parse --show-toplevel", { encoding: "utf8" }).trim();
|
|
31
|
+
} catch {
|
|
32
|
+
return process.cwd();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function resolvePath(path) {
|
|
37
|
+
if (!path) return "";
|
|
38
|
+
if (isAbsolute(path)) return path;
|
|
39
|
+
return resolve(projectRoot(), path);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const boardPath = resolvePath(boardArg);
|
|
43
|
+
const outPath = resolvePath(outArg);
|
|
44
|
+
if (!existsSync(boardPath)) {
|
|
45
|
+
console.error(`moodboard: no board at ${boardArg}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const esc = (s) =>
|
|
50
|
+
String(s ?? "")
|
|
51
|
+
.replace(/&/g, "&")
|
|
52
|
+
.replace(/</g, "<")
|
|
53
|
+
.replace(/>/g, ">")
|
|
54
|
+
.replace(/"/g, """);
|
|
55
|
+
|
|
56
|
+
const norm = (s) => s.trim().toLowerCase().replace(/\s+/g, " ").replace(/\.$/, "");
|
|
57
|
+
|
|
58
|
+
function fieldsOf(text) {
|
|
59
|
+
const fields = {};
|
|
60
|
+
let key = null;
|
|
61
|
+
for (const line of text.split(/\r?\n/)) {
|
|
62
|
+
const m = line.match(/^- ([a-z][a-z /]*):\s*(.*)$/i);
|
|
63
|
+
if (m) {
|
|
64
|
+
key = m[1].toLowerCase();
|
|
65
|
+
fields[key] = m[2].trim();
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (key && /^\s+\S/.test(line)) fields[key] = `${fields[key]} ${line.trim()}`.trim();
|
|
69
|
+
}
|
|
70
|
+
return fields;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function lum(hex) {
|
|
74
|
+
const [r, g, b] = [0, 2, 4]
|
|
75
|
+
.map((i) => parseInt(hex.slice(i + 1, i + 3), 16) / 255)
|
|
76
|
+
.map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4));
|
|
77
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function expand(hex) {
|
|
81
|
+
const h = hex.replace("#", "");
|
|
82
|
+
const full = h.length === 3 ? h.replace(/./g, (c) => c + c) : h;
|
|
83
|
+
return `#${full.toLowerCase()}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function swatches(colour) {
|
|
87
|
+
const found = [];
|
|
88
|
+
const re = /#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})(?:\s*(?:→|->)\s*#([0-9a-fA-F]{6}|[0-9a-fA-F]{3}))?/g;
|
|
89
|
+
let m;
|
|
90
|
+
while ((m = re.exec(colour))) found.push({ index: m.index, end: re.lastIndex, hex: expand(m[2] || m[1]) });
|
|
91
|
+
const out = [];
|
|
92
|
+
for (let i = 0; i < found.length; i++) {
|
|
93
|
+
const end = i + 1 < found.length ? found[i + 1].index : colour.length;
|
|
94
|
+
const label = colour
|
|
95
|
+
.slice(found[i].end, end)
|
|
96
|
+
.replace(/^[\s,;:–\-."']+|[\s,;:–\-."']+$/g, "")
|
|
97
|
+
.replace(/\s+/g, " ")
|
|
98
|
+
.trim();
|
|
99
|
+
if (!out.some((s) => s.hex === found[i].hex)) out.push({ hex: found[i].hex, label });
|
|
100
|
+
}
|
|
101
|
+
return out.slice(0, 8);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function facesOf(typeLine) {
|
|
105
|
+
return typeLine
|
|
106
|
+
.split(/,|\s+and\s+|\s+&\s+|\s+\+\s+/i)
|
|
107
|
+
.map((s) => s.replace(/\s+for\s+.*/i, "").replace(/^(a pairing of|pairing of|the)\s+/i, "").trim())
|
|
108
|
+
.filter(Boolean)
|
|
109
|
+
.slice(0, 2);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function isSans(name) {
|
|
113
|
+
return /sans|grotesk|grotesque|gothic|america|aeonik|inter|helvetica|neue|haas|sohne|söhne|geist|satoshi|switzer|untitled/i.test(
|
|
114
|
+
name,
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function cssFamily(name) {
|
|
119
|
+
if (!name) return '"Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif';
|
|
120
|
+
const safe = name.replace(/["\\<>]/g, "").slice(0, 80);
|
|
121
|
+
const fallback = isSans(name)
|
|
122
|
+
? '"Helvetica Neue", Helvetica, Arial, sans-serif'
|
|
123
|
+
: '"Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif';
|
|
124
|
+
return `"${safe}", ${fallback}`;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function webPath(fromFile, absTarget) {
|
|
128
|
+
let rel = relative(dirname(fromFile), absTarget).split("\\").join("/");
|
|
129
|
+
if (!rel.startsWith(".")) rel = `./${rel}`;
|
|
130
|
+
return rel;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function shotSrc(shot) {
|
|
134
|
+
if (!shot) return "";
|
|
135
|
+
const abs = resolvePath(shot.trim());
|
|
136
|
+
if (!existsSync(abs)) {
|
|
137
|
+
console.error(`moodboard: missing shot ${shot.trim()}`);
|
|
138
|
+
return "";
|
|
139
|
+
}
|
|
140
|
+
return webPath(outPath, abs);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const md = readFileSync(boardPath, "utf8");
|
|
144
|
+
const readSlice = md.match(/## Read this\s*\n([\s\S]*?)(?=\n## |\n### |\n- kind:|$)/);
|
|
145
|
+
const read = readSlice ? fieldsOf(readSlice[1]) : {};
|
|
146
|
+
const leadsName = leadsArg || read.leads || read.primary || "";
|
|
147
|
+
if (!leadsName) {
|
|
148
|
+
console.error("moodboard: name the leading card with --leads");
|
|
149
|
+
process.exit(1);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const cards = [];
|
|
153
|
+
const chunks = md.split(/^### /m).slice(1);
|
|
154
|
+
for (const chunk of chunks) {
|
|
155
|
+
const nl = chunk.indexOf("\n");
|
|
156
|
+
const name = (nl === -1 ? chunk : chunk.slice(0, nl)).trim();
|
|
157
|
+
const body = nl === -1 ? "" : chunk.slice(nl + 1);
|
|
158
|
+
const cut = body.search(/^- kind:/m);
|
|
159
|
+
cards.push({ name, ...fieldsOf((cut === -1 ? body : body.slice(0, cut)).split(/^## /m)[0]) });
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const primary = cards.find((c) => norm(c.name) === norm(leadsName));
|
|
163
|
+
if (!primary) {
|
|
164
|
+
console.error(`moodboard: no card named ${leadsName}`);
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
const alsoName = alsoArg || (read.also && !/^none$/i.test(read.also.trim()) ? read.also : "");
|
|
168
|
+
const also = alsoName ? cards.find((c) => norm(c.name) === norm(alsoName)) : null;
|
|
169
|
+
if (alsoName && !also) console.error(`moodboard: no card named ${alsoName}`);
|
|
170
|
+
|
|
171
|
+
const imagery = [];
|
|
172
|
+
{
|
|
173
|
+
let inCard = false;
|
|
174
|
+
let cur = null;
|
|
175
|
+
const push = () => {
|
|
176
|
+
if (cur?.kind === "imagery" && cur.shot) imagery.push(cur);
|
|
177
|
+
cur = null;
|
|
178
|
+
};
|
|
179
|
+
for (const line of md.split(/\r?\n/)) {
|
|
180
|
+
if (line.startsWith("### ")) {
|
|
181
|
+
inCard = true;
|
|
182
|
+
push();
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (line.startsWith("## ")) {
|
|
186
|
+
inCard = false;
|
|
187
|
+
push();
|
|
188
|
+
continue;
|
|
189
|
+
}
|
|
190
|
+
const m = line.match(/^- ([a-z][a-z /]*):\s*(.*)$/i);
|
|
191
|
+
if (m && m[1].toLowerCase() === "kind") {
|
|
192
|
+
inCard = false;
|
|
193
|
+
push();
|
|
194
|
+
cur = { kind: m[2].trim().toLowerCase() };
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (inCard) continue;
|
|
198
|
+
if (cur && m) cur[m[1].toLowerCase()] = m[2].trim();
|
|
199
|
+
else if (cur && line.trim() === "") push();
|
|
200
|
+
}
|
|
201
|
+
push();
|
|
202
|
+
}
|
|
203
|
+
if (imagery.length > 3) console.error(`moodboard: showing 3 of ${imagery.length} imagery`);
|
|
204
|
+
|
|
205
|
+
const colours = swatches(primary.colour || "").slice(0, 6);
|
|
206
|
+
const seenFaces = [];
|
|
207
|
+
for (const line of [primary.type, also && also.fit !== "form" ? also.type : ""]) {
|
|
208
|
+
for (const face of facesOf(line || "")) {
|
|
209
|
+
if (!seenFaces.some((f) => norm(f) === norm(face))) seenFaces.push(face);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const faces = seenFaces.slice(0, 3);
|
|
213
|
+
const family = cssFamily(faces[0] || "");
|
|
214
|
+
const ink = "#1c1c1a";
|
|
215
|
+
|
|
216
|
+
const principle = (primary["worth taking"] || "").trim();
|
|
217
|
+
const primarySrc = shotSrc(primary.shot);
|
|
218
|
+
const alsoSrc = also ? shotSrc(also.shot) : "";
|
|
219
|
+
const pictures = imagery.slice(0, 3).flatMap((item) => {
|
|
220
|
+
const src = shotSrc(item.shot);
|
|
221
|
+
return src ? [{ src, caption: (item.shows || "").trim() }] : [];
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
const tiles = [];
|
|
225
|
+
if (faces.length) {
|
|
226
|
+
const names = faces
|
|
227
|
+
.map((face) => `<p class="face" style="font-family:${cssFamily(face)}">${esc(face)}</p>`)
|
|
228
|
+
.join("");
|
|
229
|
+
tiles.push(`<article class="tile type span-${colours.length ? 2 : 6}">
|
|
230
|
+
<p class="kicker">Type we saw</p>
|
|
231
|
+
<p class="aa">Aa</p>
|
|
232
|
+
<div class="faces">${names}</div>
|
|
233
|
+
</article>`);
|
|
234
|
+
}
|
|
235
|
+
if (colours.length) {
|
|
236
|
+
const span = faces.length ? 4 : 6;
|
|
237
|
+
const chips = colours
|
|
238
|
+
.map((s) => {
|
|
239
|
+
const edge = lum(s.hex) > 0.86 ? " chip-edge" : "";
|
|
240
|
+
return `<div class="swatch"><div class="chip${edge}" style="background:${s.hex}"></div><p class="hex">${esc(s.hex)}</p>${s.label ? `<p class="role">${esc(s.label)}</p>` : ""}</div>`;
|
|
241
|
+
})
|
|
242
|
+
.join("");
|
|
243
|
+
tiles.push(`<article class="tile colour span-${span}"><p class="kicker">Colour we saw</p><div class="swatches">${chips}</div></article>`);
|
|
244
|
+
}
|
|
245
|
+
if (primarySrc || principle) {
|
|
246
|
+
const span = also && (alsoSrc || also["worth taking"]) ? 3 : 6;
|
|
247
|
+
const shot = primarySrc ? `<img src="${esc(primarySrc)}" alt="Leading reference, top of the shot">` : "";
|
|
248
|
+
tiles.push(`<article class="tile primary span-${span}${primarySrc ? " shot" : " no-shot"}">${shot}<div class="caption"><p class="kicker">Leads</p>${principle ? `<p class="control">${esc(principle)}</p>` : ""}</div></article>`);
|
|
249
|
+
}
|
|
250
|
+
if (also && (alsoSrc || also["worth taking"])) {
|
|
251
|
+
const span = primarySrc || principle ? 3 : 6;
|
|
252
|
+
const shot = alsoSrc ? `<img src="${esc(alsoSrc)}" alt="Also reference, top of the shot">` : "";
|
|
253
|
+
const line = (also["worth taking"] || "").trim();
|
|
254
|
+
tiles.push(`<article class="tile also span-${span}${alsoSrc ? " shot" : ""}">${shot}<div class="caption"><p class="kicker">Also</p>${line ? `<p class="control">${esc(line)}</p>` : ""}</div></article>`);
|
|
255
|
+
}
|
|
256
|
+
const pictureSpan = pictures.length === 1 ? 6 : pictures.length === 2 ? 3 : 2;
|
|
257
|
+
for (const pic of pictures) {
|
|
258
|
+
const cap = pic.caption ? `<figcaption>${esc(pic.caption)}</figcaption>` : "";
|
|
259
|
+
tiles.push(`<figure class="tile picture shot span-${pictureSpan}"><img src="${esc(pic.src)}" alt="${esc(pic.caption || "Imagery")}">${cap}</figure>`);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
if (!tiles.length) {
|
|
263
|
+
console.error("moodboard: nothing on the board to show");
|
|
264
|
+
process.exit(1);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const html = `<!DOCTYPE html>
|
|
268
|
+
<html lang="en">
|
|
269
|
+
<head>
|
|
270
|
+
<meta charset="utf-8">
|
|
271
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
272
|
+
<title>Moodboard</title>
|
|
273
|
+
<style>
|
|
274
|
+
:root {
|
|
275
|
+
--display: ${family};
|
|
276
|
+
--ink: ${ink};
|
|
277
|
+
--paper: #ffffff;
|
|
278
|
+
--canvas: #e4e4e2;
|
|
279
|
+
--muted: #6f6f6a;
|
|
280
|
+
--ui: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
281
|
+
}
|
|
282
|
+
* { box-sizing: border-box; }
|
|
283
|
+
html { color-scheme: light; }
|
|
284
|
+
body {
|
|
285
|
+
margin: 0;
|
|
286
|
+
min-height: 100vh;
|
|
287
|
+
background: var(--canvas);
|
|
288
|
+
color: var(--ink);
|
|
289
|
+
font-family: var(--ui);
|
|
290
|
+
-webkit-font-smoothing: antialiased;
|
|
291
|
+
}
|
|
292
|
+
.sheet { max-width: 1080px; margin: 0 auto; padding: 52px 28px 80px; }
|
|
293
|
+
h1 {
|
|
294
|
+
margin: 0 0 16px 2px;
|
|
295
|
+
font-family: var(--ui);
|
|
296
|
+
font-size: 11px;
|
|
297
|
+
font-weight: 600;
|
|
298
|
+
letter-spacing: 0.18em;
|
|
299
|
+
text-transform: uppercase;
|
|
300
|
+
color: var(--muted);
|
|
301
|
+
}
|
|
302
|
+
.grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; align-items: stretch; }
|
|
303
|
+
.tile { background: var(--paper); border-radius: 22px; overflow: hidden; min-width: 0; }
|
|
304
|
+
.span-2 { grid-column: span 2; }
|
|
305
|
+
.span-3 { grid-column: span 3; }
|
|
306
|
+
.span-4 { grid-column: span 4; }
|
|
307
|
+
.span-6 { grid-column: span 6; }
|
|
308
|
+
.kicker {
|
|
309
|
+
margin: 0;
|
|
310
|
+
font-size: 11px;
|
|
311
|
+
font-weight: 600;
|
|
312
|
+
letter-spacing: 0.16em;
|
|
313
|
+
text-transform: uppercase;
|
|
314
|
+
color: var(--muted);
|
|
315
|
+
}
|
|
316
|
+
.type, .colour, .principle, .leave { padding: 22px 24px 20px; }
|
|
317
|
+
.type {
|
|
318
|
+
display: flex;
|
|
319
|
+
flex-direction: column;
|
|
320
|
+
min-height: 250px;
|
|
321
|
+
background: #171717;
|
|
322
|
+
color: #f6f5f2;
|
|
323
|
+
}
|
|
324
|
+
.type .kicker { color: rgba(255, 255, 255, 0.55); }
|
|
325
|
+
.aa {
|
|
326
|
+
margin: 22px 0 0;
|
|
327
|
+
font-family: var(--display);
|
|
328
|
+
font-size: 104px;
|
|
329
|
+
line-height: 0.78;
|
|
330
|
+
letter-spacing: -0.045em;
|
|
331
|
+
font-weight: 500;
|
|
332
|
+
color: #f6f5f2;
|
|
333
|
+
}
|
|
334
|
+
.faces { margin-top: 20px; }
|
|
335
|
+
.face {
|
|
336
|
+
margin: 0;
|
|
337
|
+
font-family: var(--display);
|
|
338
|
+
font-size: 22px;
|
|
339
|
+
line-height: 1.2;
|
|
340
|
+
letter-spacing: -0.03em;
|
|
341
|
+
color: #f6f5f2;
|
|
342
|
+
}
|
|
343
|
+
.face + .face { margin-top: 2px; font-size: 16px; color: rgba(255, 255, 255, 0.62); }
|
|
344
|
+
.colour { display: flex; flex-direction: column; min-height: 250px; }
|
|
345
|
+
.swatches {
|
|
346
|
+
margin-top: auto;
|
|
347
|
+
padding-top: 22px;
|
|
348
|
+
display: grid;
|
|
349
|
+
grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
|
|
350
|
+
gap: 10px 12px;
|
|
351
|
+
}
|
|
352
|
+
.chip { height: 92px; border-radius: 14px; }
|
|
353
|
+
.chip-edge { box-shadow: inset 0 0 0 1px rgba(28, 28, 26, 0.14); }
|
|
354
|
+
.hex {
|
|
355
|
+
margin: 8px 0 0;
|
|
356
|
+
font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
357
|
+
font-size: 11px;
|
|
358
|
+
letter-spacing: 0.02em;
|
|
359
|
+
color: #3c3c39;
|
|
360
|
+
}
|
|
361
|
+
.role {
|
|
362
|
+
margin: 2px 0 0;
|
|
363
|
+
font-size: 12px;
|
|
364
|
+
line-height: 1.3;
|
|
365
|
+
color: var(--muted);
|
|
366
|
+
display: -webkit-box;
|
|
367
|
+
-webkit-line-clamp: 2;
|
|
368
|
+
-webkit-box-orient: vertical;
|
|
369
|
+
overflow: hidden;
|
|
370
|
+
}
|
|
371
|
+
.principle { display: flex; flex-direction: column; min-height: 320px; }
|
|
372
|
+
.principle .kicker { color: color-mix(in srgb, currentColor 58%, transparent); }
|
|
373
|
+
.statement {
|
|
374
|
+
margin: auto 0 0;
|
|
375
|
+
max-width: 16ch;
|
|
376
|
+
font-family: var(--display);
|
|
377
|
+
font-size: 40px;
|
|
378
|
+
line-height: 1.05;
|
|
379
|
+
letter-spacing: -0.035em;
|
|
380
|
+
font-weight: 500;
|
|
381
|
+
}
|
|
382
|
+
.statement.long { font-size: 28px; line-height: 1.15; max-width: 22ch; }
|
|
383
|
+
.shot { position: relative; background: #1a1a1a; }
|
|
384
|
+
.shot img {
|
|
385
|
+
display: block;
|
|
386
|
+
width: 100%;
|
|
387
|
+
height: 320px;
|
|
388
|
+
object-fit: cover;
|
|
389
|
+
object-position: top center;
|
|
390
|
+
background: #eceae6;
|
|
391
|
+
}
|
|
392
|
+
.picture img { height: 250px; object-position: center; }
|
|
393
|
+
.shot .caption, .picture figcaption {
|
|
394
|
+
position: absolute;
|
|
395
|
+
left: 0;
|
|
396
|
+
right: 0;
|
|
397
|
+
bottom: 0;
|
|
398
|
+
margin: 0;
|
|
399
|
+
padding: 64px 18px 16px;
|
|
400
|
+
background: linear-gradient(to top, rgba(10, 10, 10, 0.78) 0%, rgba(10, 10, 10, 0.28) 52%, rgba(10, 10, 10, 0) 100%);
|
|
401
|
+
color: #fff;
|
|
402
|
+
}
|
|
403
|
+
.shot .kicker { color: rgba(255, 255, 255, 0.72); }
|
|
404
|
+
.shot .control { margin: 4px 0 0; font-size: 16px; line-height: 1.3; color: #fff; }
|
|
405
|
+
.picture { margin: 0; }
|
|
406
|
+
.picture figcaption {
|
|
407
|
+
font-size: 14px;
|
|
408
|
+
line-height: 1.3;
|
|
409
|
+
display: -webkit-box;
|
|
410
|
+
-webkit-line-clamp: 2;
|
|
411
|
+
-webkit-box-orient: vertical;
|
|
412
|
+
overflow: hidden;
|
|
413
|
+
}
|
|
414
|
+
.primary.no-shot { min-height: 220px; background: var(--paper); }
|
|
415
|
+
.primary.no-shot .caption { position: static; padding: 22px 24px; background: none; color: inherit; }
|
|
416
|
+
.primary.no-shot .kicker { color: var(--muted); }
|
|
417
|
+
.primary.no-shot .control {
|
|
418
|
+
font-family: var(--display);
|
|
419
|
+
font-size: 28px;
|
|
420
|
+
line-height: 1.15;
|
|
421
|
+
letter-spacing: -0.03em;
|
|
422
|
+
color: #2a2a28;
|
|
423
|
+
}
|
|
424
|
+
.leave { display: flex; flex-direction: column; justify-content: center; gap: 12px; min-height: 180px; }
|
|
425
|
+
.quiet { margin: 0; max-width: 28em; font-size: 20px; line-height: 1.35; letter-spacing: -0.02em; color: #3a3a38; }
|
|
426
|
+
@media (max-width: 800px) {
|
|
427
|
+
.sheet { padding: 28px 16px 48px; }
|
|
428
|
+
.tile, .span-2, .span-3, .span-4, .span-6 { grid-column: 1 / -1; }
|
|
429
|
+
.aa { font-size: 84px; }
|
|
430
|
+
.statement { font-size: 32px; }
|
|
431
|
+
}
|
|
432
|
+
</style>
|
|
433
|
+
</head>
|
|
434
|
+
<body>
|
|
435
|
+
<main class="sheet">
|
|
436
|
+
<h1>Moodboard</h1>
|
|
437
|
+
<div class="grid">
|
|
438
|
+
${tiles.join("\n ")}
|
|
439
|
+
</div>
|
|
440
|
+
</main>
|
|
441
|
+
</body>
|
|
442
|
+
</html>
|
|
443
|
+
`;
|
|
444
|
+
|
|
445
|
+
mkdirSync(dirname(outPath), { recursive: true });
|
|
446
|
+
writeFileSync(outPath, html);
|
|
447
|
+
console.log(outArg);
|