@jonandev/longbeard 0.13.0 → 0.15.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 +35 -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 +7 -11
- package/skills/design-brief/SKILL.md +5 -35
- package/skills/design-check/SKILL.md +5 -7
- package/skills/design-check/references/design-rules.md +26 -4
- package/skills/design-check/scripts/rules.mjs +143 -9
- package/skills/design-content/SKILL.md +3 -8
- package/skills/design-direction/SKILL.md +58 -53
- 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 +7 -7
- package/skills/design-direction/references/screen-template.html +7 -164
- package/skills/design-direction/references/screen.js +163 -0
- package/skills/design-direction/references/subject.md +3 -3
- 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 +4 -6
- package/skills/design-identity/SKILL.md +12 -14
- 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 +11 -11
- package/skills/design-moodboard/references/graphic.md +1 -1
- package/skills/design-moodboard/references/sources.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 -49
- package/skills/design-prototype/references/design-floor.md +118 -0
- package/skills/design-prototype/references/design-md-template.md +4 -2
- 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 +9 -8
- package/skills/design-wordmark/scripts/sheet.mjs +3 -1
- package/skills/framework-skills/SKILL.md +3 -5
- package/skills/idea/SKILL.md +7 -9
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Direction for a graphic
|
|
2
2
|
|
|
3
|
-
Read when the product brief's surface is a graphic. Everything in `SKILL.md`
|
|
3
|
+
Read when the product brief's surface is a graphic. Everything in `SKILL.md` holds except what is said here. A piece counts as a screen wherever a skill says screen, and the eight screens are eight pieces.
|
|
4
4
|
|
|
5
5
|
## The size
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@ The size is the format in `docs/brief.md`, never phone or desktop. The design br
|
|
|
8
8
|
|
|
9
9
|
- **On screen:** the pixels the format gives.
|
|
10
10
|
- **In print:** the paper's ratio, at a working width of 1200 px (A3 portrait is 1200 × 1697). Figma carries the real size later.
|
|
11
|
-
- **Build at it:** each screen is built at `?size=<width>x<height>`, and the page's own default size is set to the format, so every later capture is the whole piece.
|
|
12
|
-
- **Capture at it.** Every `--clip 0,0,1440,900`
|
|
11
|
+
- **Build at it:** each screen is built at `?size=<width>x<height>`, and the page's own default size is set to the format, so every later capture is the whole piece. "1440 by 900" means this working size, and every measure stays a share of the piece's width and height.
|
|
12
|
+
- **Capture at it.** Every `--clip 0,0,1440,900` is `--width <w> --clip 0,0,<w>,<h>` at this size, whole piece, never its top half. On the canvas a tall piece shows whole, at its own proportions; look at it before showing it.
|
|
13
13
|
- **A reference of another proportion** (a wide poster for a tall brief) is a base only if its layout survives at the format's ratio, with each measure kept as a share of its own sides. Otherwise it lends moves and is never a base.
|
|
14
14
|
|
|
15
15
|
## What the pieces carry
|
|
@@ -20,10 +20,9 @@ The size is the format in `docs/brief.md`, never phone or desktop. The design br
|
|
|
20
20
|
- **No navigation.** The direction doc says `navigation: none`.
|
|
21
21
|
- **The rest** (the second language, the small print, other sizes of a set) is written down for `design-prototype`.
|
|
22
22
|
|
|
23
|
-
##
|
|
23
|
+
## Checks and the trim
|
|
24
24
|
|
|
25
|
-
- **
|
|
26
|
-
- **Touch-up:** the same rule, repair and never tidy. Contrast where text sits is fixed; so is a fact the brief gives that is not on the piece, added where the facts sit. Text over a picture, giant type, crops, overlaps and collisions are never faults here, and type cropped by the edge on purpose carries `data-crop`.
|
|
25
|
+
- **Checks:** the same rule, a check reports and the concept wins. Contrast where text sits is fixed; so is a fact the brief gives that is not on the piece, added where the facts sit. Text over a picture, giant type, crops, overlaps and collisions are never faults here, and type cropped by the edge on purpose carries `data-crop`.
|
|
27
26
|
- **Nothing important in the trim:** on a print piece, mark where the trim and a safe margin fall at the working size (3 mm each by default, theirs if they give one). A word or a fact in the trim is a fault. A crop or a picture that runs off the edge on purpose is not.
|
|
28
27
|
|
|
29
28
|
## The doc
|
|
@@ -22,18 +22,18 @@ Write `.longbeard/design/direction/library.json`, one reading per reference (the
|
|
|
22
22
|
"motion": { "what": "…", "trigger": "…", "ms": 600, "easing": "…", "character": "…", "by": "page | frames | not seen" },
|
|
23
23
|
"finish": { "css": "…", "by": "page | eye" },
|
|
24
24
|
"picture_kind": "photo | illustration | 3d | mixed",
|
|
25
|
-
"slots": { "headline": { "words": 3, "lines": 2 }, "small": 3, "pictures": 1 },
|
|
25
|
+
"slots": { "headline": { "words": 3, "lines": 2 }, "small": 3, "blocks": 5, "pictures": 1 },
|
|
26
26
|
"devices": ["<each element that is not content: a disc, a ruled line, a word band, a ring of text>"],
|
|
27
27
|
"measured": { "empty": 62, "pictures": 28, "radius": 12 }
|
|
28
28
|
}]
|
|
29
29
|
}
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
## Measure
|
|
32
|
+
## Measure a page, read a picture
|
|
33
33
|
|
|
34
34
|
**A live page:** `measure.mjs <link>` lists its fonts, sizes, weights, colours and gradients (`by: page`). It also lists the page's motion (each transition and animation with its property, time, easing and trigger) and its finish (shadows, filters, blends and textures with the share of the screen they cover), read before anything is judged by eye.
|
|
35
35
|
|
|
36
|
-
**A reference that is only a picture** (a shot, a poster, a presentation frame):
|
|
36
|
+
**A reference that is only a picture** (a shot, a poster, a presentation frame): read it yourself, at full size: the layout as shares of the screen, the type sizes at 1440 wide, the colours, how much is empty. Its reading says `by: eye`. Scripts guess at pictures; your eye is the better reader, and gets better with every model. For a number you cannot read (a size on a busy shot, the exact ground), measure it:
|
|
37
37
|
|
|
38
38
|
```
|
|
39
39
|
node <skill>/scripts/measure.mjs .longbeard/design/moodboard/refs/<name>.jpg --lines
|
|
@@ -41,7 +41,7 @@ node <skill>/scripts/measure.mjs .longbeard/design/moodboard/refs/<name>.jpg --l
|
|
|
41
41
|
|
|
42
42
|
It reads inside a presentation frame, and gives the ground, the `ink`, the palette (`common`, `loud`), how much is `empty` and how much is `pictures`, and the type: the display line's `px1440`, `weight`, `case`, `box`, the body size, the `scale`, the headline's words and lines, the text `blocks`. `--lines` lists every line it read, with its box: that is the layout's measurements. Sizes are given as px at 1440 wide, which is the size to build at.
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
A number that disagrees with what you plainly see is a misread: use your reading, and say so.
|
|
45
45
|
|
|
46
46
|
**The face, from a picture:** the nearest free face by its measured shape, of the kind you see:
|
|
47
47
|
|
|
@@ -55,11 +55,11 @@ Give it every measure the picture gave (`width`, `xheight`, `dark`, `contrast`).
|
|
|
55
55
|
|
|
56
56
|
- **`likes`:** their words from the board's note (or the card's `like:`). What they like is what the designs borrow; why is how it is used, and where it would be wrong.
|
|
57
57
|
- **`avoid`:** their words from the board's Leave out box (or the card's `avoid:`). Never on a screen built on it, never borrowed from it; the reading still records it (in `devices`, `palette`, wherever it sits), so the rebuild knows what to drop. Empty when they wrote nothing.
|
|
58
|
-
- **`concept` and `move`:** what must survive every change;
|
|
58
|
+
- **`concept` and `move`:** what must survive every change; a screen built on it keeps them.
|
|
59
59
|
- **`layout`, `type`, `spacing`:** the system, in numbers, so the rebuild is measured, not approximated. Type sizes are the reference's against its screen: a 96 px headline on a 1440 screen stays 96 px.
|
|
60
60
|
- **`palette`:** the colours as they work together. A palette is borrowed whole, or one colour they did not name is swapped for another of the same role. Never one colour picked out of it by itself.
|
|
61
61
|
- **`pictures`:** the treatment the product's pictures get on a screen built from it.
|
|
62
|
-
- **`slots`:** how much text it carries; a screen built on it carries the same, and one small element more at most.
|
|
62
|
+
- **`slots`:** how much text it carries, with its text `blocks` as `measure.mjs` counts them (or by eye); a screen built on it carries the same, and one small element more at most.
|
|
63
63
|
- **`devices`:** every element that is not content, so each on a screen traces to one.
|
|
64
64
|
|
|
65
65
|
## Motion, finish and picture kind
|
|
@@ -72,6 +72,6 @@ What a reference cannot show is "not seen", never guessed.
|
|
|
72
72
|
|
|
73
73
|
## The subject
|
|
74
74
|
|
|
75
|
-
The subject is a card on the board and is read like a reference, without a layout and never a base.
|
|
75
|
+
The subject is a card on the board and is read like a reference, without a layout and never a base. Its palette comes from [subject.md](subject.md). Write it as `"subject": { "ground", "ink", "accent", "likes": [{ "what", "why" }], "things": ["<what they liked in its pictures or world: a stamp, a number, a paper bag>"] }`. A liked thing is a move that may change form (principle 4).
|
|
76
76
|
|
|
77
77
|
**Record, never judge.** A gradient, a glow, a face the rules call a tell: if a reference uses it, it is in its reading. What they own goes in `"theirs"`; a refused face or colour is left out; light only or dark only leaves out the readings' palettes of the other kind as borrowable palettes, never the references.
|
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
<!--
|
|
3
3
|
One direction screen, to copy to .longbeard/design/direction/screens/<n>.html.
|
|
4
4
|
A screen is one reference rebuilt faithfully with the product's content, then
|
|
5
|
-
changed by one or two moves borrowed from other references
|
|
5
|
+
changed by one or two moves borrowed from other references. Write
|
|
6
6
|
it as a designer would write a static page: plain HTML and CSS, measured
|
|
7
|
-
sizes in px at the screen's width.
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
sizes in px at the screen's width. What is the same every time (the look as
|
|
8
|
+
variables, overrides in the URL, the faces loaded, the title set to "ready"
|
|
9
|
+
so a capture can wait for it, the live controls) is screen.js, copied once
|
|
10
|
+
beside the pages and loaded last. Never paste it into a page.
|
|
10
11
|
|
|
11
12
|
WRITE three things:
|
|
12
13
|
- LOOK: the faces and colours this screen uses, by role. Every colour and
|
|
@@ -19,7 +20,7 @@
|
|
|
19
20
|
- PROVENANCE: for every face, colour, element and effect on the screen, the
|
|
20
21
|
reference it comes from. Anything that cannot name one does not belong.
|
|
21
22
|
|
|
22
|
-
URL overrides (design-identity
|
|
23
|
+
URL overrides (design-identity): ?face= &body= &weight=
|
|
23
24
|
&ground=%23… &ink=%23… &accent=%23… (accent=none hides it) &size=390x844.
|
|
24
25
|
|
|
25
26
|
CONTROLS: empty in a built screen. When the screen is chosen, first.html gets
|
|
@@ -69,165 +70,7 @@ const CONTROLS = {
|
|
|
69
70
|
// accent: [["#f4f1ea", "#e2501c"]], // each reference's ground and accent, as its reading has them
|
|
70
71
|
// radius: [0, 24], // the usual corner in px at 1440: least and most
|
|
71
72
|
};
|
|
72
|
-
// ---------------------------------------------------------------- controls: the measures (plain functions)
|
|
73
|
-
const Controls = {
|
|
74
|
-
rgb: (hex) => { const h = hex.replace("#", ""); const f = h.length === 3 ? h.replace(/./g, "$&$&") : h; return [0, 2, 4].map((i) => parseInt(f.slice(i, i + 2), 16)); },
|
|
75
|
-
hex: (c) => "#" + c.map((v) => Math.round(Math.min(255, Math.max(0, v))).toString(16).padStart(2, "0")).join(""),
|
|
76
|
-
lum: (c) => { const [r, g, b] = c.map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4; }); return 0.2126 * r + 0.7152 * g + 0.0722 * b; },
|
|
77
|
-
contrast(a, b) { const x = this.lum(this.rgb(a)), y = this.lum(this.rgb(b)); return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05); },
|
|
78
|
-
// [least, most] of the numbers, or null when the board has no range (fewer than two values, or all alike).
|
|
79
|
-
range(list) { const v = (Array.isArray(list) ? list : []).filter((n) => typeof n === "number" && isFinite(n)); if (v.length < 2) return null; const lo = Math.min(...v), hi = Math.max(...v); return hi > lo ? [lo, hi] : null; },
|
|
80
|
-
// The board's range, widened to hold the screen's own value, so the screen can always come back to itself.
|
|
81
|
-
span(range, own) { return [Math.min(range[0], own), Math.max(range[1], own)]; },
|
|
82
|
-
// The accent's contrast against the ground, for each pair (ground, accent) the board has.
|
|
83
|
-
accentRatios(pairs) { return (Array.isArray(pairs) ? pairs : []).filter((p) => Array.isArray(p) && p[0] && p[1]).map((p) => Math.round(10 * this.contrast(p[1], p[0])) / 10); },
|
|
84
|
-
// The accent moved along the line from the ground through itself, to the contrast asked for.
|
|
85
|
-
accentAt(ground, accent, target) {
|
|
86
|
-
const g = this.rgb(ground), a = this.rgb(accent);
|
|
87
|
-
let best = null;
|
|
88
|
-
for (let t = 0; t <= 3.001; t += 0.01) {
|
|
89
|
-
const hex = this.hex(g.map((v, i) => v + (a[i] - v) * t));
|
|
90
|
-
const d = Math.abs(this.contrast(hex, ground) - target);
|
|
91
|
-
if (!best || d < best.d - 1e-9) best = { d, hex };
|
|
92
|
-
}
|
|
93
|
-
return { hex: best.hex, ratio: Math.round(10 * this.contrast(best.hex, ground)) / 10 };
|
|
94
|
-
},
|
|
95
|
-
// What the person pastes back: only what moved, in the measures the board gives.
|
|
96
|
-
copy(lines) { return lines.length ? ["Adjusted on this screen (own to chosen). Record in first.html's LOOK and CSS, not in the address:", ...lines].join("\n") : "Nothing moved: the screen as it was."; },
|
|
97
|
-
};
|
|
98
|
-
// ---------------------------------------------------------------- controls: the panel (only with ?controls, never in a capture)
|
|
99
|
-
function mountControls(look) {
|
|
100
|
-
const set = (k, v) => document.documentElement.style.setProperty(k, v);
|
|
101
|
-
const root = document.getElementById("screen");
|
|
102
|
-
const all = [...root.querySelectorAll("*")];
|
|
103
|
-
const px = (v) => parseFloat(v) || 0;
|
|
104
|
-
const round = (n, d) => Math.round(n * d) / d;
|
|
105
|
-
const display = all.filter((e) => e.classList.contains("display") && !e.parentElement.closest(".display") && e.textContent.trim()).map((e) => {
|
|
106
|
-
const cs = getComputedStyle(e), size = px(cs.fontSize), lh = px(cs.lineHeight);
|
|
107
|
-
return { e, size, lead: cs.lineHeight.endsWith("px") && lh ? lh / size : 1.2 };
|
|
108
|
-
});
|
|
109
|
-
const chars = new Map();
|
|
110
|
-
for (const e of all) {
|
|
111
|
-
if (e.closest(".display")) continue;
|
|
112
|
-
const n = [...e.childNodes].filter((c) => c.nodeType === 3).map((c) => c.textContent.trim()).join("").length;
|
|
113
|
-
if (n) { const s = Math.round(px(getComputedStyle(e).fontSize)); chars.set(s, (chars.get(s) || 0) + n); }
|
|
114
|
-
}
|
|
115
|
-
const body = [...chars].sort((a, b) => b[1] - a[1])[0]?.[0] || 0;
|
|
116
|
-
const biggest = display.slice().sort((a, b) => b.size - a.size)[0];
|
|
117
|
-
const corners = ["TopLeft", "TopRight", "BottomRight", "BottomLeft"];
|
|
118
|
-
const rounded = [];
|
|
119
|
-
for (const e of all) {
|
|
120
|
-
const cs = getComputedStyle(e), r = e.getBoundingClientRect(), half = Math.min(r.width, r.height) / 2;
|
|
121
|
-
const raw = corners.map((c) => cs[`border${c}Radius`]);
|
|
122
|
-
if (raw.some((v) => /[%/ ]/.test(v))) continue;
|
|
123
|
-
const v = raw.map(px);
|
|
124
|
-
if (v.some((n) => n > 0) && v.every((n) => n < half)) rounded.push({ e, v });
|
|
125
|
-
}
|
|
126
|
-
const tally = new Map();
|
|
127
|
-
for (const { v } of rounded) { const n = Math.round(v.find((x) => x > 0)); tally.set(n, (tally.get(n) || 0) + 1); }
|
|
128
|
-
const ownRadius = [...tally].sort((a, b) => b[1] - a[1])[0]?.[0] || 0;
|
|
129
|
-
const state = {};
|
|
130
|
-
const kinds = [];
|
|
131
|
-
const type = Controls.range(CONTROLS.type), lead = Controls.range(CONTROLS.leading), rad = Controls.range(CONTROLS.radius), acc = Controls.range(Controls.accentRatios(CONTROLS.accent));
|
|
132
|
-
const ownAccent = look.accent ? round(Controls.contrast(look.accent, look.ground), 10) : 0;
|
|
133
|
-
const refresh = () => {
|
|
134
|
-
const kt = state.type === undefined ? 1 : state.type / (biggest.size / body), kl = state.leading === undefined ? 1 : state.leading / biggest.lead;
|
|
135
|
-
for (const d of display) {
|
|
136
|
-
d.e.style.fontSize = kt === 1 ? "" : `${d.size * kt}px`;
|
|
137
|
-
d.e.style.lineHeight = kt === 1 && kl === 1 ? "" : String(d.lead * kl);
|
|
138
|
-
}
|
|
139
|
-
const kr = state.radius === undefined ? 1 : state.radius / ownRadius;
|
|
140
|
-
for (const { e, v } of rounded) corners.forEach((c, i) => { e.style[`border${c}Radius`] = kr === 1 || !v[i] ? "" : `${v[i] * kr}px`; });
|
|
141
|
-
state.accentHex = state.accent === undefined || Math.abs(state.accent - ownAccent) < 0.05 ? look.accent : Controls.accentAt(look.ground, look.accent, state.accent).hex;
|
|
142
|
-
if (look.accent) set("--accent", state.accentHex);
|
|
143
|
-
};
|
|
144
|
-
if (biggest && body && type) {
|
|
145
|
-
const own = round(biggest.size / body, 10);
|
|
146
|
-
kinds.push({ key: "type", label: "Type scale", note: "display over text", own, range: Controls.span(type, own), step: 0.1,
|
|
147
|
-
line: (v) => `type scale: ${own} to ${v} (every display size x ${round(v / own, 100)}; text stays ${body}px)` });
|
|
148
|
-
}
|
|
149
|
-
if (biggest && lead) {
|
|
150
|
-
const own = round(biggest.lead, 100);
|
|
151
|
-
kinds.push({ key: "leading", label: "Line spacing", note: "display line height", own, range: Controls.span(lead, own), step: 0.01,
|
|
152
|
-
line: (v) => `line spacing: ${own} to ${v} (every display line height x ${round(v / own, 100)})` });
|
|
153
|
-
}
|
|
154
|
-
if (look.accent && acc) {
|
|
155
|
-
kinds.push({ key: "accent", label: "Accent strength", note: "contrast against the ground", own: ownAccent, range: Controls.span(acc, ownAccent), step: 0.1,
|
|
156
|
-
line: () => `accent: ${look.accent} to ${state.accentHex} (${ownAccent}:1 to ${round(Controls.contrast(state.accentHex, look.ground), 10)}:1 against the ground)` });
|
|
157
|
-
}
|
|
158
|
-
if (ownRadius && rad) {
|
|
159
|
-
kinds.push({ key: "radius", label: "Corner radius", note: "px, rounded corners only", own: ownRadius, range: Controls.span(rad, ownRadius), step: 1,
|
|
160
|
-
line: (v) => `corner radius: ${ownRadius}px to ${v}px (every rounded corner x ${round(v / ownRadius, 100)}; discs, pills and arches stay)` });
|
|
161
|
-
}
|
|
162
|
-
if (!kinds.length) return;
|
|
163
|
-
const style = Object.assign(document.createElement("style"), { textContent: "#lb-controls{position:fixed;right:12px;bottom:12px;z-index:99999;font:12px/1.4 system-ui,sans-serif;color:#111;text-align:left}#lb-controls *{box-sizing:border-box}#lb-controls .lb-box{width:290px;margin-bottom:6px;padding:12px;background:#fff;border:1px solid #111;display:none}#lb-controls.lb-open .lb-box{display:block}#lb-controls label{display:block;margin:0 0 10px}#lb-controls label b{display:flex;justify-content:space-between}#lb-controls small{color:#555}#lb-controls input[type=range]{width:100%}#lb-controls button{font:inherit;padding:4px 8px;margin-right:6px;background:#fff;color:#111;border:1px solid #111;cursor:pointer}#lb-controls textarea{display:block;width:100%;height:96px;margin-top:8px;font:11px/1.3 ui-monospace,monospace;resize:none}" });
|
|
164
|
-
const panel = Object.assign(document.createElement("div"), { id: "lb-controls" });
|
|
165
|
-
const box = Object.assign(document.createElement("div"), { className: "lb-box" });
|
|
166
|
-
const out = Object.assign(document.createElement("textarea"), { readOnly: true });
|
|
167
|
-
const show = () => { out.value = Controls.copy(kinds.filter((k) => state[k.key] !== undefined && state[k.key] !== k.own).map((k) => k.line(state[k.key]))); };
|
|
168
|
-
for (const k of kinds) {
|
|
169
|
-
const label = document.createElement("label"), head = document.createElement("b"), name = document.createElement("span"), val = document.createElement("span");
|
|
170
|
-
const input = Object.assign(document.createElement("input"), { type: "range", min: k.range[0], max: k.range[1], step: k.step, value: k.own });
|
|
171
|
-
const list = Object.assign(document.createElement("datalist"), { id: `lb-own-${k.key}` }), tick = Object.assign(document.createElement("option"), { value: k.own }), note = document.createElement("small");
|
|
172
|
-
list.appendChild(tick);
|
|
173
|
-
input.setAttribute("list", list.id);
|
|
174
|
-
name.textContent = k.label;
|
|
175
|
-
val.textContent = k.own;
|
|
176
|
-
note.textContent = `${k.note}: its own ${k.own} (the tick); the board ${round(k.range[0], 100)} to ${round(k.range[1], 100)}`;
|
|
177
|
-
input.oninput = () => { state[k.key] = Number(input.value); val.textContent = input.value; refresh(); show(); };
|
|
178
|
-
k.reset = () => { delete state[k.key]; input.value = k.own; val.textContent = k.own; };
|
|
179
|
-
head.append(name, val);
|
|
180
|
-
label.append(head, input, list, note);
|
|
181
|
-
box.appendChild(label);
|
|
182
|
-
}
|
|
183
|
-
const button = (text, click) => Object.assign(document.createElement("button"), { textContent: text, onclick: click });
|
|
184
|
-
box.append(
|
|
185
|
-
button("Reset", () => { kinds.forEach((k) => k.reset()); refresh(); show(); }),
|
|
186
|
-
button("Copy", () => { out.select(); try { navigator.clipboard.writeText(out.value).catch(() => document.execCommand("copy")); } catch (_) { document.execCommand("copy"); } }),
|
|
187
|
-
out,
|
|
188
|
-
);
|
|
189
|
-
panel.append(box, button("Adjust", () => panel.classList.toggle("lb-open")));
|
|
190
|
-
document.head.appendChild(style);
|
|
191
|
-
document.body.appendChild(panel);
|
|
192
|
-
show();
|
|
193
|
-
}
|
|
194
|
-
// ---------------------------------------------------------------- the same every time
|
|
195
|
-
(async () => {
|
|
196
|
-
const q = new URLSearchParams(location.search);
|
|
197
|
-
const look = { ...LOOK, more: { ...(LOOK.more || {}) } };
|
|
198
|
-
for (const k of ["face", "body", "ground", "ink"]) if (q.get(k)) look[k] = q.get(k);
|
|
199
|
-
if (q.get("weight")) look.weight = Number(q.get("weight"));
|
|
200
|
-
if (q.get("accent")) look.accent = q.get("accent") === "none" ? null : q.get("accent");
|
|
201
|
-
const [W, H] = (q.get("size") || "1440x900").split("x").map(Number);
|
|
202
|
-
const set = (k, v) => document.documentElement.style.setProperty(k, v);
|
|
203
|
-
set("--w", W + "px");
|
|
204
|
-
set("--h", H + "px");
|
|
205
|
-
set("--face", `"${look.face}"`);
|
|
206
|
-
set("--weight", look.weight || 400);
|
|
207
|
-
set("--body-face", `"${look.body || look.face}"`);
|
|
208
|
-
set("--ground", look.ground);
|
|
209
|
-
set("--ink", look.ink);
|
|
210
|
-
set("--accent", look.accent || look.ink);
|
|
211
|
-
for (const [k, v] of Object.entries(look.more)) set(`--${k}`, v);
|
|
212
|
-
document.body.dataset.provenance = PROVENANCE.length;
|
|
213
|
-
const wanted = [[look.face, look.weight || 400], [look.body || look.face, 400], [look.body || look.face, 700]];
|
|
214
|
-
const sheets = [];
|
|
215
|
-
for (const href of look.css || []) wanted.push([null, null, href]);
|
|
216
|
-
for (const [face, weight, href] of wanted) {
|
|
217
|
-
const urls = href ? [href] : [`https://fonts.googleapis.com/css2?family=${encodeURIComponent(face).replace(/%20/g, "+")}:wght@${weight}&display=block`, `https://fonts.googleapis.com/css2?family=${encodeURIComponent(face).replace(/%20/g, "+")}&display=block`];
|
|
218
|
-
for (const url of urls) {
|
|
219
|
-
if (document.querySelector(`link[href="${url}"]`)) continue;
|
|
220
|
-
const link = Object.assign(document.createElement("link"), { rel: "stylesheet", href: url });
|
|
221
|
-
sheets.push(new Promise((done) => ((link.onload = done), (link.onerror = done))));
|
|
222
|
-
document.head.appendChild(link);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
await Promise.all(sheets);
|
|
226
|
-
await Promise.all(wanted.filter(([f]) => f).map(([f, w]) => document.fonts.load(`${w} 100px "${f}"`).catch(() => [])));
|
|
227
|
-
await document.fonts.ready;
|
|
228
|
-
document.title = "ready";
|
|
229
|
-
if (q.has("controls") && !q.has("capture")) mountControls(look);
|
|
230
|
-
})();
|
|
231
73
|
</script>
|
|
74
|
+
<script src="screen.js"></script>
|
|
232
75
|
</body>
|
|
233
76
|
</html>
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// The fixed part of every direction screen: the look from the URL, the faces
|
|
2
|
+
// loaded, the title set to "ready", and the live controls (only with ?controls).
|
|
3
|
+
// Copy it once beside the screens (screens/screen.js, prototype/screen.js); each
|
|
4
|
+
// page loads it after its own LOOK, PROVENANCE and CONTROLS. Never edit a copy.
|
|
5
|
+
// ---------------------------------------------------------------- controls: the measures (plain functions)
|
|
6
|
+
const Controls = {
|
|
7
|
+
rgb: (hex) => { const h = hex.replace("#", ""); const f = h.length === 3 ? h.replace(/./g, "$&$&") : h; return [0, 2, 4].map((i) => parseInt(f.slice(i, i + 2), 16)); },
|
|
8
|
+
hex: (c) => "#" + c.map((v) => Math.round(Math.min(255, Math.max(0, v))).toString(16).padStart(2, "0")).join(""),
|
|
9
|
+
lum: (c) => { const [r, g, b] = c.map((v) => { v /= 255; return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4; }); return 0.2126 * r + 0.7152 * g + 0.0722 * b; },
|
|
10
|
+
contrast(a, b) { const x = this.lum(this.rgb(a)), y = this.lum(this.rgb(b)); return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05); },
|
|
11
|
+
// [least, most] of the numbers, or null when the board has no range (fewer than two values, or all alike).
|
|
12
|
+
range(list) { const v = (Array.isArray(list) ? list : []).filter((n) => typeof n === "number" && isFinite(n)); if (v.length < 2) return null; const lo = Math.min(...v), hi = Math.max(...v); return hi > lo ? [lo, hi] : null; },
|
|
13
|
+
// The board's range, widened to hold the screen's own value, so the screen can always come back to itself.
|
|
14
|
+
span(range, own) { return [Math.min(range[0], own), Math.max(range[1], own)]; },
|
|
15
|
+
// The accent's contrast against the ground, for each pair (ground, accent) the board has.
|
|
16
|
+
accentRatios(pairs) { return (Array.isArray(pairs) ? pairs : []).filter((p) => Array.isArray(p) && p[0] && p[1]).map((p) => Math.round(10 * this.contrast(p[1], p[0])) / 10); },
|
|
17
|
+
// The accent moved along the line from the ground through itself, to the contrast asked for.
|
|
18
|
+
accentAt(ground, accent, target) {
|
|
19
|
+
const g = this.rgb(ground), a = this.rgb(accent);
|
|
20
|
+
let best = null;
|
|
21
|
+
for (let t = 0; t <= 3.001; t += 0.01) {
|
|
22
|
+
const hex = this.hex(g.map((v, i) => v + (a[i] - v) * t));
|
|
23
|
+
const d = Math.abs(this.contrast(hex, ground) - target);
|
|
24
|
+
if (!best || d < best.d - 1e-9) best = { d, hex };
|
|
25
|
+
}
|
|
26
|
+
return { hex: best.hex, ratio: Math.round(10 * this.contrast(best.hex, ground)) / 10 };
|
|
27
|
+
},
|
|
28
|
+
// What the person pastes back: only what moved, in the measures the board gives.
|
|
29
|
+
copy(lines) { return lines.length ? ["Adjusted on this screen (own to chosen). Record in first.html's LOOK and CSS, not in the address:", ...lines].join("\n") : "Nothing moved: the screen as it was."; },
|
|
30
|
+
};
|
|
31
|
+
// ---------------------------------------------------------------- controls: the panel (only with ?controls, never in a capture)
|
|
32
|
+
function mountControls(look) {
|
|
33
|
+
const set = (k, v) => document.documentElement.style.setProperty(k, v);
|
|
34
|
+
const root = document.getElementById("screen");
|
|
35
|
+
const all = [...root.querySelectorAll("*")];
|
|
36
|
+
const px = (v) => parseFloat(v) || 0;
|
|
37
|
+
const round = (n, d) => Math.round(n * d) / d;
|
|
38
|
+
const display = all.filter((e) => e.classList.contains("display") && !e.parentElement.closest(".display") && e.textContent.trim()).map((e) => {
|
|
39
|
+
const cs = getComputedStyle(e), size = px(cs.fontSize), lh = px(cs.lineHeight);
|
|
40
|
+
return { e, size, lead: cs.lineHeight.endsWith("px") && lh ? lh / size : 1.2 };
|
|
41
|
+
});
|
|
42
|
+
const chars = new Map();
|
|
43
|
+
for (const e of all) {
|
|
44
|
+
if (e.closest(".display")) continue;
|
|
45
|
+
const n = [...e.childNodes].filter((c) => c.nodeType === 3).map((c) => c.textContent.trim()).join("").length;
|
|
46
|
+
if (n) { const s = Math.round(px(getComputedStyle(e).fontSize)); chars.set(s, (chars.get(s) || 0) + n); }
|
|
47
|
+
}
|
|
48
|
+
const body = [...chars].sort((a, b) => b[1] - a[1])[0]?.[0] || 0;
|
|
49
|
+
const biggest = display.slice().sort((a, b) => b.size - a.size)[0];
|
|
50
|
+
const corners = ["TopLeft", "TopRight", "BottomRight", "BottomLeft"];
|
|
51
|
+
const rounded = [];
|
|
52
|
+
for (const e of all) {
|
|
53
|
+
const cs = getComputedStyle(e), r = e.getBoundingClientRect(), half = Math.min(r.width, r.height) / 2;
|
|
54
|
+
const raw = corners.map((c) => cs[`border${c}Radius`]);
|
|
55
|
+
if (raw.some((v) => /[%/ ]/.test(v))) continue;
|
|
56
|
+
const v = raw.map(px);
|
|
57
|
+
if (v.some((n) => n > 0) && v.every((n) => n < half)) rounded.push({ e, v });
|
|
58
|
+
}
|
|
59
|
+
const tally = new Map();
|
|
60
|
+
for (const { v } of rounded) { const n = Math.round(v.find((x) => x > 0)); tally.set(n, (tally.get(n) || 0) + 1); }
|
|
61
|
+
const ownRadius = [...tally].sort((a, b) => b[1] - a[1])[0]?.[0] || 0;
|
|
62
|
+
const state = {};
|
|
63
|
+
const kinds = [];
|
|
64
|
+
const type = Controls.range(CONTROLS.type), lead = Controls.range(CONTROLS.leading), rad = Controls.range(CONTROLS.radius), acc = Controls.range(Controls.accentRatios(CONTROLS.accent));
|
|
65
|
+
const ownAccent = look.accent ? round(Controls.contrast(look.accent, look.ground), 10) : 0;
|
|
66
|
+
const refresh = () => {
|
|
67
|
+
const kt = state.type === undefined ? 1 : state.type / (biggest.size / body), kl = state.leading === undefined ? 1 : state.leading / biggest.lead;
|
|
68
|
+
for (const d of display) {
|
|
69
|
+
d.e.style.fontSize = kt === 1 ? "" : `${d.size * kt}px`;
|
|
70
|
+
d.e.style.lineHeight = kt === 1 && kl === 1 ? "" : String(d.lead * kl);
|
|
71
|
+
}
|
|
72
|
+
const kr = state.radius === undefined ? 1 : state.radius / ownRadius;
|
|
73
|
+
for (const { e, v } of rounded) corners.forEach((c, i) => { e.style[`border${c}Radius`] = kr === 1 || !v[i] ? "" : `${v[i] * kr}px`; });
|
|
74
|
+
state.accentHex = state.accent === undefined || Math.abs(state.accent - ownAccent) < 0.05 ? look.accent : Controls.accentAt(look.ground, look.accent, state.accent).hex;
|
|
75
|
+
if (look.accent) set("--accent", state.accentHex);
|
|
76
|
+
};
|
|
77
|
+
if (biggest && body && type) {
|
|
78
|
+
const own = round(biggest.size / body, 10);
|
|
79
|
+
kinds.push({ key: "type", label: "Type scale", note: "display over text", own, range: Controls.span(type, own), step: 0.1,
|
|
80
|
+
line: (v) => `type scale: ${own} to ${v} (every display size x ${round(v / own, 100)}; text stays ${body}px)` });
|
|
81
|
+
}
|
|
82
|
+
if (biggest && lead) {
|
|
83
|
+
const own = round(biggest.lead, 100);
|
|
84
|
+
kinds.push({ key: "leading", label: "Line spacing", note: "display line height", own, range: Controls.span(lead, own), step: 0.01,
|
|
85
|
+
line: (v) => `line spacing: ${own} to ${v} (every display line height x ${round(v / own, 100)})` });
|
|
86
|
+
}
|
|
87
|
+
if (look.accent && acc) {
|
|
88
|
+
kinds.push({ key: "accent", label: "Accent strength", note: "contrast against the ground", own: ownAccent, range: Controls.span(acc, ownAccent), step: 0.1,
|
|
89
|
+
line: () => `accent: ${look.accent} to ${state.accentHex} (${ownAccent}:1 to ${round(Controls.contrast(state.accentHex, look.ground), 10)}:1 against the ground)` });
|
|
90
|
+
}
|
|
91
|
+
if (ownRadius && rad) {
|
|
92
|
+
kinds.push({ key: "radius", label: "Corner radius", note: "px, rounded corners only", own: ownRadius, range: Controls.span(rad, ownRadius), step: 1,
|
|
93
|
+
line: (v) => `corner radius: ${ownRadius}px to ${v}px (every rounded corner x ${round(v / ownRadius, 100)}; discs, pills and arches stay)` });
|
|
94
|
+
}
|
|
95
|
+
if (!kinds.length) return;
|
|
96
|
+
const style = Object.assign(document.createElement("style"), { textContent: "#lb-controls{position:fixed;right:12px;bottom:12px;z-index:99999;font:12px/1.4 system-ui,sans-serif;color:#111;text-align:left}#lb-controls *{box-sizing:border-box}#lb-controls .lb-box{width:290px;margin-bottom:6px;padding:12px;background:#fff;border:1px solid #111;display:none}#lb-controls.lb-open .lb-box{display:block}#lb-controls label{display:block;margin:0 0 10px}#lb-controls label b{display:flex;justify-content:space-between}#lb-controls small{color:#555}#lb-controls input[type=range]{width:100%}#lb-controls button{font:inherit;padding:4px 8px;margin-right:6px;background:#fff;color:#111;border:1px solid #111;cursor:pointer}#lb-controls textarea{display:block;width:100%;height:96px;margin-top:8px;font:11px/1.3 ui-monospace,monospace;resize:none}" });
|
|
97
|
+
const panel = Object.assign(document.createElement("div"), { id: "lb-controls" });
|
|
98
|
+
const box = Object.assign(document.createElement("div"), { className: "lb-box" });
|
|
99
|
+
const out = Object.assign(document.createElement("textarea"), { readOnly: true });
|
|
100
|
+
const show = () => { out.value = Controls.copy(kinds.filter((k) => state[k.key] !== undefined && state[k.key] !== k.own).map((k) => k.line(state[k.key]))); };
|
|
101
|
+
for (const k of kinds) {
|
|
102
|
+
const label = document.createElement("label"), head = document.createElement("b"), name = document.createElement("span"), val = document.createElement("span");
|
|
103
|
+
const input = Object.assign(document.createElement("input"), { type: "range", min: k.range[0], max: k.range[1], step: k.step, value: k.own });
|
|
104
|
+
const list = Object.assign(document.createElement("datalist"), { id: `lb-own-${k.key}` }), tick = Object.assign(document.createElement("option"), { value: k.own }), note = document.createElement("small");
|
|
105
|
+
list.appendChild(tick);
|
|
106
|
+
input.setAttribute("list", list.id);
|
|
107
|
+
name.textContent = k.label;
|
|
108
|
+
val.textContent = k.own;
|
|
109
|
+
note.textContent = `${k.note}: its own ${k.own} (the tick); the board ${round(k.range[0], 100)} to ${round(k.range[1], 100)}`;
|
|
110
|
+
input.oninput = () => { state[k.key] = Number(input.value); val.textContent = input.value; refresh(); show(); };
|
|
111
|
+
k.reset = () => { delete state[k.key]; input.value = k.own; val.textContent = k.own; };
|
|
112
|
+
head.append(name, val);
|
|
113
|
+
label.append(head, input, list, note);
|
|
114
|
+
box.appendChild(label);
|
|
115
|
+
}
|
|
116
|
+
const button = (text, click) => Object.assign(document.createElement("button"), { textContent: text, onclick: click });
|
|
117
|
+
box.append(
|
|
118
|
+
button("Reset", () => { kinds.forEach((k) => k.reset()); refresh(); show(); }),
|
|
119
|
+
button("Copy", () => { out.select(); try { navigator.clipboard.writeText(out.value).catch(() => document.execCommand("copy")); } catch (_) { document.execCommand("copy"); } }),
|
|
120
|
+
out,
|
|
121
|
+
);
|
|
122
|
+
panel.append(box, button("Adjust", () => panel.classList.toggle("lb-open")));
|
|
123
|
+
document.head.appendChild(style);
|
|
124
|
+
document.body.appendChild(panel);
|
|
125
|
+
show();
|
|
126
|
+
}
|
|
127
|
+
// ---------------------------------------------------------------- the same every time
|
|
128
|
+
(async () => {
|
|
129
|
+
const q = new URLSearchParams(location.search);
|
|
130
|
+
const look = { ...LOOK, more: { ...(LOOK.more || {}) } };
|
|
131
|
+
for (const k of ["face", "body", "ground", "ink"]) if (q.get(k)) look[k] = q.get(k);
|
|
132
|
+
if (q.get("weight")) look.weight = Number(q.get("weight"));
|
|
133
|
+
if (q.get("accent")) look.accent = q.get("accent") === "none" ? null : q.get("accent");
|
|
134
|
+
const [W, H] = (q.get("size") || "1440x900").split("x").map(Number);
|
|
135
|
+
const set = (k, v) => document.documentElement.style.setProperty(k, v);
|
|
136
|
+
set("--w", W + "px");
|
|
137
|
+
set("--h", H + "px");
|
|
138
|
+
set("--face", `"${look.face}"`);
|
|
139
|
+
set("--weight", look.weight || 400);
|
|
140
|
+
set("--body-face", `"${look.body || look.face}"`);
|
|
141
|
+
set("--ground", look.ground);
|
|
142
|
+
set("--ink", look.ink);
|
|
143
|
+
set("--accent", look.accent || look.ink);
|
|
144
|
+
for (const [k, v] of Object.entries(look.more)) set(`--${k}`, v);
|
|
145
|
+
document.body.dataset.provenance = PROVENANCE.length;
|
|
146
|
+
const wanted = [[look.face, look.weight || 400], [look.body || look.face, 400], [look.body || look.face, 700]];
|
|
147
|
+
const sheets = [];
|
|
148
|
+
for (const href of look.css || []) wanted.push([null, null, href]);
|
|
149
|
+
for (const [face, weight, href] of wanted) {
|
|
150
|
+
const urls = href ? [href] : [`https://fonts.googleapis.com/css2?family=${encodeURIComponent(face).replace(/%20/g, "+")}:wght@${weight}&display=block`, `https://fonts.googleapis.com/css2?family=${encodeURIComponent(face).replace(/%20/g, "+")}&display=block`];
|
|
151
|
+
for (const url of urls) {
|
|
152
|
+
if (document.querySelector(`link[href="${url}"]`)) continue;
|
|
153
|
+
const link = Object.assign(document.createElement("link"), { rel: "stylesheet", href: url });
|
|
154
|
+
sheets.push(new Promise((done) => ((link.onload = done), (link.onerror = done))));
|
|
155
|
+
document.head.appendChild(link);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
await Promise.all(sheets);
|
|
159
|
+
await Promise.all(wanted.filter(([f]) => f).map(([f, w]) => document.fonts.load(`${w} 100px "${f}"`).catch(() => [])));
|
|
160
|
+
await document.fonts.ready;
|
|
161
|
+
document.title = "ready";
|
|
162
|
+
if (q.has("controls") && !q.has("capture")) mountControls(look);
|
|
163
|
+
})();
|
|
@@ -4,7 +4,7 @@ Read by `design-direction`, step 0 and step 2.
|
|
|
4
4
|
|
|
5
5
|
## Pictures
|
|
6
6
|
|
|
7
|
-
Before the
|
|
7
|
+
Before the screens: three or four pictures of what the product is about (the bakery's bread and its bench, the climbing gym's wall, the app's real data on a desk). Not other designs, which is the moodboard's job: the product's own world. Every screen from here on uses them, so nothing is judged on grey boxes or on another product's pictures, and their colours become one more palette (step 2).
|
|
8
8
|
|
|
9
9
|
- **Theirs first.** The design brief says whether they have pictures. If they do, ask for three or four, and save them to `.longbeard/design/pictures/`.
|
|
10
10
|
- **None yet:** find stand-ins, a few, never a bulk search. Search the subject, not a mood: the brief's identity nouns, one query per picture you need.
|
|
@@ -14,7 +14,7 @@ Before the grid: three or four pictures of what the product is about (the bakery
|
|
|
14
14
|
node <skill>/scripts/pictures.mjs "flour on a wooden bench" --out .longbeard/design/pictures --count 2 --orientation landscape
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
It keeps only
|
|
17
|
+
It keeps only freely licensed pictures large enough for a screen, and writes `credits.tsv` beside them: a credit a licence requires must appear in the product. Drop one that is off-subject and search again with a more concrete query ("roasted coffee beans", not "coffee"). After two queries that miss, ask them for two or three photos of their own, a phone is fine, or go on with fewer.
|
|
18
18
|
- **Pictures a reference could hold.** The references' pictures are clean: one subject, a plain or quiet ground, a calm crop. Prefer the stand-in that is one loaf on a plain bench to the one with a kettle and a counter behind it; crop to the subject. A picture with clutter in it makes a faithful layout look unfinished.
|
|
19
19
|
- **Of the kind the look uses.** When the moodboard is photographs, look for photographs; when it is illustration or renders, say that those are not searched, and use the closest photographs, cropped and toned as the moodboard does, until theirs exist.
|
|
20
20
|
|
|
@@ -30,4 +30,4 @@ node <skill>/scripts/subject-colours.mjs .longbeard/design/pictures --json
|
|
|
30
30
|
|
|
31
31
|
**Then look, and name every colour.** Open its sheet (`--sheet <scratch>/subject.html`, captured), which shows each proposed colour beside the pictures with the places it comes from lit up. Every colour must be something a person sees as the subject and can name: "the crust", "the flour", "the oven's black". A colour that lights up the backdrop, a cloth, a wall or a prop is not the subject's, even when it fills the photo: drop it (`--exclude "#hex"`) and run it again. The script already flags colours that sit mostly at the edges as background and never makes them the signature or the accent; the look is the check it cannot do. Write the name beside each colour wherever it is shown ("crust, lightened to carry white text").
|
|
32
32
|
|
|
33
|
-
Only then it goes in the library as `"subject"`. Never tune them stronger to make a screen livelier: a colour no reference would set a page on is not a direction they chose.
|
|
33
|
+
Its proposal is a start, not the answer: a colour you can name better from the pictures (the crust's real brown, not the averaged one) replaces it, contrast checked with `colours.mjs`. Only then it goes in the library as `"subject"`. Never tune them stronger to make a screen livelier: a colour no reference would set a page on is not a direction they chose.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Options on the real page. Each option is an element with data-variant="1", "2", …
|
|
2
|
+
// and data-from="<the reference it comes from>". The page shows one, chosen by
|
|
3
|
+
// ?variant=<n> (1 when absent), and a small bar at the bottom centre: the option's
|
|
4
|
+
// number, its reference, and arrows. ← and → flip between them and keep the URL in
|
|
5
|
+
// step, so a capture or a link opens the same option. ?bar=0 hides the bar for captures.
|
|
6
|
+
// Copy this file next to the page and load it last: <script src="variants.js"></script>
|
|
7
|
+
(() => {
|
|
8
|
+
const all = [...document.querySelectorAll("[data-variant]")];
|
|
9
|
+
const ns = [...new Set(all.map((el) => el.dataset.variant))].sort((a, b) => Number(a) - Number(b));
|
|
10
|
+
if (!ns.length) return;
|
|
11
|
+
const params = new URLSearchParams(location.search);
|
|
12
|
+
let at = Math.max(0, ns.indexOf(params.get("variant") || ns[0]));
|
|
13
|
+
const bar = document.createElement("div");
|
|
14
|
+
bar.setAttribute("role", "toolbar");
|
|
15
|
+
bar.setAttribute("aria-label", "Options");
|
|
16
|
+
bar.style.cssText = "position:fixed;left:50%;bottom:16px;transform:translateX(-50%);z-index:2147483647;display:flex;gap:12px;align-items:center;padding:8px 12px;border-radius:999px;background:#111;color:#fff;font:500 13px/1.2 system-ui,sans-serif;box-shadow:0 2px 12px rgba(0,0,0,.25)";
|
|
17
|
+
const button = (text, label, step) => {
|
|
18
|
+
const b = document.createElement("button");
|
|
19
|
+
b.type = "button";
|
|
20
|
+
b.textContent = text;
|
|
21
|
+
b.setAttribute("aria-label", label);
|
|
22
|
+
b.style.cssText = "all:unset;cursor:pointer;padding:4px 8px;min-width:24px;text-align:center";
|
|
23
|
+
b.onclick = () => show(at + step);
|
|
24
|
+
return b;
|
|
25
|
+
};
|
|
26
|
+
const label = document.createElement("span");
|
|
27
|
+
bar.append(button("←", "Previous option", -1), label, button("→", "Next option", 1));
|
|
28
|
+
function show(i) {
|
|
29
|
+
at = (i + ns.length) % ns.length;
|
|
30
|
+
for (const el of all) el.hidden = el.dataset.variant !== ns[at];
|
|
31
|
+
const from = all.find((el) => el.dataset.variant === ns[at])?.dataset.from || "";
|
|
32
|
+
label.textContent = `${at + 1} / ${ns.length}${from ? " \u00b7 from " + from : ""}`;
|
|
33
|
+
params.set("variant", ns[at]);
|
|
34
|
+
history.replaceState(null, "", "?" + params.toString() + location.hash);
|
|
35
|
+
}
|
|
36
|
+
addEventListener("keydown", (e) => {
|
|
37
|
+
if (e.target.closest?.("input, textarea, select, [contenteditable]")) return;
|
|
38
|
+
if (e.key === "ArrowLeft") show(at - 1);
|
|
39
|
+
if (e.key === "ArrowRight") show(at + 1);
|
|
40
|
+
});
|
|
41
|
+
if (params.get("bar") !== "0") document.body.append(bar);
|
|
42
|
+
show(at);
|
|
43
|
+
})();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// The direction's screens as one page to choose from: every screen in a strip
|
|
3
|
-
// (
|
|
3
|
+
// (each round, and a screen's parts, in a row), the one
|
|
4
4
|
// they open shown large, and beside it what it is made from: its base and each
|
|
5
5
|
// move, with the reference's picture and their own words. Actions write a
|
|
6
6
|
// line for the chat. No dependencies. It shows what was built; it adds no
|
|
@@ -8,9 +8,10 @@
|
|
|
8
8
|
//
|
|
9
9
|
// node canvas.mjs .longbeard/design/direction/screens.json --board .longbeard/design/direction/board.md --shots .longbeard/design/direction/grid --out .longbeard/design/direction/canvas.html
|
|
10
10
|
//
|
|
11
|
-
// screens.json entries (
|
|
11
|
+
// screens.json entries (the skill's step 3): n, base, moves [{ what, from, like }], state,
|
|
12
|
+
// kind ("concept", with idea: the concept it keeps, shown in place of "Base"),
|
|
12
13
|
// failure, and optionally round (1 when left out), of (the screen it belongs to),
|
|
13
|
-
// part (a part of that screen),
|
|
14
|
+
// part (a part of that screen), fault (one line), shot
|
|
14
15
|
// (a picture; else <shots>/<n>.png). board.md cards give each reference's shot and like.
|
|
15
16
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
16
17
|
import { dirname, isAbsolute, relative, resolve } from "node:path";
|
|
@@ -87,14 +88,14 @@ const shotOf = (s) => {
|
|
|
87
88
|
return "";
|
|
88
89
|
};
|
|
89
90
|
|
|
90
|
-
// Rows: each round, then each
|
|
91
|
+
// Rows: each round, then each screen's parts.
|
|
91
92
|
const rows = new Map();
|
|
92
93
|
for (const s of screens) {
|
|
93
|
-
const key = s.of != null ?
|
|
94
|
+
const key = s.of != null ? `${s.of} · ${s.part || "parts"}` : `Round ${s.round || 1}`;
|
|
94
95
|
if (!rows.has(key)) rows.set(key, []);
|
|
95
96
|
rows.get(key).push(s);
|
|
96
97
|
}
|
|
97
|
-
const label = (s) => (s.state === "failed" ? "failed" :
|
|
98
|
+
const label = (s) => (s.state === "failed" ? "failed" : "built");
|
|
98
99
|
const data = screens.map((s) => {
|
|
99
100
|
const base = cardOf(s.base);
|
|
100
101
|
return {
|
|
@@ -103,7 +104,7 @@ const data = screens.map((s) => {
|
|
|
103
104
|
label: label(s),
|
|
104
105
|
of: s.of != null ? String(s.of) : "",
|
|
105
106
|
part: s.part || "",
|
|
106
|
-
|
|
107
|
+
concept: s.kind === "concept" ? s.idea || "its concept" : "",
|
|
107
108
|
fault: s.state === "failed" ? `failed: ${s.failure || "no reason given"}` : s.fault || "",
|
|
108
109
|
base: { name: base.name, src: base.src, like: base.like, avoid: base.avoid },
|
|
109
110
|
moves: (s.moves || []).map((m) => {
|
|
@@ -246,11 +247,13 @@ const html = `<!DOCTYPE html>
|
|
|
246
247
|
$("baseimg").src = s.base.src || "";
|
|
247
248
|
$("basebox").href = s.base.src || "#";
|
|
248
249
|
$("basecap").textContent = "Base: " + s.base.name;
|
|
249
|
-
const kind = s.
|
|
250
|
+
const kind = s.part ? s.part + " of " + s.of : (s.concept ? "concept from " : "on ") + s.base.name;
|
|
250
251
|
$("title").textContent = s.n + " · " + kind;
|
|
251
252
|
$("fault").textContent = s.fault;
|
|
252
253
|
$("made").innerHTML =
|
|
253
|
-
|
|
254
|
+
(s.concept
|
|
255
|
+
? ing(s.base.src, "Concept · " + s.base.name, "its idea, redrawn for this product: " + s.concept, s.base.like, s.base.avoid)
|
|
256
|
+
: ing(s.base.src, "Base · " + s.base.name, "the layout, spacing and everything no move names", s.base.like, s.base.avoid)) +
|
|
254
257
|
s.moves.map((m) => ing(m.src, "+ " + m.from, m.what + (m.proposed ? " (proposed)" : ""), m.like, "")).join("");
|
|
255
258
|
try { localStorage.setItem(key, s.n); } catch (e) {}
|
|
256
259
|
}
|