@brunosouzas/design-system 0.8.1 → 0.9.1
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 +2 -0
- package/README.md +15 -2
- package/dist/src/fonts/embed.js +2 -0
- package/dist/src/pieces/headline.d.ts +11 -0
- package/dist/src/pieces/headline.js +37 -0
- package/dist/src/pieces/library.d.ts +4 -2
- package/dist/src/pieces/library.js +3 -1
- package/fonts/SourceSerif4-Bold.ttf +0 -0
- package/package.json +1 -1
package/NOTICE
CHANGED
|
@@ -7,6 +7,8 @@ This package ships third-party font files, unmodified, in fonts/:
|
|
|
7
7
|
SourceSans3-Black.ttf), from https://github.com/adobe-fonts/source-sans
|
|
8
8
|
- Source Code Pro, release 2.042R (SourceCodePro-Regular.ttf,
|
|
9
9
|
SourceCodePro-Bold.ttf), from https://github.com/adobe-fonts/source-code-pro
|
|
10
|
+
- Source Serif 4, release 4.005R (SourceSerif4-Bold.ttf), from
|
|
11
|
+
https://github.com/adobe-fonts/source-serif
|
|
10
12
|
|
|
11
13
|
Copyright Adobe, with Reserved Font Name 'Source'. Licensed under the SIL Open
|
|
12
14
|
Font License, Version 1.1: fonts/OFL.txt. The cover command embeds a subset of
|
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ The package also installs the cover command as `brunosouzas-cover <spec.json> --
|
|
|
78
78
|
|
|
79
79
|
### Type in a written image
|
|
80
80
|
|
|
81
|
-
An SVG shown through `<img>` cannot load web fonts, so a written image carries its own: `embedFonts(tree)` adds one `<style>` after the `<desc>` with a `@font-face` per Source face the tree's text uses, each a subset holding only the glyphs drawn ([ADR 0008](docs/adr/0008-type-inside-the-image.md)). The cover command and `npm run pieces:sheet` call it before they write; a tree without Source text is returned unchanged. It is async, reads only the faces it needs, and rejects naming the font file or `harfbuzzjs` when one fails to load. It lives in its own entry so the root entry stays importable in a browser. Its output is for written files and `<img>`: when you inline a piece's SVG in an HTML page, skip `embedFonts` and let the page's fonts apply, because an inline `<style>` with `@font-face` applies to the whole document and would replace the page's Source faces with a subset.
|
|
81
|
+
An SVG shown through `<img>` cannot load web fonts, so a written image carries its own: `embedFonts(tree)` adds one `<style>` after the `<desc>` with a `@font-face` per Source face the tree's text uses (the package ships Source Sans 3 Regular, Bold and Black, Source Code Pro Regular and Bold, and, since 0.9.0, Source Serif 4 Bold for `headline`), each a subset holding only the glyphs drawn ([ADR 0008](docs/adr/0008-type-inside-the-image.md)). The cover command and `npm run pieces:sheet` call it before they write; a tree without Source text is returned unchanged. It is async, reads only the faces it needs, and rejects naming the font file or `harfbuzzjs` when one fails to load. It lives in its own entry so the root entry stays importable in a browser. Its output is for written files and `<img>`: when you inline a piece's SVG in an HTML page, skip `embedFonts` and let the page's fonts apply, because an inline `<style>` with `@font-face` applies to the whole document and would replace the page's Source faces with a subset.
|
|
82
82
|
|
|
83
83
|
```ts
|
|
84
84
|
import { coverTree, toSvg } from "@brunosouzas/design-system";
|
|
@@ -144,7 +144,7 @@ The components take every colour and size from the tokens, and what is visible a
|
|
|
144
144
|
- `toSvg(node)` writes a tree as SVG text; `toReact(node)` turns the same tree into React elements. Both describe the same elements, attributes and text, which the tests check.
|
|
145
145
|
- `pose(node, { x, y, tilt, squash, hop, scale, shake, opacity })` animates any piece around its base point; a scene recomputes the numbers every frame.
|
|
146
146
|
- Every colour parameter is a token path (`"color.state.healthy"`, `"illustration.accent"`), never a hex value, except the three data fills of the map pieces below. Each piece checks its parameters before drawing and names the first wrong one. Positions and points take any finite number, because a map has no edge; sizes stay within 10000. A drawing that would hold a non-finite number throws `<piece>: the drawing overflows`.
|
|
147
|
-
- The
|
|
147
|
+
- The 63 pieces, with their anchors, parameters and defaults, are listed in [design §4](openspec/changes/archive/2026-10-23-illustration-pieces/design.md) (the 26 cover pieces), in [design §3](openspec/changes/archive/2026-10-23-metro-and-diagram-pieces/design.md) of `metro-and-diagram-pieces` (the nine map and diagram pieces) and in [design §3, §5 and §6](openspec/changes/archive/2026-10-23-stackledger-map-and-link-pieces/design.md) of `stackledger-map-and-link-pieces` (the six markers, zones and icons) and in [design §3 to §5](openspec/changes/archive/2026-10-23-body-diagram-pieces/design.md) of `body-diagram-pieces` (the ten body diagram pieces), plus `stateStart` ([design §4](openspec/changes/archive/2026-10-24-designer-formats/design.md) of `designer-formats`) and `headline` (below); the rules are in [`openspec/specs/illustration-pieces/`](openspec/specs/illustration-pieces/spec.md). `npm run pieces:sheet -- --out <file.svg>` draws them all, and `--surface dark` draws every piece that takes `surface` on the dark surface.
|
|
148
148
|
|
|
149
149
|
### Maps and diagrams
|
|
150
150
|
|
|
@@ -276,6 +276,10 @@ npx --yes --package @brunosouzas/design-system@<version> brunosouzas-cover desig
|
|
|
276
276
|
- **Text tables.** `"text": { "pt": { "open": ["taxa de falha", "> limite"] }, "en": { ... } }` holds one table per language with the same keys; any string `"@open"` elsewhere in the spec (pieces, `title`, `description`, even `id`) is replaced by that key's value for the language passed with `--lang <code>`. Every language must define every key, and the ids in the output gain the language (`<id>-pt`). Without `text`, strings are drawn as written, so `"@home"` stays a label.
|
|
277
277
|
- Like a cover, a diagram or icon is a standalone image: `uiIcon` `colour: "currentColor"` is refused in every format.
|
|
278
278
|
|
|
279
|
+
### Titles
|
|
280
|
+
|
|
281
|
+
`headline({ x, y, lines, size, anchor, surface })` writes a title of one to four `lines` in Source Serif 4 Bold (`font.serif`), the first baseline at (`x`, `y`), the next ones 1.1 × `size` lower; `size` is an integer from 24 to 160 (default 64), `anchor` is `start` (default), `middle` or `end`, and the colour is `brand.<surface>.text`. It draws only words (`text`), so a cover, banner, LinkedIn card, og or diagram spec writes it outside the outlined group, and the written image embeds the serif subset. With `text` tables, `"lines": "@slogan"` takes a line array per language. `test/fixtures/covers/og-headline.json` is brunosouzas.com's default share image.
|
|
282
|
+
|
|
279
283
|
### A new piece
|
|
280
284
|
|
|
281
285
|
Add it to `src/pieces/library.ts` (or `src/pieces/metro.ts` for a map or diagram piece) with `definePiece(name, schema, draw)`, take its colours and sizes from the tokens (a new colour goes to `tokens/source.json` first), register it in `PIECES`, and give it a sample in `scripts/pieces-sheet.ts`. The catalogue test then checks that it draws with only its required parameters and uses token colours only.
|
|
@@ -296,6 +300,15 @@ const github = toSvg(el("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "
|
|
|
296
300
|
|
|
297
301
|
`src/pieces/eip-icons.ts` holds the 26 Enterprise Integration Patterns icons as data. They are redrawn from the icons by Gregor Hohpe and Bobby Woolf ([enterpriseintegrationpatterns.com](https://www.enterpriseintegrationpatterns.com/)), licensed [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); each icon keeps that credit in its description.
|
|
298
302
|
|
|
303
|
+
## Upgrading to 0.9.0
|
|
304
|
+
|
|
305
|
+
0.9.0 (card 307) adds a serif title. Nothing is removed or renamed, and every 0.8.1 spec builds byte-identical.
|
|
306
|
+
|
|
307
|
+
| Added | What |
|
|
308
|
+
|---|---|
|
|
309
|
+
| `headline` | a title in Source Serif 4 Bold, one to four lines (see Titles, above); `PIECES` has 63 names, so a check of the exact list must add it |
|
|
310
|
+
| `fonts/SourceSerif4-Bold.ttf` | Adobe's Source Serif 4 4.005R Bold, unmodified, its SHA-256 pinned; an image embeds only the glyphs it draws ([ADR 0008](docs/adr/0008-type-inside-the-image.md), amended) |
|
|
311
|
+
|
|
299
312
|
## Upgrading to 0.8.1
|
|
300
313
|
|
|
301
314
|
0.8.1 (card 303) adds stackledger's product layer. Nothing is removed or renamed; images and pages that use the backdrop tokens or `ledgerMark` change appearance on rebuild.
|
package/dist/src/fonts/embed.js
CHANGED
|
@@ -30,6 +30,8 @@ const FACES = [
|
|
|
30
30
|
{ family: "Source Sans 3", weight: 400, upTo: 549, range: "100 549", file: "SourceSans3-Regular.ttf" },
|
|
31
31
|
{ family: "Source Sans 3", weight: 700, upTo: 799, range: "550 799", file: "SourceSans3-Bold.ttf" },
|
|
32
32
|
{ family: "Source Sans 3", weight: 900, upTo: Infinity, range: "800 900", file: "SourceSans3-Black.ttf" },
|
|
33
|
+
// One serif face, the bold the `headline` piece draws (change headline-piece): every weight takes it.
|
|
34
|
+
{ family: "Source Serif 4", weight: 700, upTo: Infinity, range: "100 900", file: "SourceSerif4-Bold.ttf" },
|
|
33
35
|
];
|
|
34
36
|
// FACES is already in the order of the rules: family name by code point, then weight.
|
|
35
37
|
/** Subtrees whose strings are never drawn. */
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SurfaceName } from "./ink.ts";
|
|
2
|
+
export type HeadlineParams = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
lines: string[];
|
|
6
|
+
size?: number;
|
|
7
|
+
anchor?: "start" | "middle" | "end";
|
|
8
|
+
surface?: SurfaceName;
|
|
9
|
+
};
|
|
10
|
+
/** One to four lines of a title in Source Serif 4 Bold, the first baseline at (x, y). */
|
|
11
|
+
export declare const headline: import("./piece.ts").Piece<HeadlineParams>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// A title in the brand's serif (change headline-piece, card 307; studio
|
|
2
|
+
// decision I9: Source Serif 4 for titles). The default share image of
|
|
3
|
+
// brunosouzas.com is its first use: the slogan in three lines on an `og` image.
|
|
4
|
+
//
|
|
5
|
+
// Like `edgeLabel`, it draws nothing in `body`: its group is `text`, which a
|
|
6
|
+
// cover-frame format writes in the labels group, outside the ink-outlined
|
|
7
|
+
// group, so no stroke reaches the letters. One `g` carries every shared
|
|
8
|
+
// attribute (overriding the labels group's size, weight, fill and anchor), and
|
|
9
|
+
// one `text` per line carries only its position. Values match the approved
|
|
10
|
+
// preview: −0.01 em tracking, written in user units, and a 1.1 × size step.
|
|
11
|
+
import { tokens } from "../../tokens/generated/tokens.js";
|
|
12
|
+
import { surfaceParam } from "./ink.js";
|
|
13
|
+
import { drawn, el, g, r2 } from "./node.js";
|
|
14
|
+
import { label, num, pos } from "./params.js";
|
|
15
|
+
import { definePiece } from "./piece.js";
|
|
16
|
+
/** Line step as a share of the size. */
|
|
17
|
+
const LEADING = 1.1;
|
|
18
|
+
const drawHeadline = ({ x, y, lines, size = 64, anchor = "start", surface = "light" }) => drawn([], [
|
|
19
|
+
g({
|
|
20
|
+
"data-piece": "headline",
|
|
21
|
+
"font-family": tokens.font.serif,
|
|
22
|
+
"font-size": size,
|
|
23
|
+
"font-weight": tokens.font.weightBold,
|
|
24
|
+
"letter-spacing": r2(-size / 100),
|
|
25
|
+
fill: tokens.brand[surface].text,
|
|
26
|
+
"text-anchor": anchor,
|
|
27
|
+
}, ...lines.map((line, i) => el("text", { x, y: r2(y + i * LEADING * size) }, line))),
|
|
28
|
+
]);
|
|
29
|
+
/** One to four lines of a title in Source Serif 4 Bold, the first baseline at (x, y). */
|
|
30
|
+
export const headline = definePiece("headline", {
|
|
31
|
+
x: pos(),
|
|
32
|
+
y: pos(),
|
|
33
|
+
lines: { kind: "array", required: true, minItems: 1, maxItems: 4, of: label() },
|
|
34
|
+
size: num({ min: 24, max: 160, integer: true }),
|
|
35
|
+
anchor: { kind: "enum", values: ["start", "middle", "end"] },
|
|
36
|
+
surface: surfaceParam,
|
|
37
|
+
}, drawHeadline);
|
|
@@ -4,8 +4,9 @@ import { bankObject, type BankObjectName, type BankObjectParams } from "./bank-o
|
|
|
4
4
|
import { symbol, type SymbolParams } from "./symbol.ts";
|
|
5
5
|
import { brandNotationIcon, type BrandNotationIconName, type BrandNotationIconParams } from "./brand-notation-icons.ts";
|
|
6
6
|
import { categoryIcon, type CategoryIconParams } from "./category-icon.ts";
|
|
7
|
-
|
|
8
|
-
export
|
|
7
|
+
import { headline, type HeadlineParams } from "./headline.ts";
|
|
8
|
+
export { emote, mira, visor, drone, kiu, sinal, bankObject, symbol, brandNotationIcon, categoryIcon, headline };
|
|
9
|
+
export type { MiraParams, VisorParams, DroneParams, KiuParams, SinalParams, BankObjectName, BankObjectParams, SymbolParams, BrandNotationIconName, BrandNotationIconParams, CategoryIconParams, HeadlineParams };
|
|
9
10
|
export * from "./metro.ts";
|
|
10
11
|
export * from "./diagram.ts";
|
|
11
12
|
export * from "./ui-icons.ts";
|
|
@@ -341,6 +342,7 @@ export declare const PIECES: {
|
|
|
341
342
|
readonly symbol: import("./piece.ts").Piece<SymbolParams>;
|
|
342
343
|
readonly brandNotationIcon: import("./piece.ts").Piece<BrandNotationIconParams>;
|
|
343
344
|
readonly categoryIcon: import("./piece.ts").Piece<CategoryIconParams>;
|
|
345
|
+
readonly headline: import("./piece.ts").Piece<HeadlineParams>;
|
|
344
346
|
};
|
|
345
347
|
export type PieceName = keyof typeof PIECES;
|
|
346
348
|
export declare const PIECE_NAMES: PieceName[];
|
|
@@ -21,8 +21,9 @@ 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
|
+
import { headline } from "./headline.js";
|
|
24
25
|
import { codeLength, spans } from "./ink.js";
|
|
25
|
-
export { emote, mira, visor, drone, kiu, sinal, bankObject, symbol, brandNotationIcon, categoryIcon };
|
|
26
|
+
export { emote, mira, visor, drone, kiu, sinal, bankObject, symbol, brandNotationIcon, categoryIcon, headline };
|
|
26
27
|
export * from "./metro.js";
|
|
27
28
|
export * from "./diagram.js";
|
|
28
29
|
export * from "./ui-icons.js";
|
|
@@ -410,5 +411,6 @@ export const PIECES = {
|
|
|
410
411
|
symbol,
|
|
411
412
|
brandNotationIcon,
|
|
412
413
|
categoryIcon,
|
|
414
|
+
headline,
|
|
413
415
|
};
|
|
414
416
|
export const PIECE_NAMES = Object.keys(PIECES);
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brunosouzas/design-system",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Design tokens and illustration pieces of brunosouzas.com: tokens as CSS, JSON and TypeScript, pieces that draw SVG (and React), and a cover command.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|