@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
|
@@ -15,14 +15,14 @@ import { METRO_PIECES } from "./metro.js";
|
|
|
15
15
|
import { DIAGRAM_PIECES, stateStart } from "./diagram.js";
|
|
16
16
|
import { uiIcon } from "./ui-icons.js";
|
|
17
17
|
import { linkIcon } from "./link-icons.js";
|
|
18
|
-
import { emote
|
|
18
|
+
import { emote } from "./emote.js";
|
|
19
19
|
import { mira, visor, drone, kiu, sinal } from "./brand-cast.js";
|
|
20
20
|
import { bankObject } from "./bank-objects.js";
|
|
21
21
|
import { symbol } from "./symbol.js";
|
|
22
22
|
import { brandNotationIcon } from "./brand-notation-icons.js";
|
|
23
23
|
import { categoryIcon } from "./category-icon.js";
|
|
24
24
|
import { codeLength, spans } from "./ink.js";
|
|
25
|
-
export { emote,
|
|
25
|
+
export { emote, mira, visor, drone, kiu, sinal, bankObject, symbol, brandNotationIcon, categoryIcon };
|
|
26
26
|
export * from "./metro.js";
|
|
27
27
|
export * from "./diagram.js";
|
|
28
28
|
export * from "./ui-icons.js";
|
|
@@ -60,7 +60,7 @@ export const sheet = definePiece("sheet", {
|
|
|
60
60
|
fill: col(),
|
|
61
61
|
leadFill: col(),
|
|
62
62
|
tick: col(),
|
|
63
|
-
}, ({ x, y, width, height, rows, top = 46, step = 38, fill = "color.white", leadFill = "color.
|
|
63
|
+
}, ({ x, y, width, height, rows, top = 46, step = 38, fill = "color.white", leadFill = "color.ink", tick = "color.white" }) => {
|
|
64
64
|
const marks = [];
|
|
65
65
|
const bars = [];
|
|
66
66
|
const ticks = [];
|
|
@@ -76,14 +76,14 @@ export const sheet = definePiece("sheet", {
|
|
|
76
76
|
barX = x + 56;
|
|
77
77
|
}
|
|
78
78
|
else if (row.lead === "question") {
|
|
79
|
-
marks.push(el("circle", { cx: x + 30, cy, r: 13, fill: tokens.color.
|
|
79
|
+
marks.push(el("circle", { cx: x + 30, cy, r: 13, fill: tokens.color.white }));
|
|
80
80
|
glyphs.push(el("text", { x: x + 30, y: cy + 7, "font-size": 19, "font-weight": tokens.font.weightHeavy }, "?"));
|
|
81
81
|
barX = x + 52;
|
|
82
82
|
}
|
|
83
83
|
bars.push(el("rect", { x: barX, y: cy - 5, width: row.bar, height: 10, rx: 5 }));
|
|
84
84
|
if (row.tail === "check") {
|
|
85
85
|
const tx = x + width - 40;
|
|
86
|
-
marks.push(el("rect", { x: tx, y: cy - 11, width: 22, height: 22, rx: 5, fill: tokens.color.healthy }));
|
|
86
|
+
marks.push(el("rect", { x: tx, y: cy - 11, width: 22, height: 22, rx: 5, fill: tokens.color.state.healthy }));
|
|
87
87
|
ticks.push(el("path", { d: `M${tx + 5},${cy} L${tx + 10},${cy + 6} L${tx + 18},${cy - 6}`, stroke: ink }));
|
|
88
88
|
}
|
|
89
89
|
});
|
|
@@ -94,8 +94,10 @@ export const sheet = definePiece("sheet", {
|
|
|
94
94
|
g({ stroke: "none", fill: tokens.illustration.textBar }, ...bars),
|
|
95
95
|
], glyphs);
|
|
96
96
|
});
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
// The line kinds of 0.6.x specs, kept so they stay valid (ADR 0009): on the dark card every line is
|
|
98
|
+
// brand.dark.textMuted, a `white` line brand.dark.text, and the `tall` line (the one under review) the accent.
|
|
99
|
+
const CODE_LINE_COLOURS = ["healthy", "caller", "white", "backend"];
|
|
100
|
+
/** Dark code panel with neutral lines; a tall line, the one under review, takes the accent (ADR 0009). */
|
|
99
101
|
export const codePanel = definePiece("codePanel", {
|
|
100
102
|
x: pos(),
|
|
101
103
|
y: pos(),
|
|
@@ -106,7 +108,7 @@ export const codePanel = definePiece("codePanel", {
|
|
|
106
108
|
required: true,
|
|
107
109
|
of: {
|
|
108
110
|
kind: "object",
|
|
109
|
-
fields: { indent: { kind: "number", required: true, min: 0, max: MAX_SIZE }, w: size(true), color: { kind: "enum", required: true, values:
|
|
111
|
+
fields: { indent: { kind: "number", required: true, min: 0, max: MAX_SIZE }, w: size(true), color: { kind: "enum", required: true, values: CODE_LINE_COLOURS }, tall: { kind: "boolean" } },
|
|
110
112
|
},
|
|
111
113
|
},
|
|
112
114
|
top: size(),
|
|
@@ -119,25 +121,25 @@ export const codePanel = definePiece("codePanel", {
|
|
|
119
121
|
width: line.w,
|
|
120
122
|
height: line.tall ? 16 : 10,
|
|
121
123
|
rx: line.tall ? 8 : 5,
|
|
122
|
-
fill:
|
|
124
|
+
fill: line.tall ? tokens.brand.dark.accent : line.color === "white" ? tokens.brand.dark.text : tokens.brand.dark.textMuted,
|
|
123
125
|
}))),
|
|
124
126
|
]));
|
|
125
|
-
/** Chat slip with a tail at the bottom left and one
|
|
126
|
-
export const speechBubble = definePiece("speechBubble", { x: pos(), y: pos(), width: size(true, 60), height: size(true, 50), fill: col() }, ({ x, y, width: w, height: h, fill = "color.
|
|
127
|
+
/** Chat slip with a tail at the bottom left and one text line. */
|
|
128
|
+
export const speechBubble = definePiece("speechBubble", { x: pos(), y: pos(), width: size(true, 60), height: size(true, 50), fill: col() }, ({ x, y, width: w, height: h, fill = "color.white" }) => {
|
|
127
129
|
const r = 12;
|
|
128
130
|
const b = y + h;
|
|
129
131
|
const d = `M${x},${y + r} Q${x},${y} ${x + r},${y} H${x + w - r} Q${x + w},${y} ${x + w},${y + r} V${b - r} Q${x + w},${b} ${x + w - r},${b} H${x + 44} L${x + 20},${b + 20} L${x + 24},${b} H${x + r} Q${x},${b} ${x},${b - r} Z`;
|
|
130
132
|
return drawn([
|
|
131
133
|
...shadowed(el("path", { d, fill: colour(fill, "fill") })),
|
|
132
|
-
el("rect", { x: x + 22, y: y + 31, width: w - 44, height: 13, rx: 6.5, fill: tokens.
|
|
134
|
+
el("rect", { x: x + 22, y: y + 31, width: w - 44, height: 13, rx: 6.5, fill: tokens.illustration.textBar, stroke: "none" }),
|
|
133
135
|
]);
|
|
134
136
|
});
|
|
135
137
|
/** Browser window: title bar with three dots, a hero block and two text lines. */
|
|
136
138
|
export const browserWindow = definePiece("browserWindow", { x: pos(), y: pos(), width: size(false, 60), height: size(false, 130) }, ({ x, y, width: w = 200, height: h = 140 }) => drawn([
|
|
137
139
|
...shadowed(el("rect", { x, y, width: w, height: h, rx: 12, fill: tokens.color.white })),
|
|
138
140
|
el("path", { d: `M${x},${y + 30} H${x + w}`, fill: "none" }),
|
|
139
|
-
...[tokens.color.
|
|
140
|
-
el("rect", { x: x + 20, y: y + 46, width: w - 40, height: 40, rx: 8, fill: tokens.
|
|
141
|
+
...[tokens.color.white, tokens.color.white, tokens.color.white].map((fill, i) => el("circle", { cx: x + 18 + i * 16, cy: y + 15, r: 5, fill, "stroke-width": 2.5 })),
|
|
142
|
+
el("rect", { x: x + 20, y: y + 46, width: w - 40, height: 40, rx: 8, fill: tokens.brand.light.bg, "stroke-width": tokens.outline.small }),
|
|
141
143
|
el("rect", { x: x + 20, y: y + 100, width: r2(w * 0.6), height: 10, rx: 5, fill: tokens.illustration.textBar, stroke: "none" }),
|
|
142
144
|
el("rect", { x: x + 20, y: y + 118, width: r2(w * 0.4), height: 10, rx: 5, fill: tokens.illustration.textBar, stroke: "none" }),
|
|
143
145
|
]));
|
|
@@ -148,17 +150,16 @@ export const folder = definePiece("folder", { x: pos(), y: pos(), scale: size()
|
|
|
148
150
|
const front = `M${p(-6, 64)} Q${p(-6, 52)} ${p(6, 52)} L${p(184, 52)} Q${p(196, 52)} ${p(196, 64)} L${p(190, 198)} L${p(0, 198)} Z`;
|
|
149
151
|
const paper = (dx, dy, rot) => el("rect", { x: r2(x + dx * s), y: r2(y + dy * s), width: r2(96 * s), height: r2(120 * s), rx: 8, fill: tokens.color.white, transform: `rotate(${rot} ${r2(x + (dx + 48) * s)} ${r2(y + (dy + 60) * s)})` });
|
|
150
152
|
return drawn([
|
|
151
|
-
...shadowed(el("path", { d: back, fill: tokens.
|
|
153
|
+
...shadowed(el("path", { d: back, fill: tokens.brand.light.border })),
|
|
152
154
|
paper(24, -8, -8),
|
|
153
155
|
paper(66, -16, 6),
|
|
154
|
-
el("path", { d: front, fill: tokens.color.
|
|
156
|
+
el("path", { d: front, fill: tokens.color.white }),
|
|
155
157
|
]);
|
|
156
158
|
});
|
|
157
159
|
/** A closed book seen from the front: back page, front cover, spine and page edges. */
|
|
158
160
|
export const book = definePiece("book", { x: pos(), y: pos(), width: size(false, 30), height: size(false, 30) }, ({ x, y, width: w = 120, height: h = 200 }) => drawn([
|
|
159
|
-
|
|
161
|
+
// The back page stays white; no ink shape behind or offset from the front cover (it read as the old shadow, ADR 0009).
|
|
160
162
|
el("rect", { x: x + 14, y: y + 10, width: w - 2, height: h, rx: 8, fill: tokens.color.white }),
|
|
161
|
-
el("rect", { x, y, width: w, height: h, rx: 8, fill: ink, stroke: "none" }),
|
|
162
163
|
el("rect", { x, y, width: w, height: h, rx: 8, fill: tokens.color.white }),
|
|
163
164
|
el("rect", { x, y, width: 20, height: h, rx: 8, fill: ink }),
|
|
164
165
|
el("path", { d: `M${x + w + 4},${y + 16} V${y + h - 6} M${x + w + 8},${y + 20} V${y + h - 2}`, "stroke-width": 2 }),
|
|
@@ -174,7 +175,7 @@ export const blockArrow = definePiece("blockArrow", { x: pos(), y: pos(), length
|
|
|
174
175
|
]);
|
|
175
176
|
});
|
|
176
177
|
/** Curved arrow (cubic Bézier) with a chevron head at `to`; solid or dashed. */
|
|
177
|
-
export const arcArrow = definePiece("arcArrow", { from: { kind: "point", required: true }, c1: { kind: "point", required: true }, c2: { kind: "point", required: true }, to: { kind: "point", required: true }, color: col(), dashed: { kind: "boolean" }, width: size() }, ({ from, c1, c2, to, color = "color.
|
|
178
|
+
export const arcArrow = definePiece("arcArrow", { from: { kind: "point", required: true }, c1: { kind: "point", required: true }, c2: { kind: "point", required: true }, to: { kind: "point", required: true }, color: col(), dashed: { kind: "boolean" }, width: size() }, ({ from, c1, c2, to, color = "color.ink", dashed = false, width }) => {
|
|
178
179
|
const stroke = colour(color, "color");
|
|
179
180
|
const strokeWidth = width ?? (dashed ? 4 : 6);
|
|
180
181
|
const angle = Math.atan2(to[1] - c2[1], to[0] - c2[0]);
|
|
@@ -190,9 +191,9 @@ export const arcArrow = definePiece("arcArrow", { from: { kind: "point", require
|
|
|
190
191
|
]);
|
|
191
192
|
});
|
|
192
193
|
/** A rail (track) with square nodes spread along it. */
|
|
193
|
-
export const rail = definePiece("rail", { x: pos(), y: pos(), width: size(true, 100), nodes: { kind: "array", required: true, minItems: 1, of: { kind: "color" } }, fill: col(), thickness: size() }, ({ x, y, width: w, nodes, fill = "
|
|
194
|
-
|
|
195
|
-
el("path", { d: `M${x + 30},${y + t / 2} H${x + w - 30}`, fill: "none", stroke: tokens.
|
|
194
|
+
export const rail = definePiece("rail", { x: pos(), y: pos(), width: size(true, 100), nodes: { kind: "array", required: true, minItems: 1, of: { kind: "color" } }, fill: col(), thickness: size() }, ({ x, y, width: w, nodes, fill = "color.white", thickness: t = 44 }) => drawn([
|
|
195
|
+
el("rect", { x, y, width: w, height: t, rx: t / 2, fill: colour(fill, "fill") }),
|
|
196
|
+
el("path", { d: `M${x + 30},${y + t / 2} H${x + w - 30}`, fill: "none", stroke: tokens.brand.light.border, "stroke-width": tokens.outline.small }),
|
|
196
197
|
...nodes.map((node, i) => el("rect", { x: r2(x + 40 + i * ((w - 100) / Math.max(1, nodes.length - 1)) - 10), y: y + t / 2 - 10, width: 20, height: 20, rx: 4, fill: colour(node, `nodes[${i}]`), "stroke-width": tokens.outline.small })),
|
|
197
198
|
]));
|
|
198
199
|
/** A road: a wide grey band along a path with white dashes in the middle. */
|
|
@@ -203,7 +204,7 @@ export const road = definePiece("road", { d: { kind: "string", required: true, n
|
|
|
203
204
|
const PIN_SIZE = 18;
|
|
204
205
|
/** A pin standing on (x, y): a stem and a round head with a short label. `size` is the head's radius (18) and
|
|
205
206
|
* scales the head, its outline and the label together (card 190). */
|
|
206
|
-
export const milestonePin = definePiece("milestonePin", { x: pos(), y: pos(), text: label(), fill: col(), stem: size(), size: { kind: "number", min: 6, max: 48 } }, ({ x, y, text, fill = "color.
|
|
207
|
+
export const milestonePin = definePiece("milestonePin", { x: pos(), y: pos(), text: label(), fill: col(), stem: size(), size: { kind: "number", min: 6, max: 48 } }, ({ x, y, text, fill = "color.white", stem = 44, size: r }) => {
|
|
207
208
|
// Without `size`, the 0.5.0 expressions exactly (no rounding), so every 0.5.0 call keeps its bytes.
|
|
208
209
|
const k = (r ?? PIN_SIZE) / PIN_SIZE;
|
|
209
210
|
const at = r === undefined ? (v) => v : r2;
|
|
@@ -218,56 +219,55 @@ export const priceTag = definePiece("priceTag", { x: pos(), y: pos(), text: labe
|
|
|
218
219
|
const d = `M${x + 20},${top} L${right - 10},${top} Q${right},${top} ${right},${top + 10} L${right},${bottom - 10} Q${right},${bottom} ${right - 10},${bottom} L${x + 20},${bottom} L${x},${y} Z`;
|
|
219
220
|
const body = [];
|
|
220
221
|
if (stringFrom) {
|
|
221
|
-
body.push(el("path", { d: `M${stringFrom[0]},${stringFrom[1]} C${stringFrom[0] - 14},${r2((stringFrom[1] + y) / 2)} ${x + 2},${y + 4} ${x + 20},${y}`, fill: "none", stroke:
|
|
222
|
+
body.push(el("path", { d: `M${stringFrom[0]},${stringFrom[1]} C${stringFrom[0] - 14},${r2((stringFrom[1] + y) / 2)} ${x + 2},${y + 4} ${x + 20},${y}`, fill: "none", stroke: ink, "stroke-width": tokens.outline.block }));
|
|
222
223
|
}
|
|
223
|
-
body.push(
|
|
224
|
+
body.push(el("path", { d, fill: colour(fill, "fill") }), el("circle", { cx: x + 16, cy: y, r: 5, fill: ink, stroke: "none" }));
|
|
224
225
|
return drawn(body, [el("text", { x: r2(x + 20 + (w - 20) / 2 - 2), y: y + 8, "font-family": mono, "font-size": 22 }, text)]);
|
|
225
226
|
});
|
|
226
227
|
/** A name tag hanging on a string from (hangX, hangY), showing one EIP icon. */
|
|
227
|
-
export const nameTag = definePiece("nameTag", { hangX: pos(), hangY: pos(), cx: pos(), top: pos(), rotate: { kind: "number" }, icon: { kind: "enum", required: true, values: EIP_ICON_NAMES }, fill: col() }, ({ hangX: sx, hangY: sy, cx, top, rotate = 0, icon, fill = "color.
|
|
228
|
+
export const nameTag = definePiece("nameTag", { hangX: pos(), hangY: pos(), cx: pos(), top: pos(), rotate: { kind: "number" }, icon: { kind: "enum", required: true, values: EIP_ICON_NAMES }, fill: col() }, ({ hangX: sx, hangY: sy, cx, top, rotate = 0, icon, fill = "color.white" }) => {
|
|
228
229
|
const w = 96;
|
|
229
230
|
const h = 92;
|
|
230
231
|
const x = cx - w / 2;
|
|
231
232
|
const d = `M${x},${top + 14} L${x + 18},${top} H${x + w - 18} L${x + w},${top + 14} V${top + h - 6} Q${x + w},${top + h} ${x + w - 6},${top + h} H${x + 6} Q${x},${top + h} ${x},${top + h - 6} Z`;
|
|
232
233
|
return drawn([
|
|
233
234
|
el("path", { d: `M${sx},${sy} C${sx - 13},${sy + 28} ${sx + 6},${sy + 36} ${cx},${top + 20}`, fill: "none", "stroke-width": tokens.outline.small }),
|
|
234
|
-
g({ transform: `rotate(${rotate} ${cx} ${top + 20})` },
|
|
235
|
+
g({ transform: `rotate(${rotate} ${cx} ${top + 20})` }, el("path", { d, fill: colour(fill, "fill") }), el("circle", { cx, cy: top + 14, r: 5, fill: tokens.color.white, "stroke-width": tokens.outline.small }), ...eipIcon({ name: icon, x: cx - 38, y: top + 27, scale: 1.18 }).body),
|
|
235
236
|
]);
|
|
236
237
|
});
|
|
237
238
|
/** Green round badge with a tick. */
|
|
238
239
|
export const checkBadge = definePiece("checkBadge", { cx: pos(), cy: pos(), r: size() }, ({ cx, cy, r = 16 }) => drawn([
|
|
239
|
-
el("circle", { cx, cy, r, fill: tokens.color.healthy, "stroke-width": tokens.outline.small }),
|
|
240
|
+
el("circle", { cx, cy, r, fill: tokens.color.state.healthy, "stroke-width": tokens.outline.small }),
|
|
240
241
|
el("path", { d: `M${r2(cx - r * 0.42)},${cy} L${r2(cx - r * 0.1)},${r2(cy + r * 0.34)} L${r2(cx + r * 0.45)},${r2(cy - r * 0.32)}`, fill: "none", "stroke-width": 3.5, "stroke-linecap": "round" }),
|
|
241
242
|
]));
|
|
242
243
|
/** Rubber stamp, round (dashed inner ring) or rectangular, tilted, with one word. */
|
|
243
|
-
export const stamp = definePiece("stamp", { cx: pos(), cy: pos(), word: label(), fill: col(), r: size(false, 12), rotate: { kind: "number" }, shape: { kind: "enum", values: ["round", "rect"] } }, ({ cx, cy, word, fill = "color.healthy", r = 40, rotate = -12, shape = "round" }) => {
|
|
244
|
+
export const stamp = definePiece("stamp", { cx: pos(), cy: pos(), word: label(), fill: col(), r: size(false, 12), rotate: { kind: "number" }, shape: { kind: "enum", values: ["round", "rect"] } }, ({ cx, cy, word, fill = "color.state.healthy", r = 40, rotate = -12, shape = "round" }) => {
|
|
244
245
|
const turn = `rotate(${rotate} ${cx} ${cy})`;
|
|
245
246
|
const face = shape === "round"
|
|
246
247
|
? [
|
|
247
|
-
|
|
248
|
+
el("circle", { cx, cy, r, fill: colour(fill, "fill") }),
|
|
248
249
|
el("circle", { cx, cy, r: r - 10, fill: "none", stroke: tokens.color.white, "stroke-width": tokens.outline.small, "stroke-dasharray": "6 5" }),
|
|
249
250
|
]
|
|
250
251
|
: [
|
|
251
|
-
|
|
252
|
+
el("rect", { x: cx - r * 1.6, y: cy - r * 0.7, width: r * 3.2, height: r * 1.4, rx: 8, fill: colour(fill, "fill") }),
|
|
252
253
|
el("rect", { x: cx - r * 1.6 + 8, y: cy - r * 0.7 + 8, width: r * 3.2 - 16, height: r * 1.4 - 16, rx: 4, fill: "none", stroke: tokens.color.white, "stroke-width": tokens.outline.small }),
|
|
253
254
|
];
|
|
254
255
|
return drawn([g({ transform: turn }, ...face)], [el("text", { x: cx, y: cy + 10, "font-size": 27, "font-weight": tokens.font.weightHeavy, transform: turn }, word)]);
|
|
255
256
|
});
|
|
256
|
-
/** Robot:
|
|
257
|
+
/** Robot in the v2 grammar: white body and ears, a dark visor with the cast's idle eyes, one grille bar, the accent on the antenna tip. Scale it with pose. */
|
|
257
258
|
export const robot = definePiece("robot", { cx: pos(), top: pos() }, ({ cx, top }) => {
|
|
258
259
|
const w = 160;
|
|
259
260
|
const h = 152;
|
|
260
261
|
const x = cx - w / 2;
|
|
261
262
|
return drawn([
|
|
262
263
|
el("line", { x1: cx, y1: top, x2: cx, y2: top - 28 }),
|
|
263
|
-
el("circle", { cx, cy: top - 34, r: 10, fill: tokens.
|
|
264
|
-
el("rect", { x: x - 16, y: top + 44, width: 20, height: 52, rx: 6, fill: tokens.
|
|
265
|
-
el("rect", { x: x + w - 4, y: top + 44, width: 20, height: 52, rx: 6, fill: tokens.
|
|
266
|
-
|
|
267
|
-
el("rect", { x: x + 22, y: top + 22, width: w - 44, height: 72, rx: 14, fill:
|
|
268
|
-
el("
|
|
269
|
-
el("
|
|
270
|
-
g({ stroke: "none", fill: ink }, el("rect", { x: x + 30, y: top + 108, width: 44, height: 9, rx: 4.5 }), el("rect", { x: x + 82, y: top + 108, width: 48, height: 9, rx: 4.5 }), el("rect", { x: x + 42, y: top + 124, width: 60, height: 9, rx: 4.5 })),
|
|
264
|
+
el("circle", { cx, cy: top - 34, r: 10, fill: tokens.brand.light.accent }),
|
|
265
|
+
el("rect", { x: x - 16, y: top + 44, width: 20, height: 52, rx: 6, fill: tokens.color.white }),
|
|
266
|
+
el("rect", { x: x + w - 4, y: top + 44, width: 20, height: 52, rx: 6, fill: tokens.color.white }),
|
|
267
|
+
el("rect", { x, y: top, width: w, height: h, rx: 22, fill: tokens.color.white }),
|
|
268
|
+
el("rect", { x: x + 22, y: top + 22, width: w - 44, height: 72, rx: 14, fill: tokens.brand.light.text }),
|
|
269
|
+
...[-23, 23].map((dx) => el("rect", { x: r2(cx + dx - 6.4), y: top + 43, width: 12.8, height: 30, rx: 6.4, fill: tokens.cast.eyes, stroke: "none" })),
|
|
270
|
+
g({ stroke: "none", fill: tokens.brand.light.border }, el("rect", { x: x + 44, y: top + 114, width: 72, height: 9, rx: 4.5 })),
|
|
271
271
|
]);
|
|
272
272
|
});
|
|
273
273
|
/** Magnifier: lens centred on (cx, cy), handle to the bottom right. */
|
|
@@ -284,25 +284,25 @@ export const magnifier = definePiece("magnifier", { cx: pos(), cy: pos(), r: siz
|
|
|
284
284
|
]);
|
|
285
285
|
});
|
|
286
286
|
/** Stack of server units; the `failing` unit (0-based) shows a red light. */
|
|
287
|
-
export const serverStack = definePiece("serverStack", { x: pos(), y: pos(), width: size(), units: count(1, 20), fill: col(), failing: count(0, 19) }, ({ x, y, width: w = 150, units = 3, fill = "color.
|
|
287
|
+
export const serverStack = definePiece("serverStack", { x: pos(), y: pos(), width: size(), units: count(1, 20), fill: col(), failing: count(0, 19) }, ({ x, y, width: w = 150, units = 3, fill = "color.white", failing }) => {
|
|
288
288
|
const uh = 40;
|
|
289
289
|
const gap = 10;
|
|
290
290
|
return drawn(Array.from({ length: units }, (_, i) => {
|
|
291
291
|
const uy = y + i * (uh + gap);
|
|
292
292
|
return [
|
|
293
293
|
...shadowed(el("rect", { x, y: uy, width: w, height: uh, rx: 8, fill: colour(fill, "fill") })),
|
|
294
|
-
el("rect", { x: x + 16, y: uy + 15, width: r2(w * 0.5), height: 10, rx: 5, fill: tokens.
|
|
295
|
-
el("circle", { cx: x + w - 24, cy: uy + 20, r: 6, fill: i === failing ? tokens.color.failure : tokens.color.white, "stroke-width": tokens.outline.small }),
|
|
294
|
+
el("rect", { x: x + 16, y: uy + 15, width: r2(w * 0.5), height: 10, rx: 5, fill: tokens.illustration.textBar, stroke: "none" }),
|
|
295
|
+
el("circle", { cx: x + w - 24, cy: uy + 20, r: 6, fill: i === failing ? tokens.color.state.failure : tokens.color.white, "stroke-width": tokens.outline.small }),
|
|
296
296
|
];
|
|
297
297
|
}).flat());
|
|
298
298
|
});
|
|
299
299
|
export const cloud = definePiece("cloud", { cx: pos(), cy: pos(), scale: size(), fill: col() }, ({ cx, cy, scale: s = 1, fill = "color.white" }) => {
|
|
300
300
|
const p = (dx, dy) => `${r2(cx + dx * s)},${r2(cy + dy * s)}`;
|
|
301
301
|
const d = `M${p(-70, 30)} Q${p(-96, 30)} ${p(-94, 4)} Q${p(-90, -20)} ${p(-62, -18)} Q${p(-52, -58)} ${p(-10, -54)} Q${p(26, -52)} ${p(36, -24)} Q${p(86, -30)} ${p(90, 6)} Q${p(92, 30)} ${p(66, 30)} Z`;
|
|
302
|
-
return drawn(
|
|
302
|
+
return drawn([el("path", { d, fill: colour(fill, "fill") })]);
|
|
303
303
|
});
|
|
304
|
-
/** Gear with square teeth and a
|
|
305
|
-
export const gear = definePiece("gear", { cx: pos(), cy: pos(), r: size(), teeth: count(4, 64), fill: col() }, ({ cx, cy, r = 84, teeth = 12, fill = "color.
|
|
304
|
+
/** Gear with square teeth and a hub, as on the maven-release cover. */
|
|
305
|
+
export const gear = definePiece("gear", { cx: pos(), cy: pos(), r: size(), teeth: count(4, 64), fill: col() }, ({ cx, cy, r = 84, teeth = 12, fill = "color.white" }) => {
|
|
306
306
|
const root = r * 0.78;
|
|
307
307
|
const points = [];
|
|
308
308
|
const step = (2 * Math.PI) / teeth;
|
|
@@ -311,18 +311,18 @@ export const gear = definePiece("gear", { cx: pos(), cy: pos(), r: size(), teeth
|
|
|
311
311
|
const a = i * step;
|
|
312
312
|
points.push(at(root, a - step * 0.3), at(r, a - step * 0.18), at(r, a + step * 0.18), at(root, a + step * 0.3));
|
|
313
313
|
}
|
|
314
|
-
return drawn([...shadowed(el("polygon", { points: points.join(" "), fill: colour(fill, "fill") })), el("circle", { cx, cy, r: r2(r * 0.36), fill: tokens.
|
|
314
|
+
return drawn([...shadowed(el("polygon", { points: points.join(" "), fill: colour(fill, "fill") })), el("circle", { cx, cy, r: r2(r * 0.36), fill: tokens.brand.light.bg })]);
|
|
315
315
|
});
|
|
316
316
|
/** Parcel (box) with a lid line and a tape strip. */
|
|
317
|
-
export const parcel = definePiece("parcel", { x: pos(), y: pos(), size: size(), fill: col() }, ({ x, y, size: s = 96, fill = "color.
|
|
317
|
+
export const parcel = definePiece("parcel", { x: pos(), y: pos(), size: size(), fill: col() }, ({ x, y, size: s = 96, fill = "color.white" }) => drawn([
|
|
318
318
|
...shadowed(el("rect", { x, y, width: s, height: r2(s * 0.8), rx: 6, fill: colour(fill, "fill") })),
|
|
319
319
|
el("path", { d: `M${x},${r2(y + s * 0.3)} H${x + s}`, fill: "none", "stroke-width": tokens.outline.small }),
|
|
320
320
|
el("rect", { x: x + s / 2 - 12, y, width: 24, height: r2(s * 0.8), fill: tokens.illustration.tape, "stroke-width": tokens.outline.small }),
|
|
321
321
|
]));
|
|
322
322
|
/** Steps climbing to the right from the bottom-left corner (x, y), as on the obsidian-to-site guide cover. */
|
|
323
|
-
export const steps = definePiece("steps", { x: pos(), y: pos(), count: count(1, 20), width: size(), rise: size(), fill: col() }, ({ x, y, count = 4, width: w = 145, rise = 40, fill = "color.
|
|
323
|
+
export const steps = definePiece("steps", { x: pos(), y: pos(), count: count(1, 20), width: size(), rise: size(), fill: col() }, ({ x, y, count = 4, width: w = 145, rise = 40, fill = "color.white" }) => {
|
|
324
324
|
const blocks = Array.from({ length: count }, (_, i) => el("rect", { x: x + i * w, y: y - rise * (i + 1), width: w, height: rise * (i + 1), rx: 10, fill: colour(fill, "fill") }));
|
|
325
|
-
return drawn(
|
|
325
|
+
return drawn(blocks);
|
|
326
326
|
});
|
|
327
327
|
const muleGlyph = (kind, cx, cy) => {
|
|
328
328
|
const line = { fill: "none", "stroke-linecap": "round" };
|
|
@@ -345,7 +345,7 @@ export const muleFlow = definePiece("muleFlow", {
|
|
|
345
345
|
tiles: { kind: "array", required: true, minItems: 1, of: { kind: "object", fields: { x: pos(), kind: { kind: "enum", required: true, values: ["scatter-gather", "choice", "for-each"] } } } },
|
|
346
346
|
tileWidth: size(false, 40),
|
|
347
347
|
fill: col(),
|
|
348
|
-
}, ({ x, y, width: w, height: h = 104, tiles, tileWidth = 86, fill = "
|
|
348
|
+
}, ({ x, y, width: w, height: h = 104, tiles, tileWidth = 86, fill = "brand.light.bg" }) => {
|
|
349
349
|
const cy = y + h / 2;
|
|
350
350
|
const links = [`M${x + 18},${cy} H${tiles[0].x - 6}`];
|
|
351
351
|
const heads = [];
|
|
@@ -358,7 +358,7 @@ export const muleFlow = definePiece("muleFlow", {
|
|
|
358
358
|
...shadowed(el("rect", { x, y, width: w, height: h, rx: 22, fill: colour(fill, "fill") })),
|
|
359
359
|
el("path", { d: links.join(" "), "stroke-linecap": "round" }),
|
|
360
360
|
...heads,
|
|
361
|
-
...tiles.
|
|
361
|
+
...tiles.map((tile) => el("rect", { x: tile.x, y: y + 14, width: tileWidth, height: h - 28, rx: 14, fill: tokens.color.white })),
|
|
362
362
|
...tiles.flatMap((tile) => muleGlyph(tile.kind, tile.x + tileWidth / 2, cy)),
|
|
363
363
|
]);
|
|
364
364
|
});
|
|
@@ -400,7 +400,6 @@ export const PIECES = {
|
|
|
400
400
|
linkIcon,
|
|
401
401
|
...DIAGRAM_PIECES,
|
|
402
402
|
stateStart,
|
|
403
|
-
mascot,
|
|
404
403
|
emote,
|
|
405
404
|
mira,
|
|
406
405
|
visor,
|
|
@@ -3,7 +3,8 @@ import { type SurfaceName } from "./metro.ts";
|
|
|
3
3
|
export type LinkIcon = {
|
|
4
4
|
readonly name: string;
|
|
5
5
|
readonly title: string;
|
|
6
|
-
readonly description: string;
|
|
6
|
+
readonly description: string;
|
|
7
|
+
/** The face colour of the site's 0.6 sticker, a colour token path; since 0.7.0 `linkIcon` draws every face white. */
|
|
7
8
|
readonly face: string;
|
|
8
9
|
readonly glyph: readonly SvgNode[];
|
|
9
10
|
};
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
// of stackledger-map-and-link-pieces): the social stickers of brunosouzas.com
|
|
3
3
|
// (public/images/home/social-*.svg at e29b3dd), with every colour replaced by
|
|
4
4
|
// its token, plus a `website` globe in the same style. `linkIcon` draws the
|
|
5
|
-
//
|
|
6
|
-
//
|
|
5
|
+
// face white with its outline and no frame behind it (ADR 0009: no hard shadow,
|
|
6
|
+
// colour only where it means something), then the glyph, at the site's measures
|
|
7
|
+
// (46 box, face 38 at 2, radius 9, outline 2.5). On the dark surface the face's
|
|
8
|
+
// outline is surface.dark.muted; the glyph, inside the white face, stays ink.
|
|
7
9
|
//
|
|
8
10
|
// Credit: the GitHub mark is Font Awesome's (fontawesome.com), licensed
|
|
9
11
|
// CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/); its description
|
|
@@ -13,7 +15,7 @@
|
|
|
13
15
|
// a link, a style, a script or a URL, so the output can ship as a static file.
|
|
14
16
|
import { tokens } from "../../tokens/generated/tokens.js";
|
|
15
17
|
import { drawn, el, g, r2 } from "./node.js";
|
|
16
|
-
import {
|
|
18
|
+
import { pos, size } from "./params.js";
|
|
17
19
|
import { definePiece } from "./piece.js";
|
|
18
20
|
import { SURFACES } from "./metro.js";
|
|
19
21
|
const C = tokens.color;
|
|
@@ -32,7 +34,7 @@ export const LINK_ICONS = [
|
|
|
32
34
|
name: "linkedin",
|
|
33
35
|
title: "LinkedIn",
|
|
34
36
|
description: "LinkedIn icon.",
|
|
35
|
-
face: "color.caller",
|
|
37
|
+
face: "color.state.caller",
|
|
36
38
|
glyph: [
|
|
37
39
|
el("rect", { x: 12, y: 18.5, width: 4, height: 11.5, rx: 1, fill: INK, stroke: "none" }),
|
|
38
40
|
el("circle", { cx: 14, cy: 13.8, r: 2.4, fill: INK, stroke: "none" }),
|
|
@@ -43,7 +45,7 @@ export const LINK_ICONS = [
|
|
|
43
45
|
name: "email",
|
|
44
46
|
title: "Email",
|
|
45
47
|
description: "Email icon.",
|
|
46
|
-
face: "color.transitional",
|
|
48
|
+
face: "color.state.transitional",
|
|
47
49
|
glyph: [
|
|
48
50
|
el("rect", { x: 9, y: 13, width: 24, height: 17, rx: 3, fill: C.white, stroke: INK, "stroke-width": 2.5 }),
|
|
49
51
|
el("path", { d: "M10,15 L21,23 L32,15", fill: "none", stroke: INK, "stroke-width": 2.5, "stroke-linejoin": "round" }),
|
|
@@ -53,7 +55,7 @@ export const LINK_ICONS = [
|
|
|
53
55
|
name: "website",
|
|
54
56
|
title: "Website",
|
|
55
57
|
description: "Website icon: a globe.",
|
|
56
|
-
face: "color.healthy",
|
|
58
|
+
face: "color.state.healthy",
|
|
57
59
|
glyph: [
|
|
58
60
|
el("circle", { cx: 21, cy: 21, r: 10.5, fill: C.white, stroke: INK, "stroke-width": 2.5 }),
|
|
59
61
|
el("ellipse", { cx: 21, cy: 21, rx: 4.6, ry: 10.5, fill: "none", stroke: INK, "stroke-width": 2 }),
|
|
@@ -62,19 +64,9 @@ export const LINK_ICONS = [
|
|
|
62
64
|
},
|
|
63
65
|
];
|
|
64
66
|
export const LINK_ICON_NAMES = LINK_ICONS.map((icon) => icon.name);
|
|
65
|
-
/** The site's frame: the shadow (and on dark the rim) behind the face. */
|
|
66
|
-
const frame = (surface) => {
|
|
67
|
-
const s = tokens.surface[surface];
|
|
68
|
-
return s.rimWidth > 0
|
|
69
|
-
? [
|
|
70
|
-
el("rect", { x: 4, y: 4, width: 41, height: 41, rx: 11, fill: s.shadow, stroke: "none" }),
|
|
71
|
-
el("rect", { x: 0.5, y: 0.5, width: 41, height: 41, rx: 11, fill: s.rim, stroke: "none" }),
|
|
72
|
-
]
|
|
73
|
-
: [el("rect", { x: 5, y: 5, width: 38, height: 38, rx: 9, fill: s.shadow, stroke: "none" })];
|
|
74
|
-
};
|
|
75
67
|
/** One link sticker at (x, y), `size` wide (46 by default), on the light or the dark page. */
|
|
76
68
|
export const linkIcon = definePiece("linkIcon", { icon: { kind: "enum", required: true, values: LINK_ICON_NAMES }, x: pos(), y: pos(), size: size(), surface: { kind: "enum", values: SURFACES } }, ({ icon, x, y, size: side = LINK_ICON_SIZE, surface = "light" }) => {
|
|
77
69
|
const data = LINK_ICONS.find((candidate) => candidate.name === icon);
|
|
78
|
-
const face = el("rect", { x: 2, y: 2, width: 38, height: 38, rx: 9, fill:
|
|
79
|
-
return drawn([g({ transform: `translate(${r2(x)} ${r2(y)}) scale(${side / LINK_ICON_SIZE})`, stroke: "none" },
|
|
70
|
+
const face = el("rect", { x: 2, y: 2, width: 38, height: 38, rx: 9, fill: C.white, stroke: surface === "dark" ? tokens.surface.dark.muted : INK, "stroke-width": 2.5 });
|
|
71
|
+
return drawn([g({ transform: `translate(${r2(x)} ${r2(y)}) scale(${side / LINK_ICON_SIZE})`, stroke: "none" }, face, ...data.glyph)]);
|
|
80
72
|
});
|
|
@@ -82,7 +82,8 @@ export type LedgerMarkParams = {
|
|
|
82
82
|
surface?: SurfaceName;
|
|
83
83
|
};
|
|
84
84
|
/** stackledger's mark (favicon, header): an ink square with a bent line and two stations, 32 units scaled to `size`.
|
|
85
|
-
* On
|
|
85
|
+
* On the dark surface a 2-unit band in surface.dark.muted lines the square inside its 32 box, whatever rimWidth is,
|
|
86
|
+
* so the ink square never sits bare on the dark background (ADR 0009). The stations inside the square stay ink. */
|
|
86
87
|
export declare const ledgerMark: import("./piece.ts").Piece<LedgerMarkParams>;
|
|
87
88
|
export type RenewalRingParams = Ink & {
|
|
88
89
|
cx: number;
|
|
@@ -90,7 +91,8 @@ export type RenewalRingParams = Ink & {
|
|
|
90
91
|
r: number;
|
|
91
92
|
width?: number;
|
|
92
93
|
};
|
|
93
|
-
/** The renewal ring: bands like a bent pipe round a station (rim
|
|
94
|
+
/** The renewal ring: bands like a bent pipe round a station (a rim when the surface has one, the ink line, then
|
|
95
|
+
* color.state.blocked), no shadow. */
|
|
94
96
|
export declare const renewalRing: import("./piece.ts").Piece<RenewalRingParams>;
|
|
95
97
|
export type SuggestedHaloParams = {
|
|
96
98
|
cx: number;
|
package/dist/src/pieces/metro.js
CHANGED
|
@@ -29,10 +29,10 @@ export const lineBadge = definePiece("lineBadge", { x: pos(), y: pos(), text: la
|
|
|
29
29
|
const { x, y, text, fill, height = M.badgeHeight, flat = false } = params;
|
|
30
30
|
const width = badgeWidth(params);
|
|
31
31
|
const face = paint(fill);
|
|
32
|
-
const { outline } = inkOf(params);
|
|
32
|
+
const { line, outline } = inkOf(params);
|
|
33
33
|
const inset = flat ? outline / 2 : 0;
|
|
34
34
|
const shape = pill(x - width / 2 + inset, y - height / 2 + inset, width - 2 * inset, height - 2 * inset);
|
|
35
|
-
const body = flat ? [shape(0, 0, { fill: face, stroke:
|
|
35
|
+
const body = flat ? [shape(0, 0, { fill: face, stroke: line, "stroke-width": r2(outline), "stroke-linejoin": "round" })] : sticker(shape, face, params);
|
|
36
36
|
return drawn(body, text === undefined ? [] : [words(x, y + 4.5, text, { fill: white, "font-size": M.badgeTextSize, "font-weight": bold, "text-anchor": "middle" })]);
|
|
37
37
|
}, (params) => {
|
|
38
38
|
const height = params.height ?? M.badgeHeight;
|
|
@@ -141,7 +141,7 @@ const drawNode = (kind, params) => {
|
|
|
141
141
|
words(x + inset, middle - 3, title, { fill: titleFill, "font-size": M.labelSize, "font-weight": bold, "text-anchor": "start" }),
|
|
142
142
|
words(x + inset, middle + 14, subtitle, { fill: focus ? ink : s.muted, "font-size": 11, "font-weight": 400, "text-anchor": "start" }),
|
|
143
143
|
];
|
|
144
|
-
return drawn(sticker(shape, focus ? tokens.color.caller : s.panel, params), text);
|
|
144
|
+
return drawn(sticker(shape, focus ? tokens.color.state.caller : s.panel, params), text);
|
|
145
145
|
};
|
|
146
146
|
/** A diagram box (a skill, a software item): rounded rect with a title and an optional subtitle. */
|
|
147
147
|
export const nodeBlock = definePiece("nodeBlock", { ...nodeSchema, radius: { kind: "number", min: 0, max: MAX_SIZE } }, (p) => drawNode("box", p), nodeLimits("box"));
|
|
@@ -165,7 +165,7 @@ export const messageArrow = definePiece("messageArrow", {
|
|
|
165
165
|
surface: surfaceParam,
|
|
166
166
|
}, ({ from, to, curve = "bezier", controls, head = true, heads = "end", dashed, label: text, width = M.edgeWidth, kind = "message", surface = "light" }) => {
|
|
167
167
|
const s = tokens.surface[surface];
|
|
168
|
-
const paint_ = kind === "failure" ? tokens.color.failure : kind === "failFast" ? tokens.color.failFast : s.text;
|
|
168
|
+
const paint_ = kind === "failure" ? tokens.color.state.failure : kind === "failFast" ? tokens.color.state.failFast : s.text;
|
|
169
169
|
const length = 5 * width;
|
|
170
170
|
const distance = Math.hypot(to[0] - from[0], to[1] - from[1]);
|
|
171
171
|
const dx = to[0] - from[0];
|
|
@@ -221,13 +221,13 @@ export const messageArrow = definePiece("messageArrow", {
|
|
|
221
221
|
return limits(head === false && heads !== undefined && { path: "heads", message: "cannot be combined with head: false" }, distance === 0 && { path: "to", message: "must differ from from" }, distance > 0 && head && distance < need && { path: "to", message: `is too close to from for the ${heads === "both" ? "heads" : "head"}: needs at least ${r2(need)}, found ${r2(distance)}` }, controls !== undefined && curve !== undefined && { path: "controls", message: "cannot be combined with curve" });
|
|
222
222
|
});
|
|
223
223
|
/** stackledger's mark (favicon, header): an ink square with a bent line and two stations, 32 units scaled to `size`.
|
|
224
|
-
* On
|
|
224
|
+
* On the dark surface a 2-unit band in surface.dark.muted lines the square inside its 32 box, whatever rimWidth is,
|
|
225
|
+
* so the ink square never sits bare on the dark background (ADR 0009). The stations inside the square stay ink. */
|
|
225
226
|
export const ledgerMark = definePiece("ledgerMark", { x: pos(), y: pos(), size: { kind: "number", min: 12, max: 512 }, line: col(), surface: surfaceParam }, ({ x, y, size: side = 32, line = "illustration.accent", surface = "light" }) => {
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
const square = rimWidth > 0
|
|
227
|
+
const band = 2;
|
|
228
|
+
const square = surface === "dark"
|
|
229
229
|
? [
|
|
230
|
-
el("rect", { x: 0, y: 0, width: 32, height: 32, rx: 7, fill:
|
|
230
|
+
el("rect", { x: 0, y: 0, width: 32, height: 32, rx: 7, fill: tokens.surface.dark.muted, stroke: "none" }),
|
|
231
231
|
el("rect", { x: band, y: band, width: 32 - 2 * band, height: 32 - 2 * band, rx: 7 - band, fill: ink, stroke: "none" }),
|
|
232
232
|
]
|
|
233
233
|
: [el("rect", { x: 0, y: 0, width: 32, height: 32, rx: 7, fill: ink, stroke: "none" })];
|
|
@@ -235,13 +235,14 @@ export const ledgerMark = definePiece("ledgerMark", { x: pos(), y: pos(), size:
|
|
|
235
235
|
g({ transform: `translate(${r2(x)} ${r2(y)}) scale(${side / 32})` }, ...square, el("path", { d: "M7 23 L14 16 L25 16", fill: "none", stroke: colour(line, "line"), "stroke-width": 4.5, "stroke-linecap": "round", "stroke-linejoin": "round" }), el("circle", { cx: 14, cy: 16, r: 4, fill: white, stroke: ink, "stroke-width": 2 }), el("circle", { cx: 25, cy: 16, r: 2.6, fill: white, stroke: ink, "stroke-width": 1.6 })),
|
|
236
236
|
]);
|
|
237
237
|
});
|
|
238
|
-
/** The renewal ring: bands like a bent pipe round a station (rim
|
|
238
|
+
/** The renewal ring: bands like a bent pipe round a station (a rim when the surface has one, the ink line, then
|
|
239
|
+
* color.state.blocked), no shadow. */
|
|
239
240
|
export const renewalRing = definePiece("renewalRing", { cx: pos(), cy: pos(), r: size(true), width: { kind: "number", min: 0, exclusiveMin: true, max: 50 }, ...inkSchema }, (params) => {
|
|
240
241
|
const { cx, cy, r, width = M.ringWidth } = params;
|
|
241
|
-
const { s, outline, rim } = inkOf(params);
|
|
242
|
+
const { s, line, outline, rim } = inkOf(params);
|
|
242
243
|
// Radius and band widths as given, like pipe's widths: a valid hairline must not round to zero.
|
|
243
244
|
const band = (stroke, strokeWidth) => el("circle", { cx: r2(cx), cy: r2(cy), r, fill: "none", stroke, "stroke-width": strokeWidth });
|
|
244
|
-
return drawn([...(s.rimWidth > 0 ? [band(s.rim, width + outline + 2 * rim)] : []), band(
|
|
245
|
+
return drawn([...(s.rimWidth > 0 ? [band(s.rim, width + outline + 2 * rim)] : []), band(line, width + outline), band(tokens.color.state.blocked, width)]);
|
|
245
246
|
}, (params) => {
|
|
246
247
|
const { outline, rim } = inkOf(params);
|
|
247
248
|
const need = ((params.width ?? M.ringWidth) + outline + 2 * rim) / 2;
|
|
@@ -253,7 +254,7 @@ export const suggestedHalo = definePiece("suggestedHalo", { cx: pos(), cy: pos()
|
|
|
253
254
|
export const licenceMark = definePiece("licenceMark", { cx: pos(), cy: pos(), state: { kind: "enum", values: ["owned", "toBuy"] }, size: size(), ...inkSchema }, (params) => {
|
|
254
255
|
const { cx, cy, state = "owned", size: side = M.licenceSize } = params;
|
|
255
256
|
const shape = (dx, dy, attrs) => el("circle", { cx: r2(cx + dx), cy: r2(cy + dy), r: r2(side / 2), ...attrs });
|
|
256
|
-
return drawn(sticker(shape, state === "owned" ? tokens.color.healthy : white, params));
|
|
257
|
+
return drawn(sticker(shape, state === "owned" ? tokens.color.state.healthy : white, params));
|
|
257
258
|
}, (params) => {
|
|
258
259
|
const need = 3 * inkOf(params).outline;
|
|
259
260
|
const side = params.size ?? M.licenceSize;
|
|
@@ -17,9 +17,11 @@ export declare const el: (tag: SvgTag, attrs?: Attrs, ...children: Child[]) => S
|
|
|
17
17
|
export declare const g: (attrs: Attrs, ...children: Child[]) => SvgNode;
|
|
18
18
|
export declare const drawn: (body: readonly SvgNode[], text?: readonly SvgNode[]) => Drawn;
|
|
19
19
|
/**
|
|
20
|
-
* Hard offset shadow
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
* Hard offset shadow: the pieces draw none since 0.7.0 (ADR 0009, `shadow.block`
|
|
21
|
+
* is 0), so with offset 0 this returns the shape alone and the output carries no
|
|
22
|
+
* hidden node. With an offset above 0, for a caller that still wants one: an ink
|
|
23
|
+
* copy of the shape translated by `offset`, then the shape. Inside the outlined
|
|
24
|
+
* group the copy keeps the outline too.
|
|
23
25
|
*/
|
|
24
26
|
export declare const shadowed: (shape: SvgNode, offset?: number) => SvgNode[];
|
|
25
27
|
/** Rounds to two decimals so computed geometry stays short and stable in the output. */
|
package/dist/src/pieces/node.js
CHANGED
|
@@ -34,11 +34,13 @@ export const el = (tag, attrs = {}, ...children) => ({
|
|
|
34
34
|
export const g = (attrs, ...children) => el("g", attrs, ...children);
|
|
35
35
|
export const drawn = (body, text = []) => ({ body, text });
|
|
36
36
|
/**
|
|
37
|
-
* Hard offset shadow
|
|
38
|
-
*
|
|
39
|
-
*
|
|
37
|
+
* Hard offset shadow: the pieces draw none since 0.7.0 (ADR 0009, `shadow.block`
|
|
38
|
+
* is 0), so with offset 0 this returns the shape alone and the output carries no
|
|
39
|
+
* hidden node. With an offset above 0, for a caller that still wants one: an ink
|
|
40
|
+
* copy of the shape translated by `offset`, then the shape. Inside the outlined
|
|
41
|
+
* group the copy keeps the outline too.
|
|
40
42
|
*/
|
|
41
|
-
export const shadowed = (shape, offset = tokens.shadow.block) => [
|
|
43
|
+
export const shadowed = (shape, offset = tokens.shadow.block) => offset === 0 ? [shape] : [
|
|
42
44
|
{
|
|
43
45
|
...shape,
|
|
44
46
|
attrs: {
|
|
@@ -32,7 +32,7 @@ export const isColourLiteral = (value) => COLOUR_LITERAL.test(value);
|
|
|
32
32
|
export const colour = (path, name = "colour") => {
|
|
33
33
|
const value = COLOUR_TOKENS.get(path);
|
|
34
34
|
if (value === undefined)
|
|
35
|
-
throw new RangeError(`${name}: expected a colour token path such as color.healthy, found ${JSON.stringify(path)}`);
|
|
35
|
+
throw new RangeError(`${name}: expected a colour token path such as color.state.healthy, found ${JSON.stringify(path)}`);
|
|
36
36
|
return value;
|
|
37
37
|
};
|
|
38
38
|
const describe = (value) => (value === undefined ? "nothing" : JSON.stringify(value));
|
|
@@ -62,7 +62,7 @@ const checkValue = (spec, value, path, out) => {
|
|
|
62
62
|
if (isColourLiteral(value))
|
|
63
63
|
return report("colour literals are not allowed; use a token path");
|
|
64
64
|
if (!COLOUR_TOKENS.has(value))
|
|
65
|
-
return report(`expected a colour token path such as color.healthy, found ${describe(value)}`);
|
|
65
|
+
return report(`expected a colour token path such as color.state.healthy, found ${describe(value)}`);
|
|
66
66
|
return;
|
|
67
67
|
case "dataColor":
|
|
68
68
|
if (typeof value !== "string")
|