@brunosouzas/stackledger 0.4.1 → 0.5.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/README.md +13 -12
- package/dist/map/layout.d.ts +8 -3
- package/dist/map/layout.js +37 -6
- package/dist/map/layout.js.map +1 -1
- package/dist/map/neighbourhood.d.ts +1 -1
- package/dist/map/neighbourhood.js +20 -21
- package/dist/map/neighbourhood.js.map +1 -1
- package/dist/map/parallel.d.ts +19 -5
- package/dist/map/parallel.js +101 -14
- package/dist/map/parallel.js.map +1 -1
- package/dist/map/pieces.d.ts +12 -0
- package/dist/map/pieces.js +15 -0
- package/dist/map/pieces.js.map +1 -0
- package/dist/map/relations.d.ts +1 -1
- package/dist/map/relations.js +26 -31
- package/dist/map/relations.js.map +1 -1
- package/dist/map/strip.js +13 -15
- package/dist/map/strip.js.map +1 -1
- package/dist/map/svg.d.ts +11 -4
- package/dist/map/svg.js +47 -76
- package/dist/map/svg.js.map +1 -1
- package/dist/map/themes.d.ts +9 -6
- package/dist/map/themes.js +64 -48
- package/dist/map/themes.js.map +1 -1
- package/dist/map/xml.d.ts +0 -2
- package/dist/map/xml.js +0 -11
- package/dist/map/xml.js.map +1 -1
- package/dist/schema.d.ts +15 -0
- package/dist/schema.js +4 -0
- package/dist/schema.js.map +1 -1
- package/dist/site/build.js +2 -0
- package/dist/site/build.js.map +1 -1
- package/dist/site/data.d.ts +21 -1
- package/dist/site/data.js +3 -1
- package/dist/site/data.js.map +1 -1
- package/dist/site/ui-icons.d.ts +4 -0
- package/dist/site/ui-icons.js +19 -0
- package/dist/site/ui-icons.js.map +1 -0
- package/examples/catalogue-repository/.github/workflows/stackledger.yml +1 -1
- package/examples/catalogue-repository/README.md +3 -3
- package/npm-shrinkwrap.json +29 -8
- package/package.json +2 -1
- package/site/public/brand-mark-dark.svg +7 -0
- package/site/public/favicon.svg +6 -1
- package/site/public/home-banner.svg +93 -0
- package/site/public/link-icons/email-dark.svg +7 -0
- package/site/public/link-icons/email-light.svg +6 -0
- package/site/public/link-icons/github-dark.svg +8 -0
- package/site/public/link-icons/github-light.svg +7 -0
- package/site/public/link-icons/linkedin-dark.svg +8 -0
- package/site/public/link-icons/linkedin-light.svg +7 -0
- package/site/public/link-icons/website-dark.svg +8 -0
- package/site/public/link-icons/website-light.svg +7 -0
- package/site/src/components/Header.astro +1 -1
- package/site/src/components/ThemeSwitch.astro +4 -7
- package/site/src/components/Themed.astro +3 -2
- package/site/src/pages/[reports].astro +1 -1
- package/site/src/pages/index.astro +3 -2
- package/site/src/pages/map/index.astro +3 -3
- package/site/src/pages/skill-map/[...map].astro +3 -3
- package/site/src/styles/base.css +17 -6
- package/site/src/styles/pages.css +26 -3
- package/site/src/styles/tokens.css +55 -39
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Writes the output of a @brunosouzas/design-system piece through this map's own SVG writer
|
|
2
|
+
* (metro-map: Design system pieces). Every node goes through tag() of src/map/xml.ts, so the element
|
|
3
|
+
* and attribute allow-lists, the paint check, finite numbers and the escaping apply to it as to every
|
|
4
|
+
* other node: a piece node outside those rules throws instead of reaching a page.
|
|
5
|
+
*
|
|
6
|
+
* The pieces name `Lato, 'Helvetica Neue', …` on every text. The writer leaves that `font-family` out:
|
|
7
|
+
* the root svg names the same families without quotes, so nothing renders differently and no quote
|
|
8
|
+
* character reaches an attribute value. Call writePiece(stationMarker({ … })). Pure, no I/O.
|
|
9
|
+
*/
|
|
10
|
+
import type { Drawn } from '@brunosouzas/design-system';
|
|
11
|
+
/** The piece's shapes, then its words, as SVG text. */
|
|
12
|
+
export declare function writePiece(drawn: Drawn): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { escapeXml, tag } from './xml.js';
|
|
2
|
+
function writeNode(node) {
|
|
3
|
+
if (typeof node === 'string')
|
|
4
|
+
return escapeXml(node);
|
|
5
|
+
const attrs = {};
|
|
6
|
+
for (const [name, value] of Object.entries(node.attrs))
|
|
7
|
+
if (name !== 'font-family')
|
|
8
|
+
attrs[name] = value;
|
|
9
|
+
return tag(node.tag, attrs, node.children.length ? node.children.map(writeNode).join('') : undefined);
|
|
10
|
+
}
|
|
11
|
+
/** The piece's shapes, then its words, as SVG text. */
|
|
12
|
+
export function writePiece(drawn) {
|
|
13
|
+
return [...drawn.body, ...drawn.text].map(writeNode).join('');
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=pieces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pieces.js","sourceRoot":"","sources":["../../src/map/pieces.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,SAAS,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAE3D,SAAS,SAAS,CAAC,IAAsB;IACvC,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC;IACrD,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;QAAE,IAAI,IAAI,KAAK,aAAa;YAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;IACxG,OAAO,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACxG,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,UAAU,CAAC,KAAY;IACrC,OAAO,CAAC,GAAG,KAAK,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AAChE,CAAC"}
|
package/dist/map/relations.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* (src/skills/metro.ts), which the page script turns into a link; the page lists the same items.
|
|
17
17
|
*/
|
|
18
18
|
import { type MapNode, type NodeKind, type RelationKind, type SkillGraph } from '../skills/graph.js';
|
|
19
|
-
import type
|
|
19
|
+
import { type Theme } from './themes.js';
|
|
20
20
|
export interface RelationNode {
|
|
21
21
|
ref: string;
|
|
22
22
|
name: string;
|
package/dist/map/relations.js
CHANGED
|
@@ -17,9 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { incoming, outgoing } from '../skills/graph.js';
|
|
19
19
|
import { cleanText, stationRef } from '../skills/metro.js';
|
|
20
|
-
import {
|
|
20
|
+
import { hexNode, messageArrow, nodeBlock, pillNode } from '@brunosouzas/design-system';
|
|
21
21
|
import { textWidth } from './labels.js';
|
|
22
|
-
import {
|
|
22
|
+
import { writePiece } from './pieces.js';
|
|
23
|
+
import { checkInk } from './themes.js';
|
|
24
|
+
import { escapeXml, SVG_NAMESPACE, tag } from './xml.js';
|
|
23
25
|
/** Most boxes on one side; over it the page gives the number of relations instead of a diagram. */
|
|
24
26
|
export const MAX_SIDE_ITEMS = 100;
|
|
25
27
|
/** Most code points of a name a box shows before `…`. */
|
|
@@ -30,7 +32,8 @@ const ROW_GAP = 14;
|
|
|
30
32
|
const MIN_COLUMN_GAP = 96;
|
|
31
33
|
const PADDING = 24;
|
|
32
34
|
const HEADING_HEIGHT = 34;
|
|
33
|
-
|
|
35
|
+
/** Where nodeBlock starts its text; pills and hexagons start it at half the height. */
|
|
36
|
+
const TEXT_INSET = 12;
|
|
34
37
|
const MIN_BOX_WIDTH = 160;
|
|
35
38
|
const BOLD_FACTOR = 1.1;
|
|
36
39
|
const SKILL_RADIUS = 6;
|
|
@@ -49,50 +52,42 @@ export function shownName(name) {
|
|
|
49
52
|
const points = Array.from(cleanText(name));
|
|
50
53
|
return points.length > MAX_NAME_CODE_POINTS ? points.slice(0, MAX_NAME_CODE_POINTS).join('') + '…' : points.join('');
|
|
51
54
|
}
|
|
55
|
+
/** The name a box shows, or its station reference when cleaning leaves nothing (Relation box text room). */
|
|
56
|
+
const boxName = (item) => (shownName(item.name).trim() ? shownName(item.name) : item.ref);
|
|
57
|
+
/** Where the pieces start the text: 12 in a box, half the height in a pill or a hexagon. */
|
|
58
|
+
const insetOf = (kind) => (kind === 'skill' ? TEXT_INSET : BOX_HEIGHT / 2);
|
|
52
59
|
function columnWidth(nodes) {
|
|
53
|
-
const widest = nodes.reduce((most, item) => Math.max(most, textWidth(
|
|
60
|
+
const widest = nodes.reduce((most, item) => Math.max(most, textWidth(boxName(item)) * BOLD_FACTOR + insetOf(item.kind) * 2), 0);
|
|
54
61
|
return Math.ceil(Math.max(MIN_BOX_WIDTH, widest));
|
|
55
62
|
}
|
|
56
63
|
const stackHeight = (count) => count * (BOX_HEIGHT + ROW_GAP) - ROW_GAP;
|
|
57
|
-
/**
|
|
58
|
-
function shapeOf(kind, x, y, width) {
|
|
59
|
-
if (kind === 'agent') {
|
|
60
|
-
const cut = BOX_HEIGHT / 2;
|
|
61
|
-
return (by, attrs) => {
|
|
62
|
-
const [left, top] = [x + by[0], y + by[1]];
|
|
63
|
-
const points = [[left + cut, top], [left + width - cut, top], [left + width, top + cut], [left + width - cut, top + BOX_HEIGHT], [left + cut, top + BOX_HEIGHT], [left, top + cut]];
|
|
64
|
-
return tag('polygon', { points: points.map(point => point.map(number).join(',')).join(' '), ...attrs });
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
const rx = kind === 'playbook' ? BOX_HEIGHT / 2 : SKILL_RADIUS;
|
|
68
|
-
return (by, attrs) => tag('rect', { x: x + by[0], y: y + by[1], width, height: BOX_HEIGHT, rx, ...attrs });
|
|
69
|
-
}
|
|
64
|
+
/** Skill a box with a small radius, playbook a pill, agent a hexagon: the design system's node pieces. */
|
|
70
65
|
function box(item, x, y, width, theme, centre) {
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return tag('g', { 'data-ref': item.ref }, content);
|
|
66
|
+
const params = {
|
|
67
|
+
x, y, width, height: BOX_HEIGHT, title: boxName(item), subtitle: centre ? item.kind : item.relation ?? item.kind,
|
|
68
|
+
state: centre ? 'focus' : 'normal', inkScale: INK_SCALE, surface: theme.surface,
|
|
69
|
+
};
|
|
70
|
+
const drawn = item.kind === 'agent' ? hexNode(params) : item.kind === 'playbook' ? pillNode(params) : nodeBlock({ ...params, radius: SKILL_RADIUS });
|
|
71
|
+
return tag('g', { 'data-ref': item.ref }, tag('title', {}, escapeXml(cleanText(item.name))) + writePiece(drawn));
|
|
78
72
|
}
|
|
79
73
|
function nothing(x, y, width, theme) {
|
|
80
|
-
return
|
|
81
|
-
+ tag('text', { x: x + width / 2, y: y + 28, fill: theme.muted, 'font-size': 13, 'text-anchor': 'middle' }, 'Nothing');
|
|
74
|
+
return writePiece(nodeBlock({ x, y, width, height: BOX_HEIGHT, title: 'Nothing', state: 'placeholder', radius: SKILL_RADIUS, surface: theme.surface }));
|
|
82
75
|
}
|
|
83
76
|
function column(input, centreTop, theme) {
|
|
84
77
|
if (!input.nodes.length)
|
|
85
78
|
return nothing(input.x, centreTop, input.width, theme);
|
|
86
79
|
return input.nodes.map((item, i) => box(item, input.x, input.top + i * (BOX_HEIGHT + ROW_GAP), input.width, theme, false)).join('');
|
|
87
80
|
}
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
/** Arrows pointing right: from a left box to the centre, or from the centre to a right box. */
|
|
82
|
+
function edges(input, side, columnX, centreX, centreY, theme) {
|
|
90
83
|
return input.nodes.map((_, i) => {
|
|
91
84
|
const y = input.top + i * (BOX_HEIGHT + ROW_GAP) + BOX_HEIGHT / 2;
|
|
92
|
-
|
|
85
|
+
const [from, to] = side === 'left' ? [[columnX, y], [centreX, centreY]] : [[centreX, centreY], [columnX, y]];
|
|
86
|
+
return writePiece(messageArrow({ from, to, surface: theme.surface }));
|
|
93
87
|
}).join('');
|
|
94
88
|
}
|
|
95
89
|
export function renderRelations(input, theme) {
|
|
90
|
+
checkInk(theme);
|
|
96
91
|
const rows = Math.max(input.left.length, input.right.length, 1);
|
|
97
92
|
const top = PADDING + HEADING_HEIGHT;
|
|
98
93
|
const height = top + stackHeight(rows) + PADDING;
|
|
@@ -113,8 +108,8 @@ export function renderRelations(input, theme) {
|
|
|
113
108
|
heading('Brought in by', left.x),
|
|
114
109
|
heading('This item', centreX),
|
|
115
110
|
heading('Brings in', right.x),
|
|
116
|
-
edges(left, left.x + left.width, centreX, centreY, theme),
|
|
117
|
-
edges(right, right.x, centreX + centreWidth, centreY, theme),
|
|
111
|
+
edges(left, 'left', left.x + left.width, centreX, centreY, theme),
|
|
112
|
+
edges(right, 'right', right.x, centreX + centreWidth, centreY, theme),
|
|
118
113
|
column(left, centreTop, theme),
|
|
119
114
|
box(input.centre, centreX, centreTop, centreWidth, theme, true),
|
|
120
115
|
column(right, centreTop, theme),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../src/map/relations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAmE,MAAM,oBAAoB,CAAC;AACzH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"relations.js","sourceRoot":"","sources":["../../src/map/relations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAmE,MAAM,oBAAoB,CAAC;AACzH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACxF,OAAO,EAAE,SAAS,EA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AC,IAAI,CAAC,EAAE,CAAC,CAAC;UACpF,GAAG,CAAC,MAAM,EAAE,EAAE,EAAE,uEAAuE,CAAC,CAAC;IAC7F,OAAO,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/map/strip.js
CHANGED
|
@@ -11,10 +11,13 @@
|
|
|
11
11
|
* data-ref, which the page script turns into links; the page also lists them as text links.
|
|
12
12
|
*/
|
|
13
13
|
import { badgeWidth } from './badges.js';
|
|
14
|
-
import {
|
|
14
|
+
import { lineBadge, pipe as pipePiece, stationMarker } from '@brunosouzas/design-system';
|
|
15
15
|
import { textWidth } from './labels.js';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
16
|
+
import { writePiece } from './pieces.js';
|
|
17
|
+
import { checkInk, themes } from './themes.js';
|
|
18
|
+
import { escapeXml, number, SVG_NAMESPACE, tag } from './xml.js';
|
|
19
|
+
/** Half the length of an interchange capsule on the strip (its ends are the interchange radius away). */
|
|
20
|
+
const INTERCHANGE_HALF = 4;
|
|
18
21
|
const PADDING = 32;
|
|
19
22
|
const LINE_Y = 56;
|
|
20
23
|
const MIN_SPACING = 150;
|
|
@@ -52,11 +55,7 @@ function fit(title) {
|
|
|
52
55
|
/** A badge as an ink-style sticker; `flat` leaves out the shadow and rim and keeps the outline inside the box. */
|
|
53
56
|
function badgeShape(item, x, y, theme, flat = false) {
|
|
54
57
|
const width = badgeWidth(item.badge);
|
|
55
|
-
|
|
56
|
-
const shape = (by, attrs) => tag('rect', { x: x + inset + by[0], y: y + inset + by[1], width: width - inset * 2, height: BADGE_HEIGHT - inset * 2, rx: BADGE_HEIGHT / 2 - inset, ...attrs });
|
|
57
|
-
const face = flat ? shape([0, 0], { fill: item.color, stroke: theme.outline, 'stroke-width': theme.outlineWidth }) : sticker(theme, shape, item.color);
|
|
58
|
-
return face
|
|
59
|
-
+ tag('text', { x: x + width / 2, y: y + 14.5, fill: theme.badgeText, 'font-size': 12, 'font-weight': 700, 'text-anchor': 'middle' }, escapeXml(item.badge));
|
|
58
|
+
return writePiece(lineBadge({ x: x + width / 2, y: y + BADGE_HEIGHT / 2, text: item.badge, fill: item.color, width, height: BADGE_HEIGHT, flat, surface: theme.surface }));
|
|
60
59
|
}
|
|
61
60
|
/** One row of interchange badges centred under a stop; each badge links to its journey. */
|
|
62
61
|
function interchangeRow(stop, centre, y, theme) {
|
|
@@ -70,11 +69,10 @@ function interchangeRow(stop, centre, y, theme) {
|
|
|
70
69
|
}
|
|
71
70
|
function stopGroup(input, stop, x, theme) {
|
|
72
71
|
const interchange = stop.interchanges.length > 0;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
: sticker(theme, disc(stopRadius(theme)), theme.station);
|
|
72
|
+
// Every stop is a white circle on the pipe, as on the map; an interchange a short vertical capsule.
|
|
73
|
+
const marker = writePiece(interchange
|
|
74
|
+
? stationMarker({ cx: x, cy: LINE_Y - INTERCHANGE_HALF, to: [x, LINE_Y + INTERCHANGE_HALF], surface: theme.surface })
|
|
75
|
+
: stationMarker({ cx: x, cy: LINE_Y, r: stopRadius(theme), surface: theme.surface }));
|
|
78
76
|
const title = fit(stop.title);
|
|
79
77
|
const label = tag('text', { x, y: LINE_Y + 36, fill: theme.text, 'font-size': 13, 'font-weight': interchange ? 900 : 700, 'text-anchor': 'middle' }, escapeXml(title));
|
|
80
78
|
// An invisible area over the marker and its label, so a click between them still opens the stop.
|
|
@@ -87,10 +85,10 @@ function stopGroup(input, stop, x, theme) {
|
|
|
87
85
|
const stopRadius = (theme) => (theme.lineWidth + (theme.casing.enabled ? theme.casing.extraWidth : 0)) / 2 + 3;
|
|
88
86
|
/** The journey's line as a pipe: the ink casing, then the line's colour. */
|
|
89
87
|
function pipe(from, to, color, theme) {
|
|
90
|
-
|
|
91
|
-
return (theme.casing.enabled ? stroke(theme.casing.color, theme.lineWidth + theme.casing.extraWidth) : '') + stroke(color, theme.lineWidth);
|
|
88
|
+
return writePiece(pipePiece({ d: `M${number(from)},${LINE_Y} L${number(to)},${LINE_Y}`, fill: color, width: theme.lineWidth, casing: theme.casing.enabled ? theme.casing.extraWidth : 0 }));
|
|
92
89
|
}
|
|
93
90
|
export function renderStrip(input, theme) {
|
|
91
|
+
checkInk(theme);
|
|
94
92
|
const widest = input.stops.reduce((most, stop) => Math.max(most, textWidth(fit(stop.title))), 0);
|
|
95
93
|
const spacing = Math.max(MIN_SPACING, widest + 28);
|
|
96
94
|
const first = PADDING + spacing / 2;
|
package/dist/map/strip.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../src/map/strip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"strip.js","sourceRoot":"","sources":["../../src/map/strip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,IAAI,IAAI,SAAS,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACzF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAc,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,EAAmB,MAAM,UAAU,CAAC;AAElF,yGAAyG;AACzG,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAM3B,MAAM,OAAO,GAAG,EAAE,CAAC;AACnB,MAAM,MAAM,GAAG,EAAE,CAAC;AAClB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAA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U,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;AACjH,CAAC"}
|
package/dist/map/svg.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/** Render plain geometry as a self-contained, safe SVG. Call renderSvg(geometry, themes.light).
|
|
2
2
|
* Text has one escaping path; geometry has no external resources, IDs, links or CSS.
|
|
3
3
|
* Every visual choice comes from Theme data. Invalid colours/nonfinite geometry throw.
|
|
4
|
-
* Ink style
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Ink style: stations, interchanges, lines, terminal and legend badges and rule counts are drawn by
|
|
5
|
+
* the design system's pieces (stationMarker, pipe, lineBadge, countBadge), and licence markers,
|
|
6
|
+
* renewal rings, suggested halos and zones by licenceMark, renewalRing, suggestedHalo and zone, all
|
|
7
|
+
* written through src/map/pieces.ts, so the allow-lists and escaping of
|
|
8
|
+
* src/map/xml.ts apply to them; the legend panel keeps this file's drawing with the same token values.
|
|
9
|
+
* A theme whose ink differs from its surface's tokens is refused (checkInk).
|
|
7
10
|
* Strokes, stations, labels, terminal badges and legend entries carry data-line (and stations
|
|
8
11
|
* and labels data-zone) for the site's map script; those values are escaped like text.
|
|
9
12
|
* renderSvg(geometry, theme, { chrome: false }) leaves out the title band and the legend panel and
|
|
@@ -11,8 +14,12 @@
|
|
|
11
14
|
* HTML (renderSymbol draws one symbol). The default output is what `stackledger map` writes.
|
|
12
15
|
*/
|
|
13
16
|
import { type MapGeometry } from './layout.js';
|
|
14
|
-
import type
|
|
17
|
+
import { type Theme } from './themes.js';
|
|
18
|
+
import type { Stroke } from './parallel.js';
|
|
15
19
|
export { escapeXml } from './xml.js';
|
|
20
|
+
/** The `d` of a stroke's drawn path: straight parts as `L`, round bends as `A r,r 0 0 sweep x,y`
|
|
21
|
+
* (metro-map: Round bends). Every operand goes through number(), which throws on a non-finite value. */
|
|
22
|
+
export declare function pathData(stroke: Stroke): string;
|
|
16
23
|
/** chrome (default true): draw the title band and the legend panel around the map. */
|
|
17
24
|
export interface RenderOptions {
|
|
18
25
|
chrome?: boolean;
|
package/dist/map/svg.js
CHANGED
|
@@ -1,75 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
* Text has one escaping path; geometry has no external resources, IDs, links or CSS.
|
|
3
|
-
* Every visual choice comes from Theme data. Invalid colours/nonfinite geometry throw.
|
|
4
|
-
* Ink style (theme casing, outline, shadow, rim): lines are pipes, an ink casing under the line
|
|
5
|
-
* colour; interchanges, badges, licence markers, renewal rings and the legend panel get an ink
|
|
6
|
-
* outline, and their hard shadow is a copy moved by the theme offset, drawn first in the same group.
|
|
7
|
-
* Strokes, stations, labels, terminal badges and legend entries carry data-line (and stations
|
|
8
|
-
* and labels data-zone) for the site's map script; those values are escaped like text.
|
|
9
|
-
* renderSvg(geometry, theme, { chrome: false }) leaves out the title band and the legend panel and
|
|
10
|
-
* crops to the map frame: the site's map page shows the title, the line legend and the symbols in
|
|
11
|
-
* HTML (renderSymbol draws one symbol). The default output is what `stackledger map` writes.
|
|
12
|
-
*/
|
|
13
|
-
import { RULE_COUNT_FONT_SIZE } from './layout.js';
|
|
1
|
+
import { checkInk } from './themes.js';
|
|
14
2
|
import { badgeWidth } from './badges.js';
|
|
3
|
+
import { countBadge, licenceMark, lineBadge, pipe as pipePiece, renewalRing, stationMarker, suggestedHalo, zone as zonePiece } from '@brunosouzas/design-system';
|
|
15
4
|
import { sticker } from './ink.js';
|
|
16
|
-
import {
|
|
5
|
+
import { writePiece } from './pieces.js';
|
|
6
|
+
import { tag, escapeXml, number, SVG_NAMESPACE } from './xml.js';
|
|
17
7
|
export { escapeXml } from './xml.js';
|
|
18
8
|
const HEADER_HEIGHT = 64;
|
|
19
9
|
const FRAME_MARGIN = 16;
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
const length = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
23
|
-
const n = [-(b[1] - a[1]) / length * r, (b[0] - a[0]) / length * r];
|
|
24
|
-
const p = (point, sign) => `${number(point[0] + n[0] * sign)},${number(point[1] + n[1] * sign)}`;
|
|
25
|
-
const radius = number(r);
|
|
26
|
-
return `M${p(a, 1)} L${p(b, 1)} A${radius},${radius} 0 0 0 ${p(b, -1)} L${p(a, -1)} A${radius},${radius} 0 0 0 ${p(a, 1)} Z`;
|
|
27
|
-
}
|
|
28
|
-
/** Element builders bound to one theme. Catalogue text only ever passes through `text` or `title`. */
|
|
10
|
+
/** Element builders bound to one theme. Catalogue text only ever passes through `text`, `title` or a
|
|
11
|
+
* piece written by writePiece (zone titles), which escapes it the same way. */
|
|
29
12
|
function painter(theme) {
|
|
30
13
|
const text = (value, x, y, attrs = {}) => tag('text', { x, y, fill: theme.text, 'font-size': 13, ...attrs }, escapeXml(value));
|
|
31
14
|
const title = (value) => tag('title', {}, escapeXml(value));
|
|
32
15
|
const rect = (box, attrs = {}) => tag('rect', { x: box.x, y: box.y, width: box.w, height: box.h, ...attrs });
|
|
33
16
|
const line = (a, b, attrs) => tag('line', { x1: a[0], y1: a[1], x2: b[0], y2: b[1], ...attrs });
|
|
34
|
-
const circle = (centre, r, attrs) => tag('circle', { cx: centre[0], cy: centre[1], r, ...attrs });
|
|
35
|
-
const add = (point, by, scale = 1) => [point[0] + by[0] * scale, point[1] + by[1] * scale];
|
|
36
|
-
const rimmed = (width) => width + (theme.rim.enabled ? theme.rim.width * 2 : 0);
|
|
37
17
|
const boxSticker = (box, rx, fill) => sticker(theme, (by, attrs) => rect({ ...box, x: box.x + by[0], y: box.y + by[1] }, { ...attrs, rx }), fill);
|
|
38
|
-
const
|
|
39
|
-
/**
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return [
|
|
45
|
-
theme.rim.enabled ? band(theme.rim.color, rimmed(ink)) : '',
|
|
46
|
-
band(theme.outline, ink),
|
|
47
|
-
band(colour, width),
|
|
48
|
-
].join('');
|
|
49
|
-
};
|
|
50
|
-
/** Terminal badges are pill stickers, like the banner's labels. */
|
|
51
|
-
const badge = (item) => boxSticker(item.box, item.box.h / 2, item.color)
|
|
52
|
-
+ text(item.text, item.point[0], item.point[1] + 4.5, { fill: theme.badgeText, 'font-size': 12, 'font-weight': 700, 'text-anchor': 'middle' });
|
|
53
|
-
/** A stop is a circle sticker on its pipe; an interchange a capsule over all its lines. */
|
|
18
|
+
const surface = theme.surface;
|
|
19
|
+
/** Terminal badges: the design system's lineBadge, centred on the badge box. */
|
|
20
|
+
const badge = (item) => writePiece(lineBadge({
|
|
21
|
+
x: item.box.x + item.box.w / 2, y: item.box.y + item.box.h / 2, text: item.text, fill: item.color, width: item.box.w, height: item.box.h, surface,
|
|
22
|
+
}));
|
|
23
|
+
/** A stop or an interchange: the design system's stationMarker (a capsule from one end to the other). */
|
|
54
24
|
const marker = (item, muted) => {
|
|
55
|
-
const fill = muted ? theme.muted : theme.station;
|
|
56
25
|
const [a, b] = item.ends;
|
|
57
26
|
const length = Math.hypot(b[0] - a[0], b[1] - a[1]);
|
|
58
|
-
|
|
59
|
-
return discSticker(a, item.radius, fill);
|
|
60
|
-
return sticker(theme, (by, attrs) => tag('path', { d: capsulePath(add(a, by), add(b, by), item.radius), ...attrs }), fill);
|
|
27
|
+
return writePiece(stationMarker({ cx: a[0], cy: a[1], ...(length < 1e-9 ? {} : { to: b }), r: item.radius, state: muted ? 'deprecated' : 'normal', surface }));
|
|
61
28
|
};
|
|
62
|
-
const licence = (centre, hollow) =>
|
|
29
|
+
const licence = (centre, hollow) => writePiece(licenceMark({ cx: centre[0], cy: centre[1], state: hollow ? 'toBuy' : 'owned', surface }));
|
|
63
30
|
/** A rule count: a circle for one digit, a pill for more, in the panel colour, with the number. */
|
|
64
31
|
const ruleCount = (item) => {
|
|
65
32
|
const { box } = item;
|
|
66
|
-
|
|
67
|
-
return shape + text(item.text, box.x + box.w / 2, box.y + box.h / 2 + 4, { 'font-size': RULE_COUNT_FONT_SIZE, 'font-weight': 700, 'text-anchor': 'middle' });
|
|
33
|
+
return writePiece(countBadge({ cx: box.x + box.w / 2, cy: box.y + box.h / 2, text: item.text, width: box.w, height: box.h, surface }));
|
|
68
34
|
};
|
|
69
35
|
/** A line sample for the legend, drawn as a pipe like the lines on the map. */
|
|
70
|
-
const pipe = (a, b, colour) => (
|
|
71
|
-
|
|
72
|
-
|
|
36
|
+
const pipe = (a, b, colour) => writePiece(pipePiece({ d: `M${number(a[0])},${number(a[1])} L${number(b[0])},${number(b[1])}`, fill: colour, width: theme.lineWidth, casing: theme.casing.extraWidth }));
|
|
37
|
+
/** The legend's interchange: a short vertical capsule, as interchanges on a horizontal edge. */
|
|
38
|
+
const interchangeSymbol = (centre) => writePiece(stationMarker({ cx: centre[0], cy: centre[1] - 1.5, to: [centre[0], centre[1] + 1.5], r: 6, surface }));
|
|
39
|
+
return { text, title, rect, line, boxSticker, badge, marker, licence, ruleCount, pipe, interchangeSymbol };
|
|
73
40
|
}
|
|
74
41
|
function gridLayer(frame, theme, paint) {
|
|
75
42
|
const parts = [paint.rect(frame, { fill: 'none', stroke: theme.grid, 'stroke-width': 1 })];
|
|
@@ -83,28 +50,30 @@ function gridLayer(frame, theme, paint) {
|
|
|
83
50
|
}
|
|
84
51
|
return parts.join('');
|
|
85
52
|
}
|
|
86
|
-
function
|
|
87
|
-
color(zone.color);
|
|
88
|
-
if (zone.hull.length === 1)
|
|
89
|
-
return paint.circle(zone.hull[0], zone.padding, { fill: zone.color });
|
|
90
|
-
if (zone.hull.length === 2) {
|
|
91
|
-
return paint.line(zone.hull[0], zone.hull[1], { stroke: zone.color, 'stroke-width': zone.padding * 2, 'stroke-linecap': 'round' });
|
|
92
|
-
}
|
|
93
|
-
const points = zone.hull.map(point => point.map(number).join(',')).join(' ');
|
|
94
|
-
return tag('polygon', { points, fill: zone.color, stroke: zone.color, 'stroke-width': zone.padding * 2, 'stroke-linejoin': 'round' });
|
|
95
|
-
}
|
|
96
|
-
function zonesLayer(zones, theme, paint) {
|
|
53
|
+
function zonesLayer(zones, theme) {
|
|
97
54
|
return zones.map(zone => {
|
|
98
|
-
|
|
99
|
-
const title =
|
|
100
|
-
return
|
|
55
|
+
// The piece refuses a blank label; a whitespace-only title (which the catalogue accepts) draws the area alone.
|
|
56
|
+
const title = zone.title.trim() === '' ? {} : { title: zone.title, titleAt: [zone.titleBox.x, zone.titleBox.y] };
|
|
57
|
+
return writePiece(zonePiece({ points: zone.hull, fill: zone.color, ...title, surface: theme.surface }));
|
|
101
58
|
}).join('');
|
|
102
59
|
}
|
|
60
|
+
/** The `d` of a stroke's drawn path: straight parts as `L`, round bends as `A r,r 0 0 sweep x,y`
|
|
61
|
+
* (metro-map: Round bends). Every operand goes through number(), which throws on a non-finite value. */
|
|
62
|
+
export function pathData(stroke) {
|
|
63
|
+
return stroke.path.map((part, i) => {
|
|
64
|
+
const to = `${number(part.to[0])},${number(part.to[1])}`;
|
|
65
|
+
if (!i)
|
|
66
|
+
return `M${to}`;
|
|
67
|
+
if (!part.arc)
|
|
68
|
+
return `L${to}`;
|
|
69
|
+
const r = number(part.arc.radius);
|
|
70
|
+
return `A${r},${r} 0 0 ${part.arc.sweep} ${to}`;
|
|
71
|
+
}).join(' ');
|
|
72
|
+
}
|
|
103
73
|
function lineGroup(stroke, theme, paint) {
|
|
104
|
-
const d = stroke
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
return tag('g', { 'data-ref': stroke.ref, 'data-line': stroke.ref }, paint.title(stroke.title) + casing + path(stroke.color, theme.lineWidth));
|
|
74
|
+
const d = pathData(stroke);
|
|
75
|
+
const body = writePiece(pipePiece({ d, fill: stroke.color, width: theme.lineWidth, casing: theme.casing.enabled ? theme.casing.extraWidth : 0 }));
|
|
76
|
+
return tag('g', { 'data-ref': stroke.ref, 'data-line': stroke.ref }, paint.title(stroke.title) + body);
|
|
108
77
|
}
|
|
109
78
|
/** data-line (the station's lines, in line order) and data-zone (only for a drawn zone), shared by a station and its label. */
|
|
110
79
|
function stationData(station, drawnZones) {
|
|
@@ -119,9 +88,9 @@ function stationGroup(station, data, theme, paint) {
|
|
|
119
88
|
const centre = [box.x + box.w / 2, box.y + box.h / 2];
|
|
120
89
|
const mark = paint.marker(station.marker, station.deprecated);
|
|
121
90
|
const suggested = station.suggested
|
|
122
|
-
?
|
|
91
|
+
? writePiece(suggestedHalo({ cx: centre[0], cy: centre[1], r: halo + 3, surface: theme.surface }))
|
|
123
92
|
: '';
|
|
124
|
-
const ring = station.renewal ?
|
|
93
|
+
const ring = station.renewal ? writePiece(renewalRing({ cx: centre[0], cy: centre[1], r: halo, surface: theme.surface })) : '';
|
|
125
94
|
const licence = station.licencePoint ? paint.licence(station.licencePoint, station.licence === 'hollow') : '';
|
|
126
95
|
const rules = station.ruleCount ? paint.ruleCount(station.ruleCount) : '';
|
|
127
96
|
return tag('g', { 'data-ref': station.ref, ...data }, paint.title(station.title) + suggested + ring + mark + licence + rules);
|
|
@@ -147,16 +116,16 @@ function headerLayer(geometry, theme, paint) {
|
|
|
147
116
|
}
|
|
148
117
|
function legendSymbol(symbol, centre, theme, paint) {
|
|
149
118
|
if (symbol === 'interchange')
|
|
150
|
-
return paint.
|
|
119
|
+
return paint.interchangeSymbol(centre);
|
|
151
120
|
if (symbol === 'licence' || symbol === 'licence to buy')
|
|
152
121
|
return paint.licence(centre, symbol === 'licence to buy');
|
|
153
122
|
// A little smaller than on the map, so the dark theme's rim and shadow stay inside the 24 x 24 symbol.
|
|
154
123
|
if (symbol === 'number of rules')
|
|
155
124
|
return paint.ruleCount({ text: '3', box: { x: centre[0] - 7.5, y: centre[1] - 7.5, w: 15, h: 15 } });
|
|
156
125
|
if (symbol === 'suggested position') {
|
|
157
|
-
return
|
|
126
|
+
return writePiece(suggestedHalo({ cx: centre[0], cy: centre[1], r: 9, surface: theme.surface }));
|
|
158
127
|
}
|
|
159
|
-
return
|
|
128
|
+
return writePiece(renewalRing({ cx: centre[0], cy: centre[1], r: 6.5, surface: theme.surface }));
|
|
160
129
|
}
|
|
161
130
|
function legendLayer(geometry, theme, paint) {
|
|
162
131
|
const panel = geometry.legend.box;
|
|
@@ -192,12 +161,14 @@ function frameView(geometry) {
|
|
|
192
161
|
}
|
|
193
162
|
/** One legend symbol on its own (24 x 24), for the HTML legend under the site's map. */
|
|
194
163
|
export function renderSymbol(symbol, theme) {
|
|
164
|
+
checkInk(theme);
|
|
195
165
|
const size = 24;
|
|
196
166
|
const attrs = { xmlns: SVG_NAMESPACE, role: 'img', viewBox: `0 0 ${size} ${size}`, width: size, height: size };
|
|
197
167
|
// Up and left of the centre, so the shadow down and to the right stays inside the square.
|
|
198
168
|
return tag('svg', attrs, legendSymbol(symbol, [size / 2 - 1.5, size / 2 - 1.5], theme, painter(theme)));
|
|
199
169
|
}
|
|
200
170
|
export function renderSvg(geometry, theme, options = {}) {
|
|
171
|
+
checkInk(theme);
|
|
201
172
|
const chrome = options.chrome ?? true;
|
|
202
173
|
const viewBox = chrome ? geometry.viewBox : frameView(geometry);
|
|
203
174
|
const paint = painter(theme);
|
|
@@ -212,7 +183,7 @@ export function renderSvg(geometry, theme, options = {}) {
|
|
|
212
183
|
const layers = [
|
|
213
184
|
background,
|
|
214
185
|
gridLayer(geometry.frame, theme, paint),
|
|
215
|
-
zonesLayer(geometry.zones, theme
|
|
186
|
+
zonesLayer(geometry.zones, theme),
|
|
216
187
|
lines,
|
|
217
188
|
stations,
|
|
218
189
|
labelsLayer(geometry, drawnZones, theme, paint) + empty,
|