@brunosouzas/design-system 0.6.1 → 0.8.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/NOTICE +13 -0
- package/README.md +90 -41
- package/dist/scripts/cover.d.ts +7 -4
- package/dist/scripts/cover.js +25 -8
- package/dist/src/fonts/embed.d.ts +7 -0
- package/dist/src/fonts/embed.js +219 -0
- package/dist/src/pieces/bank-objects.d.ts +1 -1
- package/dist/src/pieces/bank-objects.js +26 -18
- package/dist/src/pieces/category-icon.d.ts +4 -4
- package/dist/src/pieces/category-icon.js +33 -22
- package/dist/src/pieces/cover.js +9 -3
- package/dist/src/pieces/diagram.js +3 -3
- package/dist/src/pieces/eip-icons.js +27 -27
- package/dist/src/pieces/emote.d.ts +13 -0
- package/dist/src/pieces/emote.js +88 -0
- package/dist/src/pieces/index.d.ts +1 -1
- package/dist/src/pieces/index.js +1 -1
- package/dist/src/pieces/ink.d.ts +26 -16
- package/dist/src/pieces/ink.js +15 -6
- package/dist/src/pieces/library.d.ts +9 -15
- package/dist/src/pieces/library.js +52 -53
- package/dist/src/pieces/link-icons.d.ts +2 -1
- package/dist/src/pieces/link-icons.js +10 -18
- package/dist/src/pieces/metro.d.ts +4 -2
- package/dist/src/pieces/metro.js +14 -13
- package/dist/src/pieces/node.d.ts +5 -3
- package/dist/src/pieces/node.js +6 -4
- package/dist/src/pieces/params.js +2 -2
- package/dist/tokens/generated/tokens.d.ts +86 -171
- package/dist/tokens/generated/tokens.js +87 -172
- package/fonts/OFL.txt +97 -0
- package/fonts/SourceCodePro-Bold.ttf +0 -0
- package/fonts/SourceCodePro-Regular.ttf +0 -0
- package/fonts/SourceSans3-Black.ttf +0 -0
- package/fonts/SourceSans3-Bold.ttf +0 -0
- package/fonts/SourceSans3-Regular.ttf +0 -0
- package/package.json +10 -1
- package/tokens/generated/tokens.css +78 -125
- package/tokens/generated/tokens.json +87 -172
- package/tokens/generated/tokens.ts +87 -172
- package/dist/src/pieces/cast.d.ts +0 -35
- package/dist/src/pieces/cast.js +0 -333
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
// Source faces embedded in an SVG tree (spec illustration-pieces, "Fonts
|
|
2
|
+
// embedded in an SVG tree"; design.md Decision 1, ADR 0008), exported from the
|
|
3
|
+
// subpath `@brunosouzas/design-system/fonts`.
|
|
4
|
+
//
|
|
5
|
+
// Why: the site shows covers and diagrams through `<img>`, which never loads a
|
|
6
|
+
// page's web fonts, and Source is not installed on most readers' machines. So
|
|
7
|
+
// every written image carries, as a TrueType subset in a `<style>`, only the
|
|
8
|
+
// characters it draws in each Source face; the reader sees Source, at 2-10 KB
|
|
9
|
+
// gzip per image.
|
|
10
|
+
//
|
|
11
|
+
// How: `await embedFonts(tree)` returns a new tree with one `style` after the
|
|
12
|
+
// root's `desc` (or first), one `@font-face` per face its drawn text uses. The
|
|
13
|
+
// cover command and `npm run pieces:sheet` call it before writing.
|
|
14
|
+
//
|
|
15
|
+
// What can go wrong: an unreadable font file or a WebAssembly module that does
|
|
16
|
+
// not load rejects with an Error naming the file or `harfbuzzjs`; a failed load
|
|
17
|
+
// is not cached, so the next call retries. A character no shipped face has is
|
|
18
|
+
// left out of the subset (the browser takes it from the next family of the
|
|
19
|
+
// stack). This module reads files, so it lives outside src/pieces/, whose
|
|
20
|
+
// modules stay pure (the root entry must import in a browser bundle).
|
|
21
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
22
|
+
import { readFile } from "node:fs/promises";
|
|
23
|
+
import { createRequire } from "node:module";
|
|
24
|
+
import { dirname, join } from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
const PACKAGE_NAME = "@brunosouzas/design-system";
|
|
27
|
+
const FACES = [
|
|
28
|
+
{ family: "Source Code Pro", weight: 400, upTo: 549, range: "100 549", file: "SourceCodePro-Regular.ttf" },
|
|
29
|
+
{ family: "Source Code Pro", weight: 700, upTo: Infinity, range: "550 900", file: "SourceCodePro-Bold.ttf" },
|
|
30
|
+
{ family: "Source Sans 3", weight: 400, upTo: 549, range: "100 549", file: "SourceSans3-Regular.ttf" },
|
|
31
|
+
{ family: "Source Sans 3", weight: 700, upTo: 799, range: "550 799", file: "SourceSans3-Bold.ttf" },
|
|
32
|
+
{ family: "Source Sans 3", weight: 900, upTo: Infinity, range: "800 900", file: "SourceSans3-Black.ttf" },
|
|
33
|
+
];
|
|
34
|
+
// FACES is already in the order of the rules: family name by code point, then weight.
|
|
35
|
+
/** Subtrees whose strings are never drawn. */
|
|
36
|
+
const NOT_DRAWN = new Set(["title", "desc", "style"]);
|
|
37
|
+
/** First family of a `font-family` list, trimmed and unquoted. */
|
|
38
|
+
const firstFamily = (value) => value.split(",")[0].trim().replace(/^(["'])(.*)\1$/, "$2");
|
|
39
|
+
/** CSS weight of a `font-weight` value: keywords other than `bold`, and anything non-numeric, are 400. */
|
|
40
|
+
const weightOf = (value) => {
|
|
41
|
+
if (typeof value === "number")
|
|
42
|
+
return value;
|
|
43
|
+
if (value === undefined)
|
|
44
|
+
return 400;
|
|
45
|
+
const trimmed = value.trim();
|
|
46
|
+
if (trimmed === "bold")
|
|
47
|
+
return 700;
|
|
48
|
+
return /^\d+(\.\d+)?$/.test(trimmed) ? Number(trimmed) : 400;
|
|
49
|
+
};
|
|
50
|
+
/** The shipped face a text is drawn in, or undefined (another family, or none). Italic and oblique take the upright face. */
|
|
51
|
+
const faceOf = (inherited) => {
|
|
52
|
+
if (inherited.family === undefined)
|
|
53
|
+
return undefined;
|
|
54
|
+
const family = firstFamily(inherited.family);
|
|
55
|
+
const weight = weightOf(inherited.weight);
|
|
56
|
+
const ofFamily = FACES.filter((face) => face.family === family);
|
|
57
|
+
// Snapped to the first face whose declared range reaches the weight (549.5
|
|
58
|
+
// goes to 700 and 799.5 to 900, as in the browser); above 900, the heaviest.
|
|
59
|
+
return ofFamily.find((face) => weight <= face.upTo);
|
|
60
|
+
};
|
|
61
|
+
/** Drawn characters per face: the strings of text and tspan nodes, outside title, desc and style. */
|
|
62
|
+
const drawnText = (node, inherited, out) => {
|
|
63
|
+
if (NOT_DRAWN.has(node.tag))
|
|
64
|
+
return;
|
|
65
|
+
const own = {
|
|
66
|
+
family: node.attrs["font-family"] === undefined ? inherited.family : String(node.attrs["font-family"]),
|
|
67
|
+
weight: node.attrs["font-weight"] ?? inherited.weight,
|
|
68
|
+
};
|
|
69
|
+
const isText = node.tag === "text" || node.tag === "tspan";
|
|
70
|
+
for (const child of node.children) {
|
|
71
|
+
if (typeof child !== "string")
|
|
72
|
+
drawnText(child, own, out);
|
|
73
|
+
else if (isText) {
|
|
74
|
+
const face = faceOf(own);
|
|
75
|
+
if (face === undefined)
|
|
76
|
+
continue;
|
|
77
|
+
const characters = out.get(face) ?? new Set();
|
|
78
|
+
for (const character of child)
|
|
79
|
+
characters.add(character);
|
|
80
|
+
out.set(face, characters);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
// ---------- loading (lazy, once per process, failures not cached) ----------
|
|
85
|
+
let fontsFolder;
|
|
86
|
+
/** `fonts/` of this package: the nearest package.json above this module named @brunosouzas/design-system (works from src/ and dist/). */
|
|
87
|
+
const fontsDir = () => {
|
|
88
|
+
if (fontsFolder !== undefined)
|
|
89
|
+
return fontsFolder;
|
|
90
|
+
const start = dirname(fileURLToPath(import.meta.url));
|
|
91
|
+
for (let dir = start;; dir = dirname(dir)) {
|
|
92
|
+
const manifest = join(dir, "package.json");
|
|
93
|
+
if (existsSync(manifest) && JSON.parse(readFileSync(manifest, "utf8")).name === PACKAGE_NAME) {
|
|
94
|
+
fontsFolder = join(dir, "fonts");
|
|
95
|
+
return fontsFolder;
|
|
96
|
+
}
|
|
97
|
+
if (dirname(dir) === dir)
|
|
98
|
+
throw new Error(`cannot find the fonts/ folder of ${PACKAGE_NAME} above ${start}`);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const message = (error) => (error instanceof Error ? error.message : String(error));
|
|
102
|
+
const fontFiles = new Map();
|
|
103
|
+
const fontFile = (file) => {
|
|
104
|
+
const path = join(fontsDir(), file);
|
|
105
|
+
let loading = fontFiles.get(path);
|
|
106
|
+
if (loading === undefined) {
|
|
107
|
+
loading = readFile(path).then((bytes) => new Uint8Array(bytes), (error) => {
|
|
108
|
+
fontFiles.delete(path); // not cached: the next call reads it again
|
|
109
|
+
throw new Error(`cannot read the font file ${path}: ${message(error)}`);
|
|
110
|
+
});
|
|
111
|
+
fontFiles.set(path, loading);
|
|
112
|
+
}
|
|
113
|
+
return loading;
|
|
114
|
+
};
|
|
115
|
+
let harfBuzz;
|
|
116
|
+
const subsetter = () => {
|
|
117
|
+
if (harfBuzz !== undefined)
|
|
118
|
+
return harfBuzz;
|
|
119
|
+
const loading = (async () => {
|
|
120
|
+
try {
|
|
121
|
+
const wasm = createRequire(import.meta.url).resolve("harfbuzzjs/dist/harfbuzz-subset.wasm");
|
|
122
|
+
const { instance } = await WebAssembly.instantiate(await readFile(wasm));
|
|
123
|
+
const hb = instance.exports;
|
|
124
|
+
hb._initialize();
|
|
125
|
+
return hb;
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
throw new Error(`harfbuzzjs: cannot load the WebAssembly subsetter: ${message(error)}`);
|
|
129
|
+
}
|
|
130
|
+
})();
|
|
131
|
+
// Cached only once assigned, and cleared on rejection, so a failure thrown
|
|
132
|
+
// before the first await (the module cannot be resolved) is not cached either.
|
|
133
|
+
harfBuzz = loading;
|
|
134
|
+
loading.catch(() => {
|
|
135
|
+
if (harfBuzz === loading)
|
|
136
|
+
harfBuzz = undefined; // not cached: the next call loads it again
|
|
137
|
+
});
|
|
138
|
+
return loading;
|
|
139
|
+
};
|
|
140
|
+
// ---------- subsetting ----------
|
|
141
|
+
// The mode of the spike that proved the routine (card 300): HarfBuzz may use the copy in place; it is freed after.
|
|
142
|
+
const HB_MEMORY_MODE_WRITABLE = 2;
|
|
143
|
+
const HB_SUBSET_SETS_UNICODE = 1;
|
|
144
|
+
const HB_SUBSET_SETS_LAYOUT_FEATURE_TAG = 6;
|
|
145
|
+
const HB_SUBSET_FLAGS_NO_HINTING = 0x1;
|
|
146
|
+
// Kerning and the ligatures the text may use; every other layout feature is dropped.
|
|
147
|
+
const LAYOUT_FEATURES = ["kern", "liga", "calt"];
|
|
148
|
+
const tag = (name) => [...name].reduce((value, character) => ((value << 8) | character.charCodeAt(0)) >>> 0, 0);
|
|
149
|
+
/** A TrueType subset of `font` holding the glyphs of `characters` (deterministic: same input, same bytes). */
|
|
150
|
+
const subset = (hb, font, characters, file) => {
|
|
151
|
+
const input = hb.hb_subset_input_create_or_fail();
|
|
152
|
+
if (input === 0)
|
|
153
|
+
throw new Error(`harfbuzzjs: cannot create a subset input for ${file}`);
|
|
154
|
+
const data = hb.malloc(font.byteLength);
|
|
155
|
+
new Uint8Array(hb.memory.buffer).set(font, data);
|
|
156
|
+
const blob = hb.hb_blob_create(data, font.byteLength, HB_MEMORY_MODE_WRITABLE, 0, 0);
|
|
157
|
+
const face = hb.hb_face_create(blob, 0);
|
|
158
|
+
hb.hb_blob_destroy(blob);
|
|
159
|
+
try {
|
|
160
|
+
const unicodes = hb.hb_subset_input_set(input, HB_SUBSET_SETS_UNICODE);
|
|
161
|
+
for (const character of characters)
|
|
162
|
+
hb.hb_set_add(unicodes, character.codePointAt(0));
|
|
163
|
+
const features = hb.hb_subset_input_set(input, HB_SUBSET_SETS_LAYOUT_FEATURE_TAG);
|
|
164
|
+
hb.hb_set_clear(features);
|
|
165
|
+
for (const feature of LAYOUT_FEATURES)
|
|
166
|
+
hb.hb_set_add(features, tag(feature));
|
|
167
|
+
hb.hb_subset_input_set_flags(input, hb.hb_subset_input_get_flags(input) | HB_SUBSET_FLAGS_NO_HINTING);
|
|
168
|
+
const result = hb.hb_subset_or_fail(face, input);
|
|
169
|
+
if (result === 0)
|
|
170
|
+
throw new Error(`harfbuzzjs: subsetting ${file} failed`);
|
|
171
|
+
const out = hb.hb_face_reference_blob(result);
|
|
172
|
+
const offset = hb.hb_blob_get_data(out, 0);
|
|
173
|
+
const bytes = new Uint8Array(hb.memory.buffer).slice(offset, offset + hb.hb_blob_get_length(out));
|
|
174
|
+
hb.hb_blob_destroy(out);
|
|
175
|
+
hb.hb_face_destroy(result);
|
|
176
|
+
return bytes;
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
hb.hb_subset_input_destroy(input);
|
|
180
|
+
hb.hb_face_destroy(face);
|
|
181
|
+
hb.free(data);
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
/** Glyph count of a TrueType font (its `maxp` table); a subset with only `.notdef` draws none of its characters. */
|
|
185
|
+
const glyphCount = (font) => {
|
|
186
|
+
const view = new DataView(font.buffer, font.byteOffset, font.byteLength);
|
|
187
|
+
const tables = view.getUint16(4);
|
|
188
|
+
for (let i = 0; i < tables; i++) {
|
|
189
|
+
const record = 12 + i * 16;
|
|
190
|
+
if (view.getUint32(record) === tag("maxp"))
|
|
191
|
+
return view.getUint16(view.getUint32(record + 8) + 4);
|
|
192
|
+
}
|
|
193
|
+
return 0;
|
|
194
|
+
};
|
|
195
|
+
const fontFace = (face, font) => `@font-face{font-family:'${face.family}';font-weight:${face.range};font-style:normal;src:url(data:font/ttf;base64,${Buffer.from(font).toString("base64")}) format('truetype')}`;
|
|
196
|
+
/**
|
|
197
|
+
* The tree with the Source faces its drawn text uses embedded as subsets, in
|
|
198
|
+
* one `style` right after the root's `desc` (or as its first child). A tree
|
|
199
|
+
* with no face to embed resolves to the input; the input is never modified.
|
|
200
|
+
*/
|
|
201
|
+
export const embedFonts = async (tree) => {
|
|
202
|
+
const used = new Map();
|
|
203
|
+
drawnText(tree, {}, used);
|
|
204
|
+
const faces = FACES.filter((face) => used.has(face));
|
|
205
|
+
if (faces.length === 0)
|
|
206
|
+
return tree;
|
|
207
|
+
const hb = await subsetter();
|
|
208
|
+
const rules = [];
|
|
209
|
+
for (const face of faces) {
|
|
210
|
+
const font = subset(hb, await fontFile(face.file), used.get(face), face.file);
|
|
211
|
+
if (glyphCount(font) > 1)
|
|
212
|
+
rules.push(fontFace(face, font));
|
|
213
|
+
}
|
|
214
|
+
if (rules.length === 0)
|
|
215
|
+
return tree;
|
|
216
|
+
const style = { tag: "style", attrs: {}, children: [rules.join("\n")] };
|
|
217
|
+
const at = tree.children.findIndex((child) => typeof child !== "string" && child.tag === "desc") + 1;
|
|
218
|
+
return { ...tree, children: [...tree.children.slice(0, at), style, ...tree.children.slice(at)] };
|
|
219
|
+
};
|
|
@@ -8,5 +8,5 @@ export type BankObjectParams = {
|
|
|
8
8
|
surface?: SurfaceName;
|
|
9
9
|
scale?: number;
|
|
10
10
|
};
|
|
11
|
-
/** One of the six prop-bank objects for covers (I10): Correio, Lume, Carga, Anel, Módulo, Hub
|
|
11
|
+
/** One of the six prop-bank objects for covers (I10): Correio, Lume, Carga, Anel, Módulo, Hub, with idle eyes on the screen. */
|
|
12
12
|
export declare const bankObject: import("./piece.ts").Piece<BankObjectParams>;
|
|
@@ -1,28 +1,36 @@
|
|
|
1
|
-
// The bank of objects for covers (identity studio I10): six
|
|
2
|
-
//
|
|
3
|
-
// Geometry ported
|
|
4
|
-
// (`~/.hermes/cache/scratch/ab267/casting3.py`: `courier`/`lume`/`carga`/`anel`/`modulo`/`hub`)
|
|
1
|
+
// The bank of objects for covers (identity studio I10, amended in 0.7.0): six
|
|
2
|
+
// objects that appear on track covers instead of a cast character with a role.
|
|
3
|
+
// Geometry ported from the approved phase-3 source
|
|
4
|
+
// (`~/.hermes/cache/scratch/ab267/casting3.py`: `courier`/`lume`/`carga`/`anel`/`modulo`/`hub`);
|
|
5
|
+
// in 0.7.0 every screen shows the cast's idle eyes and `modulo` loses the two
|
|
6
|
+
// inner strokes between its legs (the card 301 preview the owner approved).
|
|
5
7
|
//
|
|
6
|
-
// Why
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
8
|
+
// Why idle eyes and nothing more: an object with a face-like screen and no eyes
|
|
9
|
+
// reads as dead, so the screen is on; but a bank object is scenery, not a
|
|
10
|
+
// character with a story role (Mira, Visor, Drone, Kiu, Sinal), so it takes no
|
|
11
|
+
// expression. If a future piece needs the same object with expressions or a
|
|
12
|
+
// role in two or more places, it becomes a character with its own sheet (E8),
|
|
13
|
+
// not a change to this file.
|
|
14
|
+
import { drawn, el, g, r2 } from "./node.js";
|
|
11
15
|
import { surfaceParam } from "./ink.js";
|
|
12
16
|
import { pos, num } from "./params.js";
|
|
13
17
|
import { definePiece } from "./piece.js";
|
|
14
18
|
import { outlined, skin } from "./skin.js";
|
|
15
19
|
export const BANK_OBJECT_NAMES = ["courier", "lume", "carga", "anel", "modulo", "hub"];
|
|
16
|
-
/** The screen
|
|
17
|
-
const
|
|
18
|
-
|
|
20
|
+
/** The screen: the visor-coloured panel with the cast's idle eyes centred on it, and no other expression. */
|
|
21
|
+
const screen = (x, y, w, h, s, rx) => {
|
|
22
|
+
// Two upright pills a fifth of the screen's width either side of its centre, 0.42 of its height.
|
|
23
|
+
const cx = x + w / 2, cy = y + h / 2, dx = w * 0.2, ew = Math.max(5, w * 0.11), eh = h * 0.42;
|
|
24
|
+
return g({}, el("rect", { x, y, width: w, height: h, rx: rx ?? h / 2.4, fill: s.visor }), ...[-dx, dx].map((sx) => el("rect", { x: r2(cx + sx - ew / 2), y: r2(cy - eh / 2), width: r2(ew), height: r2(eh), rx: r2(ew / 2), fill: s.eye, stroke: "none" })));
|
|
25
|
+
};
|
|
26
|
+
const courier = (s) => g({}, el("path", { d: "M-42 -100 L-60 -126 H-34 L-18 -100 Z", fill: s.outline }), el("path", { d: "M-42 -40 L-60 -14 H-34 L-18 -40 Z", fill: s.outline }), el("rect", { x: -72, y: -84, width: 14, height: 28, rx: 4, fill: s.outline }), el("path", { d: "M-50 -102 H18 C58 -102 80 -84 80 -70 C80 -56 58 -38 18 -38 H-50 A32 32 0 0 1 -50 -102 Z", ...outlined(s) }), el("rect", { x: -40, y: -82, width: 24, height: 24, rx: 5, fill: s.accent }), screen(-2, -90, 56, 38, s));
|
|
19
27
|
const lume = (s) => {
|
|
20
28
|
const rays = [0, 1, 2].map((i) => el("path", { d: `M${50 + i * 4} ${-104 + i * 22} L${78 + i * 8} ${-112 + i * 26}`, stroke: s.accent, "stroke-width": 7, "stroke-linecap": "round" }));
|
|
21
|
-
return g({}, el("path", { d: "M-20 -138 A20 20 0 0 1 20 -138", stroke: s.outline, "stroke-width": 6, fill: "none" }), el("path", { d: "M-30 -138 H30 L38 -124 H-38 Z", fill: s.outline }), el("rect", { x: -36, y: -126, width: 72, height: 80, rx: 14, ...outlined(s) }),
|
|
29
|
+
return g({}, el("path", { d: "M-20 -138 A20 20 0 0 1 20 -138", stroke: s.outline, "stroke-width": 6, fill: "none" }), el("path", { d: "M-30 -138 H30 L38 -124 H-38 Z", fill: s.outline }), el("rect", { x: -36, y: -126, width: 72, height: 80, rx: 14, ...outlined(s) }), screen(-25, -114, 50, 44, s), el("path", { d: "M-38 -46 H38 L30 -34 H-30 Z", fill: s.outline }), el("path", { d: "M-10 -34 H10 L0 -20 Z", fill: s.outline }), ...rays);
|
|
22
30
|
};
|
|
23
|
-
const carga = (s) => g({}, el("rect", { x: -44, y: -152, width: 60, height: 28, rx: 4, fill: s.accent }), el("path", { d: "M-30 -152 V-124 M-14 -152 V-124 M2 -152 V-124", stroke: s.body, "stroke-width": 3 }), el("path", { d: "M-24 -60 L-38 -32 L-24 -6 M24 -60 L12 -32 L26 -6", stroke: s.outline, "stroke-width": 10, "stroke-linecap": "round", "stroke-linejoin": "round", fill: "none" }), el("rect", { x: -40, y: -8, width: 30, height: 9, rx: 4.5, fill: s.outline }), el("rect", { x: 12, y: -8, width: 30, height: 9, rx: 4.5, fill: s.outline }), el("rect", { x: -50, y: -126, width: 100, height: 70, rx: 16, ...outlined(s) }),
|
|
24
|
-
const anel = (s) => g({}, el("path", { d: "M-82 -78 A84 20 -12 0 1 82 -98", stroke: s.accent, "stroke-width": 9, fill: "none", "stroke-linecap": "round" }), el("circle", { cx: 0, cy: -88, r: 46, ...outlined(s) }),
|
|
25
|
-
const modulo = (s) => g({}, el("path", { d: "M-
|
|
31
|
+
const carga = (s) => g({}, el("rect", { x: -44, y: -152, width: 60, height: 28, rx: 4, fill: s.accent }), el("path", { d: "M-30 -152 V-124 M-14 -152 V-124 M2 -152 V-124", stroke: s.body, "stroke-width": 3 }), el("path", { d: "M-24 -60 L-38 -32 L-24 -6 M24 -60 L12 -32 L26 -6", stroke: s.outline, "stroke-width": 10, "stroke-linecap": "round", "stroke-linejoin": "round", fill: "none" }), el("rect", { x: -40, y: -8, width: 30, height: 9, rx: 4.5, fill: s.outline }), el("rect", { x: 12, y: -8, width: 30, height: 9, rx: 4.5, fill: s.outline }), el("rect", { x: -50, y: -126, width: 100, height: 70, rx: 16, ...outlined(s) }), screen(-30, -114, 62, 36, s), el("path", { d: "M50 -96 H66 V-74", stroke: s.outline, "stroke-width": 7, "stroke-linecap": "round", fill: "none" }), el("path", { d: "M58 -74 H74", stroke: s.outline, "stroke-width": 7, "stroke-linecap": "round" }));
|
|
32
|
+
const anel = (s) => g({}, el("path", { d: "M-82 -78 A84 20 -12 0 1 82 -98", stroke: s.accent, "stroke-width": 9, fill: "none", "stroke-linecap": "round" }), el("circle", { cx: 0, cy: -88, r: 46, ...outlined(s) }), screen(-31, -112, 62, 32, s), el("path", { d: "M82 -98 A84 20 -12 0 1 -82 -78", stroke: s.accent, "stroke-width": 9, fill: "none", "stroke-linecap": "round" }), el("rect", { x: -66, y: -74, width: 14, height: 14, rx: 3, fill: s.outline }), el("rect", { x: 58, y: -92, width: 14, height: 14, rx: 3, fill: s.outline }));
|
|
33
|
+
const modulo = (s) => g({}, el("path", { d: "M-44 -50 L-74 -2 M44 -50 L74 -2", stroke: s.outline, "stroke-width": 7, "stroke-linecap": "round" }), el("rect", { x: -88, y: -6, width: 28, height: 7, rx: 3.5, fill: s.outline }), el("rect", { x: 60, y: -6, width: 28, height: 7, rx: 3.5, fill: s.outline }), el("rect", { x: -46, y: -62, width: 92, height: 24, rx: 5, fill: s.accent }), el("path", { d: "M22 -134 L34 -154", stroke: s.outline, "stroke-width": 5, "stroke-linecap": "round" }), el("path", { d: "M26 -160 A10 10 0 0 0 44 -150 Z", fill: s.outline }), el("path", { d: "M-36 -136 H36 L52 -114 V-80 L36 -62 H-36 L-52 -80 V-114 Z", ...outlined(s) }), screen(-34, -122, 68, 42, s));
|
|
26
34
|
const hub = (s) => {
|
|
27
35
|
const arms = [];
|
|
28
36
|
const spokes = [
|
|
@@ -32,7 +40,7 @@ const hub = (s) => {
|
|
|
32
40
|
arms.push(el("path", { d: `M${x1} ${y1} Q${cx} ${cy} ${x2} ${y2}`, stroke: s.outline, "stroke-width": 7, fill: "none", "stroke-linecap": "round" }));
|
|
33
41
|
arms.push(el("rect", { x: x2 - 8, y: y2 - 4, width: 16, height: 12, rx: 3, fill: s.accent }));
|
|
34
42
|
}
|
|
35
|
-
return g({}, ...arms, el("path", { d: "M-50 -76 V-104 A50 50 0 0 1 50 -104 V-76 Q0 -60 -50 -76 Z", ...outlined(s) }),
|
|
43
|
+
return g({}, ...arms, el("path", { d: "M-50 -76 V-104 A50 50 0 0 1 50 -104 V-76 Q0 -60 -50 -76 Z", ...outlined(s) }), screen(-36, -130, 72, 40, s));
|
|
36
44
|
};
|
|
37
45
|
const DRAW = { courier, lume, carga, anel, modulo, hub };
|
|
38
46
|
const drawBankObject = (p) => {
|
|
@@ -40,5 +48,5 @@ const drawBankObject = (p) => {
|
|
|
40
48
|
const body = DRAW[p.name](s);
|
|
41
49
|
return drawn([g({ "data-piece": `bank-${p.name}`, transform: `translate(${p.x} ${p.y}) scale(${p.scale ?? 1})`, stroke: "none" }, body)]);
|
|
42
50
|
};
|
|
43
|
-
/** One of the six prop-bank objects for covers (I10): Correio, Lume, Carga, Anel, Módulo, Hub
|
|
51
|
+
/** One of the six prop-bank objects for covers (I10): Correio, Lume, Carga, Anel, Módulo, Hub, with idle eyes on the screen. */
|
|
44
52
|
export const bankObject = definePiece("bankObject", { name: { kind: "enum", required: true, values: BANK_OBJECT_NAMES }, x: pos(), y: pos(), surface: surfaceParam, scale: num({ min: 0.25, max: 4 }) }, drawBankObject);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const CATEGORY_ICON_NAMES: readonly ["personalTools"];
|
|
1
|
+
export declare const CATEGORY_ICON_NAMES: readonly ["integration", "delivery", "aiEngineering", "personalTools"];
|
|
3
2
|
export type CategoryIconName = (typeof CATEGORY_ICON_NAMES)[number];
|
|
3
|
+
/** The badge's box before `scale` (spec cover-cli, "Icon output"). */
|
|
4
|
+
export declare const CATEGORY_ICON_SIZE = 42;
|
|
4
5
|
export type CategoryIconParams = {
|
|
5
6
|
category: CategoryIconName;
|
|
6
7
|
x: number;
|
|
7
8
|
y: number;
|
|
8
|
-
surface?: SurfaceName;
|
|
9
9
|
scale?: number;
|
|
10
10
|
};
|
|
11
|
-
/**
|
|
11
|
+
/** One of the site's four category badges: the glyph on a disc in its track's default tone, a 42×42 box before `scale`. */
|
|
12
12
|
export declare const categoryIcon: import("./piece.ts").Piece<CategoryIconParams>;
|
|
@@ -1,26 +1,37 @@
|
|
|
1
|
-
// The
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
1
|
+
// The site's category badge (change site-palette-and-category-badges, design.md
|
|
2
|
+
// Decision 2; owner's choice Q7 of card 302): a disc in the default tone of the
|
|
3
|
+
// category's track family, ringed in that tone's cover ring, with a glyph on
|
|
4
|
+
// it. Integration, delivery and AI take a brand notation glyph; personal tools
|
|
5
|
+
// keeps its own (a wrench crossing a screwdriver, a ring for the bolt), ported
|
|
6
|
+
// from `~/.hermes/cache/scratch/ab267/phase4.py`'s `cat_icon()`. The geometry is
|
|
7
|
+
// the approved preview (`~/.hermes/cache/scratch/ab302/cat/cat.mjs`, 168 x 168)
|
|
8
|
+
// at a quarter: a 42 x 42 box before `scale`.
|
|
9
|
+
import { brandNotationIcon } from "./brand-notation-icons.js";
|
|
8
10
|
import { drawn, el, g } from "./node.js";
|
|
9
|
-
import {
|
|
10
|
-
import { pos, num } from "./params.js";
|
|
11
|
+
import { colour, num, pos } from "./params.js";
|
|
11
12
|
import { definePiece } from "./piece.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
13
|
+
export const CATEGORY_ICON_NAMES = ["integration", "delivery", "aiEngineering", "personalTools"];
|
|
14
|
+
/** The badge's box before `scale` (spec cover-cli, "Icon output"). */
|
|
15
|
+
export const CATEGORY_ICON_SIZE = 42;
|
|
16
|
+
const TRACK = {
|
|
17
|
+
integration: "trackIntegration",
|
|
18
|
+
delivery: "trackDelivery",
|
|
19
|
+
aiEngineering: "trackAi",
|
|
20
|
+
personalTools: "trackPersonal",
|
|
21
|
+
};
|
|
22
|
+
const GLYPH = {
|
|
23
|
+
integration: "pointToPointChannel",
|
|
24
|
+
delivery: "gateToProduction",
|
|
25
|
+
aiEngineering: "contextWindow",
|
|
26
|
+
};
|
|
27
|
+
const KEBAB = { integration: "integration", delivery: "delivery", aiEngineering: "ai-engineering", personalTools: "personal-tools" };
|
|
28
|
+
/** Personal tools' own glyph, in its 48 x 48 box, at 9, 9 and scale 0.5 like a notation glyph. */
|
|
29
|
+
const personalToolsGlyph = () => g({ transform: "translate(9 9) scale(0.5)", stroke: "none" }, el("path", { d: "M12 36 L28 20 M24 12 L36 24", stroke: colour("brand.light.text"), "stroke-width": 5, "stroke-linecap": "round", "stroke-linejoin": "round", fill: "none" }), el("circle", { cx: 16, cy: 32, r: 6, fill: "none", stroke: colour("brand.light.accent"), "stroke-width": 3.5 }));
|
|
15
30
|
const drawCategoryIcon = (p) => {
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
el("path", { d: "M12 36 L28 20 M24 12 L36 24", stroke: text, "stroke-width": 5, "stroke-linecap": "round", "stroke-linejoin": "round", fill: "none" }),
|
|
21
|
-
el("circle", { cx: 16, cy: 32, r: 6, fill: "none", stroke: accent, "stroke-width": 3.5 }),
|
|
22
|
-
];
|
|
23
|
-
return drawn([g({ "data-piece": "category-icon-personal-tools", transform: `translate(${p.x} ${p.y}) scale(${p.scale ?? 1})`, stroke: "none" }, ...glyph)]);
|
|
31
|
+
const track = TRACK[p.category];
|
|
32
|
+
const disc = el("circle", { cx: 21, cy: 21, r: 19.5, fill: colour(`coverBackground.${track}.fill`), stroke: colour(`coverBackground.${track}.ring`), "stroke-width": 1 });
|
|
33
|
+
const glyph = p.category === "personalTools" ? personalToolsGlyph() : brandNotationIcon({ name: GLYPH[p.category], x: 9, y: 9, scale: 0.5, surface: "light" }).body[0];
|
|
34
|
+
return drawn([g({ "data-piece": `category-icon-${KEBAB[p.category]}`, transform: `translate(${p.x} ${p.y}) scale(${p.scale ?? 1})` }, disc, glyph)]);
|
|
24
35
|
};
|
|
25
|
-
/**
|
|
26
|
-
export const categoryIcon = definePiece("categoryIcon", { category: { kind: "enum", required: true, values: CATEGORY_ICON_NAMES }, x: pos(), y: pos(),
|
|
36
|
+
/** One of the site's four category badges: the glyph on a disc in its track's default tone, a 42×42 box before `scale`. */
|
|
37
|
+
export const categoryIcon = definePiece("categoryIcon", { category: { kind: "enum", required: true, values: CATEGORY_ICON_NAMES }, x: pos(), y: pos(), scale: num({ min: 0.25, max: 8 }) }, drawCategoryIcon);
|
package/dist/src/pieces/cover.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
import { tokens } from "../../tokens/generated/tokens.js";
|
|
12
12
|
import { PIECE_NAMES, PIECES, rings } from "./library.js";
|
|
13
13
|
import { EIP_ICON_HEIGHT, EIP_ICON_WIDTH, EIP_ICONS } from "./eip-icons.js";
|
|
14
|
+
import { CATEGORY_ICON_SIZE } from "./category-icon.js";
|
|
14
15
|
import { LINK_ICON_SIZE } from "./link-icons.js";
|
|
15
16
|
import { mira } from "./brand-cast.js";
|
|
16
17
|
import { symbol } from "./symbol.js";
|
|
@@ -230,12 +231,16 @@ const forLanguage = (spec, lang) => {
|
|
|
230
231
|
};
|
|
231
232
|
// ---------- validation ----------
|
|
232
233
|
/** Icon pieces and the box each draws in (spec cover-cli, "Icon output"). */
|
|
233
|
-
const ICON_PIECES = ["eipIcon", "uiIcon", "linkIcon"];
|
|
234
|
+
const ICON_PIECES = ["eipIcon", "uiIcon", "linkIcon", "categoryIcon"];
|
|
234
235
|
const iconBox = (entry) => {
|
|
235
236
|
if (entry.piece === "eipIcon") {
|
|
236
237
|
const scale = entry.scale ?? 1;
|
|
237
238
|
return [EIP_ICON_WIDTH * scale, EIP_ICON_HEIGHT * scale];
|
|
238
239
|
}
|
|
240
|
+
if (entry.piece === "categoryIcon") {
|
|
241
|
+
const side = CATEGORY_ICON_SIZE * (entry.scale ?? 1);
|
|
242
|
+
return [side, side];
|
|
243
|
+
}
|
|
239
244
|
const side = entry.size ?? (entry.piece === "uiIcon" ? UI_ICON_SIZE : LINK_ICON_SIZE);
|
|
240
245
|
return [side, side];
|
|
241
246
|
};
|
|
@@ -325,7 +330,8 @@ const validateResolved = (spec) => {
|
|
|
325
330
|
out.push({ path: key, message: "expected a non-empty string" });
|
|
326
331
|
}
|
|
327
332
|
if (format === "icon") {
|
|
328
|
-
|
|
333
|
+
// signature too since 0.7.0 (0.6.x accepted it and drew nothing).
|
|
334
|
+
for (const key of ["background", "rings", "custom", "customAt", "height", "signature"])
|
|
329
335
|
if (spec[key] !== undefined)
|
|
330
336
|
out.push({ path: key, message: NOT_FOR_ICONS });
|
|
331
337
|
for (const key of ["background", "rings", "custom"])
|
|
@@ -396,7 +402,7 @@ const validateResolved = (spec) => {
|
|
|
396
402
|
else if (format === "icon") {
|
|
397
403
|
const entry = pieces[0];
|
|
398
404
|
if (pieces.length !== 1 || !isPlainObject(entry) || !ICON_PIECES.includes(entry.piece)) {
|
|
399
|
-
out.push({ path: "pieces", message: "an icon spec holds exactly one piece: eipIcon, uiIcon or
|
|
405
|
+
out.push({ path: "pieces", message: "an icon spec holds exactly one piece: eipIcon, uiIcon, linkIcon or categoryIcon" });
|
|
400
406
|
blocked.push("pieces");
|
|
401
407
|
}
|
|
402
408
|
else {
|
|
@@ -76,7 +76,7 @@ export const storeNode = definePiece("storeNode", { ...shapeSchema(true), ry: si
|
|
|
76
76
|
const { outline } = inkOf(params);
|
|
77
77
|
const rx = r2(w / 2);
|
|
78
78
|
const body = (dx, dy, attrs) => el("path", { d: `M${r2(x + dx)},${r2(y + ry + dy)} A${rx},${ry} 0 0 1 ${r2(x + w + dx)},${r2(y + ry + dy)} V${r2(y + h - ry + dy)} A${rx},${ry} 0 0 1 ${r2(x + dx)},${r2(y + h - ry + dy)} Z`, ...attrs });
|
|
79
|
-
const lid = el("path", { d: `M${r2(x)},${r2(y + ry)} A${rx},${ry} 0 0 0 ${r2(x + w)},${r2(y + ry)}`, fill: "none", stroke:
|
|
79
|
+
const lid = el("path", { d: `M${r2(x)},${r2(y + ry)} A${rx},${ry} 0 0 0 ${r2(x + w)},${r2(y + ry)}`, fill: "none", stroke: inkOf(params).line, "stroke-width": r2(0.75 * outline) });
|
|
80
80
|
return drawn([...sticker(body, c.face, params), lid], centred(x + w / 2, y + (h + ry) / 2, text, subtitle, c, params.textSize));
|
|
81
81
|
}, (params) => {
|
|
82
82
|
const ry = params.ry ?? 8;
|
|
@@ -88,7 +88,7 @@ export const queueNode = definePiece("queueNode", shapeSchema(false), (params) =
|
|
|
88
88
|
const { x, y, width: w, height: h = M.nodeHeight, text, subtitle, fill } = params;
|
|
89
89
|
const c = coloursOf(fill, params);
|
|
90
90
|
const { outline } = inkOf(params);
|
|
91
|
-
const rails = el("path", { d: `M${r2(x + RAIL)},${r2(y)} V${r2(y + h)} M${r2(x + w - RAIL)},${r2(y)} V${r2(y + h)}`, fill: "none", stroke:
|
|
91
|
+
const rails = el("path", { d: `M${r2(x + RAIL)},${r2(y)} V${r2(y + h)} M${r2(x + w - RAIL)},${r2(y)} V${r2(y + h)}`, fill: "none", stroke: inkOf(params).line, "stroke-width": r2(0.75 * outline) });
|
|
92
92
|
return drawn([...sticker(rect(x, y, w, h, tokens.radius.small), c.face, params), rails], centred(x + w / 2, y + h / 2, text, subtitle, c, params.textSize));
|
|
93
93
|
}, (params) => {
|
|
94
94
|
const height = params.height ?? M.nodeHeight;
|
|
@@ -111,7 +111,7 @@ const TAB = 24;
|
|
|
111
111
|
const tabWidth = (params) => params.tagWidth ?? 7.2 * characters(params.tag) + 24;
|
|
112
112
|
/** A container (a platform, a broker) with its name on a tab centred on the top edge. */
|
|
113
113
|
export const taggedContainer = definePiece("taggedContainer", { x: pos(), y: pos(), width: size(true), height: size(true), tag: label(), tagWidth: size(), tagFill: col(), fill: col(), ...inkSchema }, (params) => {
|
|
114
|
-
const { x, y, width, height, tag, tagFill = "color.
|
|
114
|
+
const { x, y, width, height, tag, tagFill = "color.white", fill } = params;
|
|
115
115
|
const tw = tabWidth(params);
|
|
116
116
|
const c = coloursOf(fill, params);
|
|
117
117
|
return drawn([...sticker(rect(x, y, width, height, M.nodeRadius), c.face, params), ...sticker(rect(x + 14, y - TAB / 2, tw, TAB, TAB / 2), colour(tagFill, "tagFill"), params)], [words(x + 14 + tw / 2, y + 4.5, tag, { fill: ink, "font-size": M.badgeTextSize, "font-weight": bold, "text-anchor": "middle" })]);
|