@jonandev/longbeard 0.13.0 → 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 -5
- package/CHANGELOG.md +27 -0
- package/README.md +3 -4
- package/beard.json +6 -17
- package/bin/long-beard.js +2 -2
- package/package.json +1 -1
- package/skills/design/SKILL.md +4 -6
- package/skills/design-brief/SKILL.md +5 -5
- package/skills/design-check/SKILL.md +1 -1
- package/skills/design-check/references/design-rules.md +26 -4
- package/skills/design-check/scripts/rules.mjs +143 -9
- package/skills/design-direction/SKILL.md +70 -52
- package/skills/design-direction/references/design-floor.md +118 -0
- package/skills/design-direction/references/graphic.md +5 -6
- package/skills/design-direction/references/library.md +6 -6
- package/skills/design-direction/references/screen-template.html +2 -2
- 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 +12 -9
- package/skills/design-direction/scripts/colours.mjs +247 -0
- package/skills/design-direction/scripts/moodboard.mjs +1 -1
- package/skills/design-direction/scripts/rules.mjs +747 -0
- package/skills/design-direction/scripts/sheet.mjs +3 -1
- package/skills/design-figma/SKILL.md +1 -1
- package/skills/design-identity/SKILL.md +9 -7
- package/skills/design-identity/references/design-floor.md +118 -0
- package/skills/design-identity/scripts/colours.mjs +35 -1
- package/skills/design-identity/scripts/sheet.mjs +3 -1
- package/skills/design-moodboard/SKILL.md +6 -2
- package/skills/design-moodboard/references/graphic.md +1 -1
- package/skills/design-moodboard/scripts/group.mjs +1 -1
- package/skills/design-moodboard/scripts/moodboard.mjs +1 -1
- package/skills/design-prototype/SKILL.md +51 -48
- package/skills/design-prototype/references/design-floor.md +118 -0
- package/skills/design-prototype/references/design-md-template.md +3 -1
- package/skills/design-prototype/references/graphic.md +6 -5
- package/skills/design-prototype/references/variants.js +43 -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 +6 -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 -204
- package/skills/design-direction/references/full-build.md +0 -20
- package/skills/design-direction/references/grid.md +0 -97
- package/skills/design-direction/scripts/layout-diff.mjs +0 -118
- package/skills/design-families/SKILL.md +0 -139
- 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 -609
- package/skills/design-families/scripts/tag.mjs +0 -289
- package/skills/design-prototype/references/design-rules.md +0 -204
- package/skills/design-prototype/references/five-second.md +0 -46
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The colour options of design-identity, made by rule, not picked by the agent: the
|
|
3
|
+
// chosen screen's ground and accent, even steps around each in OKLCH (lighter,
|
|
4
|
+
// darker, warmer, cooler), the family's own colours, and theirs. Every ground
|
|
5
|
+
// keeps the built ink where it reads, or else gets near-black or near-white, and an option that fails contrast is left
|
|
6
|
+
// out: 4.5:1 for text on a ground, 3:1 for an accent on its ground. --level AAA
|
|
7
|
+
// (the design brief's accessibility) asks 7:1 for text and 4.5:1 for an accent,
|
|
8
|
+
// which may carry large text; a mark such as a button's fill stays 3:1. No
|
|
9
|
+
// dependencies.
|
|
10
|
+
//
|
|
11
|
+
// node colours.mjs --ground "#f1ede4" --ink "#111111" --accent "#fe2601" \
|
|
12
|
+
// --family "#ebe4e0,#b6bc94,#fd3b19" --theirs "#2b4c7e" [--level AAA]
|
|
13
|
+
//
|
|
14
|
+
// Three choices only: the ground, the text colour (ink) and one accent. The
|
|
15
|
+
// ink has its own row, the built ink first: lighter, darker, warmer and cooler
|
|
16
|
+
// steps of it, near-black and near-white, each checked on the built ground.
|
|
17
|
+
//
|
|
18
|
+
// Prints one row per option: row, label, colour, ink (for grounds), contrast
|
|
19
|
+
// (cut, not rounded, to one place, so a ratio just under its need never prints as the need).
|
|
20
|
+
// --json prints the same as JSON, for a page that renders the rows.
|
|
21
|
+
//
|
|
22
|
+
// --roles: once the three are picked, every other role is derived by rule and
|
|
23
|
+
// checked, never chosen one by one: soft text, a hairline, the button's fill
|
|
24
|
+
// and label, a picture tone, and status (ok, warn, error) on the ground.
|
|
25
|
+
// node colours.mjs --roles --ground "#3b2416" --ink "#d8b98c" --accent "#e8643c"
|
|
26
|
+
//
|
|
27
|
+
// --harmony: when the board shows no accent and they named none, the accents colour theory
|
|
28
|
+
// offers from the board's primary: complementary, split-complementary (two), analogous (two),
|
|
29
|
+
// each at the board's own lightness and chroma (the median of its coloured --family, else the
|
|
30
|
+
// primary's), so a muted board gets a muted accent. Under 3:1 on the ground (4.5:1 at AAA) is
|
|
31
|
+
// left out. Options, never a pick: they choose.
|
|
32
|
+
// node colours.mjs --harmony --primary "#2b4c7e" --ground "#f1ede4" --family "<board colours>"
|
|
33
|
+
|
|
34
|
+
const args = process.argv.slice(2);
|
|
35
|
+
const flag = (name) => {
|
|
36
|
+
const i = args.indexOf(`--${name}`);
|
|
37
|
+
return i === -1 ? "" : (args.splice(i, 2)[1] ?? "");
|
|
38
|
+
};
|
|
39
|
+
const json = args.includes("--json");
|
|
40
|
+
const rolesMode = args.includes("--roles");
|
|
41
|
+
const harmonyMode = args.includes("--harmony");
|
|
42
|
+
const primaryArg = flag("primary");
|
|
43
|
+
const groundArg = flag("ground");
|
|
44
|
+
const inkArg = flag("ink");
|
|
45
|
+
const accentArg = flag("accent");
|
|
46
|
+
const familyArg = flag("family");
|
|
47
|
+
const theirsArg = flag("theirs");
|
|
48
|
+
const levelArg = (flag("level") || "AA").toUpperCase();
|
|
49
|
+
if (levelArg !== "AA" && levelArg !== "AAA") {
|
|
50
|
+
console.error("colours: --level is AA or AAA");
|
|
51
|
+
process.exit(2);
|
|
52
|
+
}
|
|
53
|
+
// What each kind of colour has to reach: text, an accent (which may carry large text), a mark.
|
|
54
|
+
const textNeed = levelArg === "AAA" ? 7 : 4.5;
|
|
55
|
+
const accentNeed = levelArg === "AAA" ? 4.5 : 3;
|
|
56
|
+
const markNeed = 3;
|
|
57
|
+
const cut = (v) => Math.floor(v * 10) / 10;
|
|
58
|
+
const hex6 = (v) => {
|
|
59
|
+
const s = String(v || "").trim().toLowerCase();
|
|
60
|
+
if (/^#[0-9a-f]{3}$/.test(s)) return `#${[...s.slice(1)].map((c) => c + c).join("")}`;
|
|
61
|
+
return /^#[0-9a-f]{6}$/.test(s) ? s : null;
|
|
62
|
+
};
|
|
63
|
+
const list = (v) => (v ? v.split(",").map(hex6).filter(Boolean) : []);
|
|
64
|
+
const ground = hex6(groundArg);
|
|
65
|
+
const ink = hex6(inkArg);
|
|
66
|
+
const primary = hex6(primaryArg);
|
|
67
|
+
if (harmonyMode ? !ground || !primary : !ground || !ink) {
|
|
68
|
+
if (harmonyMode) {
|
|
69
|
+
console.error('usage: node colours.mjs --harmony --primary "#rrggbb" --ground "#rrggbb" [--family "#a,#b"] [--level AA|AAA] [--json]');
|
|
70
|
+
process.exit(2);
|
|
71
|
+
}
|
|
72
|
+
console.error('usage: node colours.mjs --ground "#rrggbb" --ink "#rrggbb" [--accent "#rrggbb"] [--family "#a,#b"] [--theirs "#c"] [--level AA|AAA] [--json]');
|
|
73
|
+
process.exit(2);
|
|
74
|
+
}
|
|
75
|
+
const accent = hex6(accentArg);
|
|
76
|
+
|
|
77
|
+
// sRGB and OKLCH, both ways. Out of gamut, chroma is reduced until the colour fits.
|
|
78
|
+
const toLin = (c) => (c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4);
|
|
79
|
+
const toGam = (c) => (c <= 0.0031308 ? 12.92 * c : 1.055 * c ** (1 / 2.4) - 0.055);
|
|
80
|
+
const rgbOf = (hex) => [1, 3, 5].map((i) => parseInt(hex.slice(i, i + 2), 16) / 255);
|
|
81
|
+
const hexOf = (rgb) => `#${rgb.map((c) => Math.round(Math.min(1, Math.max(0, c)) * 255).toString(16).padStart(2, "0")).join("")}`;
|
|
82
|
+
function oklch(hex) {
|
|
83
|
+
const [r, g, b] = rgbOf(hex).map(toLin);
|
|
84
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
85
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
86
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
87
|
+
const L = 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s;
|
|
88
|
+
const A = 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s;
|
|
89
|
+
const B = 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s;
|
|
90
|
+
return [L, Math.hypot(A, B), ((Math.atan2(B, A) * 180) / Math.PI + 360) % 360];
|
|
91
|
+
}
|
|
92
|
+
function fromOklch([L, C, H]) {
|
|
93
|
+
for (let c = C; c >= 0; c -= 0.005) {
|
|
94
|
+
const a = c * Math.cos((H * Math.PI) / 180), b = c * Math.sin((H * Math.PI) / 180);
|
|
95
|
+
const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
96
|
+
const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
97
|
+
const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
98
|
+
const rgb = [4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s, -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s, -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s];
|
|
99
|
+
if (rgb.every((v) => v >= -0.0005 && v <= 1.0005)) return hexOf(rgb.map(toGam));
|
|
100
|
+
}
|
|
101
|
+
return hexOf([L, L, L].map(toGam));
|
|
102
|
+
}
|
|
103
|
+
// WCAG contrast.
|
|
104
|
+
const lum = (hex) => {
|
|
105
|
+
const [r, g, b] = rgbOf(hex).map(toLin);
|
|
106
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
107
|
+
};
|
|
108
|
+
const contrast = (a, b) => {
|
|
109
|
+
const [hi, lo] = [lum(a), lum(b)].sort((x, y) => y - x);
|
|
110
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
111
|
+
};
|
|
112
|
+
// A step: lighter or darker by 0.06 in lightness; warmer or cooler by 20 degrees of hue toward
|
|
113
|
+
// orange (55) or blue (250), whichever way is shorter.
|
|
114
|
+
const toward = (h, target, by) => {
|
|
115
|
+
const d = ((target - h + 540) % 360) - 180;
|
|
116
|
+
return (h + Math.sign(d) * Math.min(by, Math.abs(d)) + 360) % 360;
|
|
117
|
+
};
|
|
118
|
+
const step = (hex, kind) => {
|
|
119
|
+
const [L, C, H] = oklch(hex);
|
|
120
|
+
if (kind === "lighter") return fromOklch([Math.min(0.99, L + 0.06), C, H]);
|
|
121
|
+
if (kind === "darker") return fromOklch([Math.max(0.02, L - 0.06), C, H]);
|
|
122
|
+
if (kind === "warmer") return fromOklch([L, Math.max(C, 0.02), toward(H, 55, 20)]);
|
|
123
|
+
return fromOklch([L, Math.max(C, 0.02), toward(H, 250, 20)]);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// A colour between two, in OKLCH: t of the way from a to b.
|
|
127
|
+
const mix = (a, b, t) => {
|
|
128
|
+
const [L1, C1, H1] = oklch(a), [L2, C2, H2] = oklch(b);
|
|
129
|
+
const dh = ((H2 - H1 + 540) % 360) - 180;
|
|
130
|
+
return fromOklch([L1 + (L2 - L1) * t, C1 + (C2 - C1) * t, (H1 + dh * t + 360) % 360]);
|
|
131
|
+
};
|
|
132
|
+
if (harmonyMode) {
|
|
133
|
+
// The board's lightness and chroma: the median of its coloured colours, the primary among them.
|
|
134
|
+
const pool = [...new Set([primary, ...list(familyArg)])].map(oklch).filter(([, C]) => C >= 0.02);
|
|
135
|
+
const median = (xs) => { const s = [...xs].sort((a, b) => a - b); return s[Math.floor((s.length - 1) / 2)]; };
|
|
136
|
+
const [pL, pC, pH] = oklch(primary);
|
|
137
|
+
const L = pool.length ? median(pool.map((c) => c[0])) : pL;
|
|
138
|
+
const C = pool.length ? median(pool.map((c) => c[1])) : pC;
|
|
139
|
+
const kinds = [["complementary", 180], ["split-complementary", 150], ["split-complementary", 210], ["analogous", -30], ["analogous", 30]];
|
|
140
|
+
const rows = [], left = [];
|
|
141
|
+
for (const [label, turn] of kinds) {
|
|
142
|
+
const colour = fromOklch([L, C, (pH + turn + 360) % 360]);
|
|
143
|
+
const k = contrast(colour, ground);
|
|
144
|
+
if (k >= accentNeed) rows.push({ row: "accent", label, colour, contrast: cut(k) });
|
|
145
|
+
else left.push(`${label} ${colour} (${cut(k)}:1, under ${accentNeed}:1 on ${ground})`);
|
|
146
|
+
}
|
|
147
|
+
if (json) console.log(JSON.stringify({ rows, left }, null, 1));
|
|
148
|
+
else for (const r of rows) console.log([r.row, r.label, r.colour, r.contrast].join("\t"));
|
|
149
|
+
for (const l of left) console.error(`colours: left out ${l}`);
|
|
150
|
+
process.exit(0);
|
|
151
|
+
}
|
|
152
|
+
if (rolesMode) {
|
|
153
|
+
const r1 = cut;
|
|
154
|
+
const roles = [];
|
|
155
|
+
const role = (name, colour, on, need, rule) => roles.push({ role: name, colour, on, contrast: r1(contrast(colour, on)), need, rule, ok: contrast(colour, on) >= need });
|
|
156
|
+
role("text", ink, ground, textNeed, "the ink they picked");
|
|
157
|
+
// Soft text: the ink toward the ground, as far as it still reads at the text level.
|
|
158
|
+
let soft = ink;
|
|
159
|
+
for (let t = 0.05; t <= 0.6; t += 0.05) {
|
|
160
|
+
const c = mix(ink, ground, t);
|
|
161
|
+
if (contrast(c, ground) < textNeed) break;
|
|
162
|
+
soft = c;
|
|
163
|
+
}
|
|
164
|
+
role("soft text", soft, ground, textNeed, `the ink toward the ground, while it reads at ${textNeed}:1`);
|
|
165
|
+
role("hairline", mix(ink, ground, 0.8), ground, 1.2, "the ink, 20% over the ground: a line, not text");
|
|
166
|
+
// The button: the accent when it stands off the ground at 3:1 (a mark), else the ink; its label the
|
|
167
|
+
// ground or the ink, whichever reads on the fill.
|
|
168
|
+
const fill = accent && contrast(accent, ground) >= markNeed ? accent : ink;
|
|
169
|
+
role("button fill", fill, ground, markNeed, fill === ink ? "the ink: the accent is under 3:1 on the ground" : "the accent");
|
|
170
|
+
const label = [ground, ink].find((c) => c !== fill && contrast(c, fill) >= textNeed) || ["#111111", "#f7f7f5"].sort((a, b) => contrast(b, fill) - contrast(a, fill))[0];
|
|
171
|
+
role("button label", label, fill, textNeed, "the ground or the ink where it reads on the fill, else near-black or near-white");
|
|
172
|
+
// A picture tone: the ground's hue at low chroma, for duotones and the overlay under text on photos.
|
|
173
|
+
const [gL, , gH] = oklch(ground);
|
|
174
|
+
roles.push({ role: "picture tone", colour: fromOklch([gL < 0.5 ? 0.25 : 0.75, 0.04, gH]), rule: "the ground's hue, low colour: tone photos toward it, and lay it under text on a photo" });
|
|
175
|
+
// Status: green, amber and red at the lightness that reads on the ground at 3:1 (marks, not body text).
|
|
176
|
+
for (const [name, hue] of [["ok", 145], ["warn", 75], ["error", 25]]) {
|
|
177
|
+
const dark = oklch(ground)[0] < 0.5;
|
|
178
|
+
let found = null;
|
|
179
|
+
for (let L = dark ? 0.6 : 0.6; dark ? L <= 0.95 : L >= 0.2; L += dark ? 0.02 : -0.02) {
|
|
180
|
+
const c = fromOklch([L, 0.15, hue]);
|
|
181
|
+
if (contrast(c, ground) >= markNeed) { found = c; break; }
|
|
182
|
+
}
|
|
183
|
+
if (found) role(`status ${name}`, found, ground, markNeed, "its hue at the lightness that reads on the ground");
|
|
184
|
+
}
|
|
185
|
+
const failing = roles.filter((r) => r.ok === false);
|
|
186
|
+
if (json) console.log(JSON.stringify({ roles }, null, 1));
|
|
187
|
+
else {
|
|
188
|
+
for (const r of roles) console.log([r.role, r.colour, r.on || "", r.contrast ?? "", r.need ? `${r.need}:1` : "", r.rule].join("\t"));
|
|
189
|
+
}
|
|
190
|
+
for (const r of failing) console.error(`colours: ${r.role} ${r.colour} is ${r.contrast}:1 on ${r.on}, under ${r.need}:1`);
|
|
191
|
+
process.exit(failing.length ? 1 : 0);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const rows = [];
|
|
195
|
+
const seen = new Set();
|
|
196
|
+
const add = (row, label, colour, extra) => {
|
|
197
|
+
if (!colour || seen.has(`${row}${colour}`)) return;
|
|
198
|
+
seen.add(`${row}${colour}`);
|
|
199
|
+
rows.push({ row, label, colour, ...extra });
|
|
200
|
+
};
|
|
201
|
+
// Grounds: each with an ink. The built ink is part of the chosen look (tan on brown), so it stays
|
|
202
|
+
// wherever it reads; only where it fails does the ground take near-black or near-white, whichever
|
|
203
|
+
// reads best.
|
|
204
|
+
const inks = ["#111111", "#f7f7f5"];
|
|
205
|
+
const groundOption = (label, colour) => {
|
|
206
|
+
const own = contrast(ink, colour);
|
|
207
|
+
const best = own >= textNeed ? [ink, own] : inks.map((i) => [i, contrast(i, colour)]).sort((a, b) => b[1] - a[1])[0];
|
|
208
|
+
if (best[1] >= textNeed) add("ground", label, colour, { ink: best[0], contrast: cut(best[1]) });
|
|
209
|
+
};
|
|
210
|
+
groundOption("as built", ground);
|
|
211
|
+
groundOption("lighter", step(ground, "lighter"));
|
|
212
|
+
groundOption("darker", step(ground, "darker"));
|
|
213
|
+
groundOption("warmer", step(ground, "warmer"));
|
|
214
|
+
groundOption("cooler", step(ground, "cooler"));
|
|
215
|
+
const family = list(familyArg);
|
|
216
|
+
const theirs = list(theirsArg);
|
|
217
|
+
for (const c of family) if (oklch(c)[1] < 0.08) groundOption("the family's", c);
|
|
218
|
+
for (const c of theirs) groundOption("theirs", c);
|
|
219
|
+
// Ink: its own row, the built ink first, each on the built ground at the text level or out.
|
|
220
|
+
const inkOption = (label, colour) => {
|
|
221
|
+
const k = contrast(colour, ground);
|
|
222
|
+
if (k >= textNeed) add("ink", label, colour, { contrast: cut(k) });
|
|
223
|
+
};
|
|
224
|
+
inkOption("as built", ink);
|
|
225
|
+
for (const kind of ["lighter", "darker", "warmer", "cooler"]) inkOption(kind, step(ink, kind));
|
|
226
|
+
inkOption("near-black", "#111111");
|
|
227
|
+
inkOption("near-white", "#f7f7f5");
|
|
228
|
+
for (const c of theirs) inkOption("theirs", c);
|
|
229
|
+
// Accents: against the chosen ground, at the accent level or out.
|
|
230
|
+
const accentOption = (label, colour) => {
|
|
231
|
+
const k = contrast(colour, ground);
|
|
232
|
+
if (k >= accentNeed) add("accent", label, colour, { contrast: cut(k) });
|
|
233
|
+
};
|
|
234
|
+
if (accent) {
|
|
235
|
+
accentOption("as built", accent);
|
|
236
|
+
for (const kind of ["lighter", "darker", "warmer", "cooler"]) accentOption(kind, step(accent, kind));
|
|
237
|
+
}
|
|
238
|
+
for (const c of family) if (oklch(c)[1] >= 0.08) accentOption("the family's", c);
|
|
239
|
+
for (const c of theirs) accentOption("theirs", c);
|
|
240
|
+
add("accent", "none", "none", {});
|
|
241
|
+
|
|
242
|
+
const left = [...(accent && !rows.some((r) => r.row === "accent" && r.label === "as built") ? [`the built accent (under ${accentNeed}:1 on this ground)`] : [])];
|
|
243
|
+
if (json) console.log(JSON.stringify({ rows, left }, null, 1));
|
|
244
|
+
else {
|
|
245
|
+
for (const r of rows) console.log([r.row, r.label, r.colour, r.ink || "", r.contrast ?? ""].join("\t"));
|
|
246
|
+
for (const l of left) console.error(`colours: left out ${l}`);
|
|
247
|
+
}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
//
|
|
21
21
|
// --topics .longbeard/design/families/board.md: each card takes its family from
|
|
22
22
|
// that board, matched by name, so the moodboard's own cards (with their like,
|
|
23
|
-
// avoid and move lines) are shown under the families
|
|
23
|
+
// avoid and move lines) are shown under the families that board names.
|
|
24
24
|
// A card in no family keeps its part. Every card stays.
|
|
25
25
|
//
|
|
26
26
|
// --one-lead: one Lead on the whole board, not one per group. The direction's
|