@dversum/mcp-server 2.11.2 → 2.13.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/README.md +5 -0
- package/dist/src/client.d.ts +10 -0
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/client.js +21 -4
- package/dist/src/client.js.map +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/tools/creatives.d.ts +4 -0
- package/dist/src/tools/creatives.d.ts.map +1 -0
- package/dist/src/tools/creatives.js +78 -0
- package/dist/src/tools/creatives.js.map +1 -0
- package/dist/src/tools/invoices.d.ts.map +1 -1
- package/dist/src/tools/invoices.js +6 -5
- package/dist/src/tools/invoices.js.map +1 -1
- package/dist/src/tools/quotes.d.ts.map +1 -1
- package/dist/src/tools/quotes.js +6 -5
- package/dist/src/tools/quotes.js.map +1 -1
- package/dist/src/tools/request-bodies.spec.js +16 -0
- package/dist/src/tools/request-bodies.spec.js.map +1 -1
- package/dist/src/tools/subtasks.d.ts +14 -0
- package/dist/src/tools/subtasks.d.ts.map +1 -0
- package/dist/src/tools/subtasks.js +51 -0
- package/dist/src/tools/subtasks.js.map +1 -0
- package/dist/src/tools/subtasks.spec.d.ts +2 -0
- package/dist/src/tools/subtasks.spec.d.ts.map +1 -0
- package/dist/src/tools/subtasks.spec.js +90 -0
- package/dist/src/tools/subtasks.spec.js.map +1 -0
- package/dist/src/tools/text-slots.d.ts +17 -0
- package/dist/src/tools/text-slots.d.ts.map +1 -0
- package/dist/src/tools/text-slots.js +44 -0
- package/dist/src/tools/text-slots.js.map +1 -0
- package/dist/src/tools/text-slots.spec.d.ts +2 -0
- package/dist/src/tools/text-slots.spec.d.ts.map +1 -0
- package/dist/src/tools/text-slots.spec.js +31 -0
- package/dist/src/tools/text-slots.spec.js.map +1 -0
- package/dist/src/tools/universum.d.ts +42 -0
- package/dist/src/tools/universum.d.ts.map +1 -1
- package/dist/src/tools/universum.js +76 -2
- package/dist/src/tools/universum.js.map +1 -1
- package/dist/src/tools/whiteboard-brand.d.ts +4 -0
- package/dist/src/tools/whiteboard-brand.d.ts.map +1 -0
- package/dist/src/tools/whiteboard-brand.js +158 -0
- package/dist/src/tools/whiteboard-brand.js.map +1 -0
- package/dist/src/tools/whiteboard-compose.d.ts +39 -0
- package/dist/src/tools/whiteboard-compose.d.ts.map +1 -1
- package/dist/src/tools/whiteboard-compose.js +41 -17
- package/dist/src/tools/whiteboard-compose.js.map +1 -1
- package/dist/src/tools/whiteboards.d.ts.map +1 -1
- package/dist/src/tools/whiteboards.js +27 -7
- package/dist/src/tools/whiteboards.js.map +1 -1
- package/dist/src/whiteboard/brand.d.ts +58 -0
- package/dist/src/whiteboard/brand.d.ts.map +1 -0
- package/dist/src/whiteboard/brand.js +111 -0
- package/dist/src/whiteboard/brand.js.map +1 -0
- package/dist/src/whiteboard/elements.d.ts +1 -1
- package/dist/src/whiteboard/elements.d.ts.map +1 -1
- package/dist/src/whiteboard/elements.js.map +1 -1
- package/dist/src/whiteboard/measure.d.ts.map +1 -1
- package/dist/src/whiteboard/measure.js +4 -7
- package/dist/src/whiteboard/measure.js.map +1 -1
- package/dist/src/whiteboard/sections.d.ts +83 -1
- package/dist/src/whiteboard/sections.d.ts.map +1 -1
- package/dist/src/whiteboard/sections.js +392 -59
- package/dist/src/whiteboard/sections.js.map +1 -1
- package/dist/src/whiteboard/sections.spec.js +112 -3
- package/dist/src/whiteboard/sections.spec.js.map +1 -1
- package/dist/src/whiteboard/theme.d.ts +159 -0
- package/dist/src/whiteboard/theme.d.ts.map +1 -0
- package/dist/src/whiteboard/theme.js +441 -0
- package/dist/src/whiteboard/theme.js.map +1 -0
- package/package.json +1 -1
|
@@ -10,11 +10,38 @@
|
|
|
10
10
|
* caller never computes a coordinate, and `composeBoard` never has to
|
|
11
11
|
* guess where the next section starts.
|
|
12
12
|
*/
|
|
13
|
-
import { TYPE_SCALE, SPACE, GUTTER,
|
|
13
|
+
import { TYPE_SCALE, SPACE, GUTTER, STROKE, COLOR as LITERAL, SHADOW as LITERAL_SHADOW, CARD_PADDING, } from './tokens.js';
|
|
14
|
+
import { radius, brandFonts, brandLogoAspect } from './brand.js';
|
|
14
15
|
import { rect, ellipse, text, hrule, connector, icon, image, round, } from './elements.js';
|
|
15
16
|
import { textBlockHeight, textWidth } from './measure.js';
|
|
16
17
|
import { safeLinkHref } from './link.js';
|
|
17
18
|
import { resolveStyle, gapFor, DEFAULT_STYLE } from './styles.js';
|
|
19
|
+
// ---- Colour -------------------------------------------------------------
|
|
20
|
+
// Brand roles are written as tokens, which the canvas resolves against the
|
|
21
|
+
// board's theme. On a board without a theme they resolve to the literal
|
|
22
|
+
// palette in tokens.ts, so nothing looks different; on a branded board the
|
|
23
|
+
// whole composition takes the brand, and follows it when it changes.
|
|
24
|
+
// Semantic colours (up, down) are not the brand's to change.
|
|
25
|
+
const COLOR = {
|
|
26
|
+
accent: '$accent',
|
|
27
|
+
accentStrong: '$accentStrong',
|
|
28
|
+
ink: '$ink',
|
|
29
|
+
inkMuted: '$inkMuted',
|
|
30
|
+
surface: '$surface',
|
|
31
|
+
surfaceMuted: '$surfaceMuted',
|
|
32
|
+
border: '$border',
|
|
33
|
+
/** Dark bands and buttons. The same as ink until a brand says otherwise. */
|
|
34
|
+
primary: '$primary',
|
|
35
|
+
/** Legible text on primary / accent fills, whichever the brand's colours are. */
|
|
36
|
+
onPrimary: '$onPrimary',
|
|
37
|
+
onAccent: '$onAccent',
|
|
38
|
+
danger: LITERAL.danger,
|
|
39
|
+
success: LITERAL.success,
|
|
40
|
+
};
|
|
41
|
+
const SHADOW = {
|
|
42
|
+
soft: { ...LITERAL_SHADOW.soft, color: COLOR.ink },
|
|
43
|
+
focus: { ...LITERAL_SHADOW.focus, color: COLOR.ink },
|
|
44
|
+
};
|
|
18
45
|
// ---- Layout constants ---------------------------------------------------
|
|
19
46
|
/** Space from the canvas origin to the content column. */
|
|
20
47
|
export const CANVAS_MARGIN = SPACE.xxl;
|
|
@@ -39,6 +66,9 @@ export const NARROW_WIDTH = 360;
|
|
|
39
66
|
export const NARROW_MARGIN = 16;
|
|
40
67
|
/** Icon size inside a feature card. */
|
|
41
68
|
const CARD_ICON = 32;
|
|
69
|
+
/** The tinted disc a feature card's icon sits on, and the glyph inside it. */
|
|
70
|
+
const ICON_BADGE = 48;
|
|
71
|
+
const CARD_ICON_GLYPH = 24;
|
|
42
72
|
/**
|
|
43
73
|
* How tall a hero stands in page layout.
|
|
44
74
|
*
|
|
@@ -62,6 +92,29 @@ function measureIn(env) {
|
|
|
62
92
|
function lineHeightOf(role) {
|
|
63
93
|
return Math.ceil(TYPE_SCALE[role].size * TYPE_SCALE[role].lineHeight);
|
|
64
94
|
}
|
|
95
|
+
const PILL_H = 28;
|
|
96
|
+
const PILL_ROLE = 'body';
|
|
97
|
+
const PILL_FONT = TYPE_SCALE[PILL_ROLE].size;
|
|
98
|
+
/** Width a pill needs for its label. */
|
|
99
|
+
function pillWidth(label) {
|
|
100
|
+
return round(textWidth(label, PILL_FONT, 'bold') + SPACE.md * 2);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* A small rounded label on a tint of its own colour: a change (+38 %), a
|
|
104
|
+
* status (Erledigt). A tinted fill reads as a label at a glance, where the
|
|
105
|
+
* same words as bare 10 px text read as a footnote.
|
|
106
|
+
*/
|
|
107
|
+
function pill(id, x, y, label, color, opts = {}) {
|
|
108
|
+
const w = pillWidth(label);
|
|
109
|
+
const bg = rect(id('pill'), x, y, w, PILL_H, { fill: color, cornerRadius: radius().pill });
|
|
110
|
+
bg.opacity = opts.tint ?? 0.14;
|
|
111
|
+
const lh = lineHeightOf(PILL_ROLE);
|
|
112
|
+
const fg = text(id('pill-label'), x, y + round((PILL_H - lh) / 2), w, lh, label, {
|
|
113
|
+
fontSize: PILL_FONT, lineHeight: TYPE_SCALE[PILL_ROLE].lineHeight, color, fontWeight: 'bold', align: 'center',
|
|
114
|
+
...(opts.family ? { fontFamily: opts.family } : {}),
|
|
115
|
+
});
|
|
116
|
+
return { elements: [bg, fg], width: w };
|
|
117
|
+
}
|
|
65
118
|
/** A text element sized to exactly the height its content will occupy. */
|
|
66
119
|
function block(id, x, y, width, content, role, opts) {
|
|
67
120
|
const family = opts.family ?? 'sans';
|
|
@@ -100,7 +153,7 @@ function placeholderElements(id, x, y, w, h, brief) {
|
|
|
100
153
|
const stack = glyph + SPACE.md + briefH;
|
|
101
154
|
const top = y + round((h - stack) / 2);
|
|
102
155
|
return [
|
|
103
|
-
rect(id('slot'), x, y, w, h, { fill: COLOR.surfaceMuted, cornerRadius:
|
|
156
|
+
rect(id('slot'), x, y, w, h, { fill: COLOR.surfaceMuted, cornerRadius: radius().md }),
|
|
104
157
|
icon(id('slot-icon'), x + round((w - glyph) / 2), top, glyph, { iconName: 'Image', color: COLOR.inkMuted }),
|
|
105
158
|
block(id('slot-brief'), innerX, top + glyph + SPACE.md, inner, brief, 'body', {
|
|
106
159
|
color: COLOR.inkMuted, align: 'center',
|
|
@@ -112,7 +165,7 @@ function visualElement(id, x, y, w, h, visual) {
|
|
|
112
165
|
// Callers that want a placeholder go through visualElements, which can
|
|
113
166
|
// return the several elements a slot needs. Reaching here means the
|
|
114
167
|
// caller only handles one, so fall back to the frame alone.
|
|
115
|
-
return rect(id, x, y, w, h, { fill: COLOR.surfaceMuted, cornerRadius:
|
|
168
|
+
return rect(id, x, y, w, h, { fill: COLOR.surfaceMuted, cornerRadius: radius().md });
|
|
116
169
|
}
|
|
117
170
|
if (visual.kind === 'image') {
|
|
118
171
|
return image(id, x, y, w, h, { src: visual.src, ...(visual.alt !== undefined ? { alt: visual.alt } : {}) });
|
|
@@ -179,20 +232,35 @@ export function hero(env, c) {
|
|
|
179
232
|
const st = env.style;
|
|
180
233
|
const els = [];
|
|
181
234
|
const hasVisual = !!c.visual;
|
|
182
|
-
const
|
|
235
|
+
const highlights = hasVisual ? [] : (c.highlights ?? []).slice(0, 3);
|
|
236
|
+
const hasSide = hasVisual || highlights.length > 0;
|
|
237
|
+
const sideBySide = hasSide && !env.narrow;
|
|
183
238
|
const centred = st.heroAlign === 'center' && !sideBySide;
|
|
184
239
|
const textW = sideBySide
|
|
185
240
|
? round((env.width - GUTTER) / 2)
|
|
186
241
|
: centred ? env.width : Math.min(env.width, 820);
|
|
187
242
|
const align = centred ? 'center' : 'left';
|
|
188
|
-
// In page layout
|
|
189
|
-
// middle of it.
|
|
243
|
+
// In page layout a landing-page hero claims a screen and its content sits
|
|
244
|
+
// in the middle of it. A report cover with key figures does not: the
|
|
245
|
+
// figures fill the right half, and a screen-tall cover would only add
|
|
246
|
+
// empty space above and below them.
|
|
190
247
|
// A phone screen is tall and narrow, so a hero that claims a laptop
|
|
191
248
|
// viewport would push everything else below two thumb-scrolls.
|
|
192
|
-
const
|
|
249
|
+
const claimsScreen = env.layout === 'page' && highlights.length === 0;
|
|
250
|
+
const minHeight = claimsScreen ? (env.narrow ? 420 : HERO_HEIGHT) : 0;
|
|
193
251
|
const measured = heroContentHeight(env, c, textW, centred);
|
|
194
|
-
const
|
|
252
|
+
const sideW = env.width - textW - GUTTER;
|
|
253
|
+
const cardsH = highlights.length ? highlightCardsHeight(highlights, sideBySide ? sideW : env.width) : 0;
|
|
254
|
+
const height = Math.max(measured, minHeight, sideBySide ? cardsH : 0);
|
|
195
255
|
let y = env.y + round(Math.max(0, height - measured) / 2);
|
|
256
|
+
// On a branded board with a logo, the hero opens with it. "$logo" shows
|
|
257
|
+
// whatever logo the brand has, now and after it changes.
|
|
258
|
+
const logo = heroLogo(c);
|
|
259
|
+
if (logo) {
|
|
260
|
+
const lx = centred ? env.x + round((env.width - logo.width) / 2) : env.x;
|
|
261
|
+
els.push(image(env.id('logo'), lx, y, logo.width, LOGO_HEIGHT, { src: '$logo', alt: 'Logo' }));
|
|
262
|
+
y += LOGO_HEIGHT + SPACE.xl;
|
|
263
|
+
}
|
|
196
264
|
// The mark above the headline is the loudest single tell that two boards
|
|
197
265
|
// came from the same template, so each style answers it differently and
|
|
198
266
|
// one style declines to have one at all.
|
|
@@ -227,15 +295,25 @@ export function hero(env, c) {
|
|
|
227
295
|
const btnX = centred ? env.x + round((env.width - btnW) / 2) : env.x;
|
|
228
296
|
const href = safeLinkHref(c.cta.href) ?? undefined;
|
|
229
297
|
els.push(rect(env.id('cta'), btnX, y, btnW, btnH, {
|
|
230
|
-
fill: COLOR.
|
|
298
|
+
fill: COLOR.primary, cornerRadius: radius().pill, ...(href ? { link: href } : {}),
|
|
231
299
|
}));
|
|
232
300
|
els.push(text(env.id('cta-label'), btnX, y + round((btnH - lineHeightOf('body')) / 2), btnW, lineHeightOf('body'), c.cta.label, {
|
|
233
301
|
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight,
|
|
234
|
-
color: COLOR.
|
|
302
|
+
color: COLOR.onPrimary, fontWeight: 'bold', align: 'center', fontFamily: st.body,
|
|
235
303
|
...(href ? { link: href } : {}),
|
|
236
304
|
}));
|
|
237
305
|
y += btnH;
|
|
238
306
|
}
|
|
307
|
+
if (highlights.length) {
|
|
308
|
+
if (sideBySide) {
|
|
309
|
+
const hy = env.y + round(Math.max(0, height - cardsH) / 2);
|
|
310
|
+
els.push(...highlightCards(env, env.x + textW + GUTTER, hy, sideW, highlights));
|
|
311
|
+
return { elements: els, height };
|
|
312
|
+
}
|
|
313
|
+
// Phone: the figures follow the words at full width.
|
|
314
|
+
els.push(...highlightCards(env, env.x, env.y + height + SPACE.xl, env.width, highlights));
|
|
315
|
+
return { elements: els, height: height + SPACE.xl + cardsH };
|
|
316
|
+
}
|
|
239
317
|
if (c.visual && sideBySide) {
|
|
240
318
|
const vw = env.width - textW - GUTTER;
|
|
241
319
|
// The visual matches the hero, not the text, so the two halves of the
|
|
@@ -253,10 +331,61 @@ export function hero(env, c) {
|
|
|
253
331
|
}
|
|
254
332
|
return { elements: els, height };
|
|
255
333
|
}
|
|
334
|
+
const LOGO_HEIGHT = 40;
|
|
335
|
+
// Key-figure cards beside the hero: label, the figure in headline type in
|
|
336
|
+
// the brand's main colour, and the change as a pill.
|
|
337
|
+
function highlightCardHeight(s) {
|
|
338
|
+
return CARD_PADDING * 2 + lineHeightOf('body') + SPACE.xs + lineHeightOf('headline') + (s.delta ? SPACE.sm + PILL_H : 0);
|
|
339
|
+
}
|
|
340
|
+
function highlightCardsHeight(stats, _w) {
|
|
341
|
+
return stats.reduce((h, s) => h + highlightCardHeight(s), 0) + (stats.length - 1) * SPACE.md;
|
|
342
|
+
}
|
|
343
|
+
function highlightCards(env, x, y, w, stats) {
|
|
344
|
+
const st = env.style;
|
|
345
|
+
const els = [];
|
|
346
|
+
let cy = y;
|
|
347
|
+
stats.forEach((s, i) => {
|
|
348
|
+
const h = highlightCardHeight(s);
|
|
349
|
+
els.push(rect(env.id(`highlight-${i}`), x, cy, w, h, {
|
|
350
|
+
fill: st.cards === 'raised' ? COLOR.surface : COLOR.surfaceMuted, cornerRadius: radius().md,
|
|
351
|
+
...(st.cards === 'raised' ? { shadow: { ...SHADOW.soft } } : {}),
|
|
352
|
+
}));
|
|
353
|
+
// A brand stripe on the leading edge ties the figures to the brand.
|
|
354
|
+
els.push(rect(env.id(`highlight-${i}-bar`), x, cy + CARD_PADDING, 4, h - CARD_PADDING * 2, {
|
|
355
|
+
fill: COLOR.accent, cornerRadius: 2,
|
|
356
|
+
}));
|
|
357
|
+
const tx = x + CARD_PADDING + SPACE.sm;
|
|
358
|
+
const tw = w - CARD_PADDING * 2 - SPACE.sm;
|
|
359
|
+
let ty = cy + CARD_PADDING;
|
|
360
|
+
els.push(text(env.id(`highlight-${i}-label`), tx, ty, tw, lineHeightOf('body'), s.label, {
|
|
361
|
+
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.inkMuted, fontFamily: st.body,
|
|
362
|
+
}));
|
|
363
|
+
ty += lineHeightOf('body') + SPACE.xs;
|
|
364
|
+
els.push(text(env.id(`highlight-${i}-value`), tx, ty, tw, lineHeightOf('headline'), s.value, {
|
|
365
|
+
fontSize: TYPE_SCALE.headline.size, lineHeight: TYPE_SCALE.headline.lineHeight, color: COLOR.primary,
|
|
366
|
+
fontWeight: 'bold', fontFamily: st.display,
|
|
367
|
+
}));
|
|
368
|
+
ty += lineHeightOf('headline');
|
|
369
|
+
if (s.delta) {
|
|
370
|
+
ty += SPACE.sm;
|
|
371
|
+
const tone = s.delta.tone === 'down' ? COLOR.danger : COLOR.success;
|
|
372
|
+
els.push(...pill((sfx) => env.id(`highlight-${i}-delta-${sfx}`), tx, ty, s.delta.text, tone, { family: st.body }).elements);
|
|
373
|
+
}
|
|
374
|
+
cy += h + SPACE.md;
|
|
375
|
+
});
|
|
376
|
+
return els;
|
|
377
|
+
}
|
|
378
|
+
/** The hero's logo box, or null when the brand has none or the caller said logo: false. */
|
|
379
|
+
function heroLogo(c) {
|
|
380
|
+
const aspect = brandLogoAspect();
|
|
381
|
+
if (aspect === null || c.logo === false)
|
|
382
|
+
return null;
|
|
383
|
+
return { width: round(Math.min(220, Math.max(LOGO_HEIGHT, LOGO_HEIGHT * aspect))) };
|
|
384
|
+
}
|
|
256
385
|
/** Height of the hero's text stack, before any screen-filling. */
|
|
257
386
|
function heroContentHeight(env, c, textW, centred) {
|
|
258
387
|
const st = env.style;
|
|
259
|
-
let h = 0;
|
|
388
|
+
let h = heroLogo(c) ? LOGO_HEIGHT + SPACE.xl : 0;
|
|
260
389
|
if (st.heroMark === 'accent-rule')
|
|
261
390
|
h += STROKE.strong + SPACE.lg;
|
|
262
391
|
else if (st.heroMark === 'hairline')
|
|
@@ -285,7 +414,7 @@ export function featureGrid(env, c) {
|
|
|
285
414
|
const lead = st.cards === 'divided' ? SPACE.md : 0;
|
|
286
415
|
// The icon row is kept while ANY card has an icon, so titles still line
|
|
287
416
|
// up across the row; a grid with no icons at all drops the row.
|
|
288
|
-
const iconRow = items.some((it) => it.icon?.trim()) ?
|
|
417
|
+
const iconRow = items.some((it) => it.icon?.trim()) ? ICON_BADGE + SPACE.md : 0;
|
|
289
418
|
const contentHeights = items.map((it) => lead + iconRow
|
|
290
419
|
+ textBlockHeight(it.title, inner, 'title', st.display)
|
|
291
420
|
+ SPACE.sm
|
|
@@ -304,12 +433,12 @@ export function featureGrid(env, c) {
|
|
|
304
433
|
// divided: no panel at all, a hairline doing the separating.
|
|
305
434
|
if (st.cards === 'raised') {
|
|
306
435
|
els.push(rect(env.id(`card-${i}`), cx, cy, cardW, cardH, {
|
|
307
|
-
fill:
|
|
436
|
+
fill: COLOR.surface, cornerRadius: radius().md, shadow: { ...SHADOW.soft },
|
|
308
437
|
}));
|
|
309
438
|
}
|
|
310
439
|
else if (st.cards === 'flat') {
|
|
311
440
|
els.push(rect(env.id(`card-${i}`), cx, cy, cardW, cardH, {
|
|
312
|
-
fill: COLOR.surfaceMuted, cornerRadius:
|
|
441
|
+
fill: COLOR.surfaceMuted, cornerRadius: radius().sm,
|
|
313
442
|
}));
|
|
314
443
|
}
|
|
315
444
|
else {
|
|
@@ -318,7 +447,13 @@ export function featureGrid(env, c) {
|
|
|
318
447
|
const pad = st.cards === 'divided' ? 0 : CARD_PADDING;
|
|
319
448
|
const iconName = it.icon?.trim();
|
|
320
449
|
if (iconName) {
|
|
321
|
-
|
|
450
|
+
// The glyph sits on a soft disc of the brand accent: the card reads
|
|
451
|
+
// as branded at a glance, where a bare line icon reads as decoration.
|
|
452
|
+
const badge = ellipse(env.id(`icon-${i}-badge`), cx + pad, cy + pad + lead, ICON_BADGE, ICON_BADGE, { fill: COLOR.accent });
|
|
453
|
+
badge.opacity = 0.14;
|
|
454
|
+
els.push(badge);
|
|
455
|
+
const g = round((ICON_BADGE - CARD_ICON_GLYPH) / 2);
|
|
456
|
+
els.push(icon(env.id(`icon-${i}`), cx + pad + g, cy + pad + lead + g, CARD_ICON_GLYPH, {
|
|
322
457
|
iconName, color: COLOR.accentStrong,
|
|
323
458
|
}));
|
|
324
459
|
}
|
|
@@ -344,18 +479,23 @@ export function statBand(env, c) {
|
|
|
344
479
|
const st = env.style;
|
|
345
480
|
const bare = st.statBand === 'bare';
|
|
346
481
|
const onDark = st.statBand === 'ink';
|
|
347
|
-
const pad = bare ? SPACE.
|
|
482
|
+
const pad = bare ? SPACE.lg : SPACE.xxl;
|
|
348
483
|
const n = c.stats.length;
|
|
349
484
|
const perRow = env.narrow ? Math.min(n, 2) : n;
|
|
350
485
|
const rows = Math.ceil(n / perRow);
|
|
351
|
-
const
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
486
|
+
const inset = bare ? 0 : CARD_PADDING * 2;
|
|
487
|
+
const cellW = round((env.width - inset * 2) / perRow);
|
|
488
|
+
const align = bare ? 'left' : 'center';
|
|
489
|
+
// The figure is the point of the band, so it gets display type; the
|
|
490
|
+
// label sits above it as a quiet heading and the change below it as a
|
|
491
|
+
// pill. Caption-size figures read as a table footnote at board scale.
|
|
492
|
+
const narrowValue = env.narrow || perRow > 3;
|
|
493
|
+
const valueRole = narrowValue ? 'headline' : 'display';
|
|
494
|
+
const valueH = lineHeightOf(valueRole);
|
|
495
|
+
const labelH = lineHeightOf('body');
|
|
496
|
+
const deltaH = c.stats.some((s) => s.delta) ? SPACE.md + PILL_H : 0;
|
|
497
|
+
const rowH = labelH + SPACE.sm + valueH + deltaH;
|
|
498
|
+
const height = pad * 2 + rows * rowH + (rows - 1) * SPACE.xl;
|
|
359
499
|
// A dark or accent band reaching both edges of the window is the single
|
|
360
500
|
// clearest "this is a page" signal available here. Bare figures stay in
|
|
361
501
|
// the column: a rule that runs off the screen is just a stray line.
|
|
@@ -365,37 +505,31 @@ export function statBand(env, c) {
|
|
|
365
505
|
const els = bare
|
|
366
506
|
? [hrule(env.id('rule'), env.x, env.y, env.width, { stroke: COLOR.border, strokeWidth: STROKE.hairline })]
|
|
367
507
|
: [rect(env.id('panel'), panelX, env.y, panelW, height, {
|
|
368
|
-
fill: onDark ?
|
|
508
|
+
fill: onDark ? COLOR.primary : COLOR.accent, cornerRadius: bleeds ? 0 : radius().lg,
|
|
369
509
|
})];
|
|
370
|
-
const valueColor = onDark ? COLOR.
|
|
371
|
-
const labelColor = onDark ? COLOR.
|
|
372
|
-
const labelOpacity = onDark ? 0.65 : bare ? 1 : 0.7;
|
|
510
|
+
const valueColor = onDark ? COLOR.onPrimary : bare ? COLOR.primary : COLOR.onAccent;
|
|
511
|
+
const labelColor = onDark ? COLOR.onPrimary : bare ? COLOR.inkMuted : COLOR.onAccent;
|
|
373
512
|
c.stats.forEach((s, i) => {
|
|
374
|
-
const cx = env.x +
|
|
375
|
-
let cy = env.y + pad + Math.floor(i / perRow) * (rowH + SPACE.
|
|
513
|
+
const cx = env.x + inset + (i % perRow) * cellW;
|
|
514
|
+
let cy = env.y + pad + Math.floor(i / perRow) * (rowH + SPACE.xl);
|
|
515
|
+
els.push(text(env.id(`label-${i}`), cx, cy, cellW, labelH, s.label, {
|
|
516
|
+
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight,
|
|
517
|
+
color: labelColor, align, opacity: bare ? 1 : 0.75, fontFamily: st.body,
|
|
518
|
+
}));
|
|
519
|
+
cy += labelH + SPACE.sm;
|
|
376
520
|
els.push(text(env.id(`value-${i}`), cx, cy, cellW, valueH, s.value, {
|
|
377
|
-
fontSize: TYPE_SCALE.
|
|
378
|
-
color: valueColor, fontWeight: 'bold', align
|
|
379
|
-
fontFamily: st.display,
|
|
521
|
+
fontSize: TYPE_SCALE[valueRole].size, lineHeight: TYPE_SCALE[valueRole].lineHeight,
|
|
522
|
+
color: valueColor, fontWeight: 'bold', align, fontFamily: st.display,
|
|
380
523
|
}));
|
|
381
524
|
cy += valueH;
|
|
382
525
|
if (s.delta) {
|
|
383
|
-
cy += SPACE.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
}));
|
|
390
|
-
cy += lineHeightOf('caption');
|
|
526
|
+
cy += SPACE.md;
|
|
527
|
+
const tone = s.delta.tone === 'down' ? COLOR.danger : COLOR.success;
|
|
528
|
+
const color = bare || onDark ? tone : COLOR.onAccent;
|
|
529
|
+
const w = pillWidth(s.delta.text);
|
|
530
|
+
const px = align === 'center' ? cx + round((cellW - w) / 2) : cx;
|
|
531
|
+
els.push(...pill((sfx) => env.id(`delta-${i}-${sfx}`), px, cy, s.delta.text, color, { tint: onDark ? 0.2 : 0.14, family: st.body }).elements);
|
|
391
532
|
}
|
|
392
|
-
cy += SPACE.sm;
|
|
393
|
-
// Off-white at reduced opacity, because inkMuted is unreadable on ink.
|
|
394
|
-
els.push(text(env.id(`label-${i}`), cx, cy, cellW, labelH, s.label, {
|
|
395
|
-
fontSize: TYPE_SCALE.caption.size, lineHeight: TYPE_SCALE.caption.lineHeight,
|
|
396
|
-
color: bare ? COLOR.inkMuted : labelColor, align: bare ? 'left' : 'center',
|
|
397
|
-
opacity: labelOpacity, fontFamily: st.body,
|
|
398
|
-
}));
|
|
399
533
|
});
|
|
400
534
|
return { elements: els, height, bleeds };
|
|
401
535
|
}
|
|
@@ -462,7 +596,7 @@ export function steps(env, c) {
|
|
|
462
596
|
fill: COLOR.accent,
|
|
463
597
|
text: String(i + 1),
|
|
464
598
|
fontSize: TYPE_SCALE.title.size,
|
|
465
|
-
fontColor: COLOR.
|
|
599
|
+
fontColor: COLOR.onAccent,
|
|
466
600
|
fontWeight: 'bold',
|
|
467
601
|
}));
|
|
468
602
|
let ty = top + dot + SPACE.md;
|
|
@@ -501,7 +635,7 @@ function stepsStacked(env, c) {
|
|
|
501
635
|
fill: COLOR.accent,
|
|
502
636
|
text: String(i + 1),
|
|
503
637
|
fontSize: TYPE_SCALE.body.size,
|
|
504
|
-
fontColor: COLOR.
|
|
638
|
+
fontColor: COLOR.onAccent,
|
|
505
639
|
fontWeight: 'bold',
|
|
506
640
|
}));
|
|
507
641
|
let ty = y + round((dot - lineHeightOf('title')) / 2);
|
|
@@ -527,13 +661,17 @@ export function quote(env, c) {
|
|
|
527
661
|
const pad = SPACE.xl;
|
|
528
662
|
const inner = Math.min(env.width - pad * 2, 760);
|
|
529
663
|
const innerX = env.x + round((env.width - inner) / 2);
|
|
530
|
-
|
|
664
|
+
// A quote reads as a voice apart: the other generic family, or on a
|
|
665
|
+
// branded board the brand's display face.
|
|
666
|
+
const quoteFamily = env.style.display.startsWith('$')
|
|
667
|
+
? '$display'
|
|
668
|
+
: env.style.display === 'serif' ? 'sans' : 'serif';
|
|
531
669
|
const quoteH = textBlockHeight(c.quote, inner, 'headline', quoteFamily);
|
|
532
670
|
const attrH = c.attribution ? lineHeightOf('caption') + SPACE.md : 0;
|
|
533
671
|
const height = pad * 2 + quoteH + attrH;
|
|
534
672
|
const els = [
|
|
535
673
|
rect(env.id('panel'), env.x, env.y, env.width, height, {
|
|
536
|
-
fill:
|
|
674
|
+
fill: COLOR.surfaceMuted, cornerRadius: radius().lg,
|
|
537
675
|
}),
|
|
538
676
|
block(env.id('quote'), innerX, env.y + pad, inner, c.quote, 'headline', {
|
|
539
677
|
color: COLOR.ink, align: 'center', family: quoteFamily,
|
|
@@ -554,7 +692,7 @@ export function chartPanel(env, c) {
|
|
|
554
692
|
const height = CARD_PADDING * 2 + titleH + SPACE.md + chartH + capH;
|
|
555
693
|
const els = [
|
|
556
694
|
rect(env.id('panel'), env.x, env.y, env.width, height, {
|
|
557
|
-
fill:
|
|
695
|
+
fill: COLOR.surface, cornerRadius: radius().md, shadow: { ...SHADOW.soft },
|
|
558
696
|
}),
|
|
559
697
|
];
|
|
560
698
|
let y = env.y + CARD_PADDING;
|
|
@@ -585,15 +723,15 @@ export function ctaBand(env, c) {
|
|
|
585
723
|
const bleeds = env.style.bleedBands;
|
|
586
724
|
const els = [
|
|
587
725
|
rect(env.id('panel'), bleeds ? env.bleedX : env.x, env.y, bleeds ? env.bleedWidth : env.width, height, {
|
|
588
|
-
fill:
|
|
726
|
+
fill: COLOR.accent, cornerRadius: bleeds ? 0 : radius().lg,
|
|
589
727
|
}),
|
|
590
728
|
];
|
|
591
729
|
let y = env.y + pad + round(Math.max(0, btnH - stack) / 2);
|
|
592
|
-
els.push(block(env.id('headline'), env.x + pad, y, textW, c.headline, 'headline', { color: COLOR.
|
|
730
|
+
els.push(block(env.id('headline'), env.x + pad, y, textW, c.headline, 'headline', { color: COLOR.onAccent, family: env.style.display }).el);
|
|
593
731
|
y += headH;
|
|
594
732
|
if (c.note) {
|
|
595
733
|
y += SPACE.sm;
|
|
596
|
-
els.push(block(env.id('note'), env.x + pad, y, textW, c.note, 'caption', { color: COLOR.
|
|
734
|
+
els.push(block(env.id('note'), env.x + pad, y, textW, c.note, 'caption', { color: COLOR.onAccent, opacity: 0.7 }).el);
|
|
597
735
|
}
|
|
598
736
|
const btnX = env.x + env.width - pad - btnW;
|
|
599
737
|
const btnY = env.y + round((height - btnH) / 2);
|
|
@@ -601,10 +739,10 @@ export function ctaBand(env, c) {
|
|
|
601
739
|
// clickable rather than just the few pixels of text in the middle.
|
|
602
740
|
const href = safeLinkHref(c.href) ?? undefined;
|
|
603
741
|
els.push(rect(env.id('button'), btnX, btnY, btnW, btnH, {
|
|
604
|
-
fill: COLOR.
|
|
742
|
+
fill: COLOR.primary, cornerRadius: radius().pill, ...(href ? { link: href } : {}),
|
|
605
743
|
}));
|
|
606
744
|
els.push(text(env.id('button-label'), btnX, btnY + round((btnH - lineHeightOf('body')) / 2), btnW, lineHeightOf('body'), c.buttonLabel, {
|
|
607
|
-
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.
|
|
745
|
+
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.onPrimary, fontWeight: 'bold', align: 'center',
|
|
608
746
|
...(href ? { link: href } : {}),
|
|
609
747
|
}));
|
|
610
748
|
return { elements: els, height, bleeds };
|
|
@@ -763,14 +901,208 @@ export function imageBand(env, c) {
|
|
|
763
901
|
}
|
|
764
902
|
return { elements: els, height };
|
|
765
903
|
}
|
|
904
|
+
const STATUS_DEFAULT = { done: 'Erledigt', running: 'Läuft', planned: 'Geplant' };
|
|
905
|
+
// Running in the brand's main colour, not its accent: an accent red would
|
|
906
|
+
// read as a problem.
|
|
907
|
+
const STATUS_COLOR = { done: COLOR.success, running: COLOR.primary, planned: COLOR.inkMuted };
|
|
908
|
+
/**
|
|
909
|
+
* "What we did": one row per measure, with its status and its effect. The
|
|
910
|
+
* part of a report a client reads most closely, which a grid of identical
|
|
911
|
+
* cards hides: here the status and the result are the first thing seen.
|
|
912
|
+
*/
|
|
913
|
+
export function statusList(env, c) {
|
|
914
|
+
const st = env.style;
|
|
915
|
+
const labels = { ...STATUS_DEFAULT, ...(c.labels ?? {}) };
|
|
916
|
+
const heading = headingBlock(env, c.title, c.intro, env.y);
|
|
917
|
+
const els = [...heading.elements];
|
|
918
|
+
const pad = st.cards === 'divided' ? SPACE.md : CARD_PADDING;
|
|
919
|
+
const statusW = Math.max(...Object.keys(labels).map((k) => pillWidth(labels[k])));
|
|
920
|
+
const effectW = env.narrow ? 0 : Math.min(260, round(env.width * 0.24));
|
|
921
|
+
const textX = pad + statusW + SPACE.lg;
|
|
922
|
+
const textW = env.width - textX - pad - (effectW ? effectW + SPACE.lg : 0);
|
|
923
|
+
const bodyW = Math.min(textW, MEASURE);
|
|
924
|
+
let y = env.y + heading.height;
|
|
925
|
+
c.items.forEach((it, i) => {
|
|
926
|
+
const titleH = textBlockHeight(it.title, textW, 'title', st.display);
|
|
927
|
+
const bodyH = it.body ? SPACE.xs + textBlockHeight(it.body, bodyW, 'body', st.body) : 0;
|
|
928
|
+
const effectBelow = env.narrow && it.effect ? SPACE.sm + lineHeightOf('title') : 0;
|
|
929
|
+
const rowH = pad * 2 + Math.max(PILL_H, titleH + bodyH + effectBelow, effectW && it.effect ? lineHeightOf('title') : 0);
|
|
930
|
+
if (st.cards === 'divided') {
|
|
931
|
+
els.push(hrule(env.id(`rule-${i}`), env.x, y, env.width, { stroke: COLOR.border, strokeWidth: STROKE.hairline }));
|
|
932
|
+
}
|
|
933
|
+
else {
|
|
934
|
+
els.push(rect(env.id(`row-${i}`), env.x, y, env.width, rowH, {
|
|
935
|
+
fill: st.cards === 'raised' ? COLOR.surface : COLOR.surfaceMuted, cornerRadius: radius().md,
|
|
936
|
+
...(st.cards === 'raised' ? { shadow: { ...SHADOW.soft } } : {}),
|
|
937
|
+
}));
|
|
938
|
+
}
|
|
939
|
+
els.push(...pill((sfx) => env.id(`status-${i}-${sfx}`), env.x + pad, y + pad, labels[it.status], STATUS_COLOR[it.status], { family: st.body }).elements);
|
|
940
|
+
let ty = y + pad;
|
|
941
|
+
const t = block(env.id(`title-${i}`), env.x + textX, ty, textW, it.title, 'title', { color: COLOR.ink, family: st.display });
|
|
942
|
+
els.push(t.el);
|
|
943
|
+
ty += t.height;
|
|
944
|
+
if (it.body) {
|
|
945
|
+
ty += SPACE.xs;
|
|
946
|
+
const b = block(env.id(`body-${i}`), env.x + textX, ty, bodyW, it.body, 'body', { color: COLOR.inkMuted, family: st.body });
|
|
947
|
+
els.push(b.el);
|
|
948
|
+
ty += b.height;
|
|
949
|
+
}
|
|
950
|
+
if (it.effect) {
|
|
951
|
+
if (effectW) {
|
|
952
|
+
els.push(text(env.id(`effect-${i}`), env.x + env.width - pad - effectW, y + pad, effectW, lineHeightOf('title'), it.effect, {
|
|
953
|
+
fontSize: TYPE_SCALE.title.size, lineHeight: TYPE_SCALE.title.lineHeight, color: COLOR.primary,
|
|
954
|
+
fontWeight: 'bold', align: 'right', fontFamily: st.display,
|
|
955
|
+
}));
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
ty += SPACE.sm;
|
|
959
|
+
els.push(text(env.id(`effect-${i}`), env.x + textX, ty, textW, lineHeightOf('title'), it.effect, {
|
|
960
|
+
fontSize: TYPE_SCALE.title.size, lineHeight: TYPE_SCALE.title.lineHeight, color: COLOR.primary,
|
|
961
|
+
fontWeight: 'bold', fontFamily: st.display,
|
|
962
|
+
}));
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
y += rowH + (st.cards === 'divided' ? 0 : SPACE.md);
|
|
966
|
+
});
|
|
967
|
+
const last = st.cards === 'divided' ? 0 : SPACE.md;
|
|
968
|
+
return { elements: els, height: y - env.y - (c.items.length ? last : 0) };
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* A figure then and now, side by side, with the difference as a pill. The
|
|
972
|
+
* honest way to show an effect: the reader sees both numbers, not only the
|
|
973
|
+
* percentage someone computed from them.
|
|
974
|
+
*/
|
|
975
|
+
export function beforeAfter(env, c) {
|
|
976
|
+
const st = env.style;
|
|
977
|
+
const words = { before: 'Vorher', after: 'Nachher', ...(c.labels ?? {}) };
|
|
978
|
+
const heading = headingBlock(env, c.title, c.intro, env.y);
|
|
979
|
+
const els = [...heading.elements];
|
|
980
|
+
const items = c.items.slice(0, 3);
|
|
981
|
+
const cols = env.narrow ? 1 : items.length;
|
|
982
|
+
const cardW = round((env.width - GUTTER * (cols - 1)) / cols);
|
|
983
|
+
const pad = CARD_PADDING;
|
|
984
|
+
const inner = cardW - pad * 2;
|
|
985
|
+
const arrow = 24;
|
|
986
|
+
const halfW = round((inner - arrow - SPACE.md * 2) / 2);
|
|
987
|
+
const cardH = (it) => pad * 2 + textBlockHeight(it.label, inner, 'title', st.display) + SPACE.lg
|
|
988
|
+
+ lineHeightOf('body') + SPACE.xs + lineHeightOf('headline')
|
|
989
|
+
+ (it.delta ? SPACE.md + PILL_H : 0);
|
|
990
|
+
const h = Math.max(...items.map(cardH));
|
|
991
|
+
const top = env.y + heading.height;
|
|
992
|
+
items.forEach((it, i) => {
|
|
993
|
+
const cx = env.x + (i % cols) * (cardW + GUTTER);
|
|
994
|
+
const cy = top + Math.floor(i / cols) * (h + GUTTER);
|
|
995
|
+
els.push(rect(env.id(`card-${i}`), cx, cy, cardW, h, {
|
|
996
|
+
fill: st.cards === 'raised' ? COLOR.surface : COLOR.surfaceMuted, cornerRadius: radius().md,
|
|
997
|
+
...(st.cards === 'raised' ? { shadow: { ...SHADOW.soft } } : {}),
|
|
998
|
+
}));
|
|
999
|
+
let y = cy + pad;
|
|
1000
|
+
const l = block(env.id(`label-${i}`), cx + pad, y, inner, it.label, 'title', { color: COLOR.ink, family: st.display });
|
|
1001
|
+
els.push(l.el);
|
|
1002
|
+
y += l.height + SPACE.lg;
|
|
1003
|
+
const bx = cx + pad;
|
|
1004
|
+
const ax = bx + halfW + SPACE.md + arrow + SPACE.md;
|
|
1005
|
+
for (const [key, x, word, value, color] of [
|
|
1006
|
+
['before', bx, words.before, it.before, COLOR.inkMuted],
|
|
1007
|
+
['after', ax, words.after, it.after, COLOR.primary],
|
|
1008
|
+
]) {
|
|
1009
|
+
els.push(text(env.id(`${key}-word-${i}`), x, y, halfW, lineHeightOf('body'), word, {
|
|
1010
|
+
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.inkMuted, fontFamily: st.body,
|
|
1011
|
+
}));
|
|
1012
|
+
els.push(text(env.id(`${key}-value-${i}`), x, y + lineHeightOf('body') + SPACE.xs, halfW, lineHeightOf('headline'), value, {
|
|
1013
|
+
fontSize: TYPE_SCALE.headline.size, lineHeight: TYPE_SCALE.headline.lineHeight, color,
|
|
1014
|
+
fontWeight: 'bold', fontFamily: st.display,
|
|
1015
|
+
}));
|
|
1016
|
+
}
|
|
1017
|
+
const ay = y + lineHeightOf('body') + SPACE.xs + round((lineHeightOf('headline') - arrow) / 2);
|
|
1018
|
+
els.push(icon(env.id(`arrow-${i}`), bx + halfW + SPACE.md, ay, arrow, { iconName: 'ArrowRight', color: COLOR.accentStrong }));
|
|
1019
|
+
y += lineHeightOf('body') + SPACE.xs + lineHeightOf('headline');
|
|
1020
|
+
if (it.delta) {
|
|
1021
|
+
y += SPACE.md;
|
|
1022
|
+
const tone = it.delta.tone === 'down' ? COLOR.danger : COLOR.success;
|
|
1023
|
+
els.push(...pill((sfx) => env.id(`delta-${i}-${sfx}`), ax, y, it.delta.text, tone, { family: st.body }).elements);
|
|
1024
|
+
}
|
|
1025
|
+
});
|
|
1026
|
+
const rows = Math.ceil(items.length / cols);
|
|
1027
|
+
return { elements: els, height: heading.height + rows * h + (rows - 1) * GUTTER };
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Stages as bars whose length is their share of the first, with the
|
|
1031
|
+
* conversion between neighbours written in the gap. Where a journey loses
|
|
1032
|
+
* people is the point, and a table of numbers buries it.
|
|
1033
|
+
*/
|
|
1034
|
+
export function funnel(env, c) {
|
|
1035
|
+
const st = env.style;
|
|
1036
|
+
const heading = headingBlock(env, c.title, c.intro, env.y);
|
|
1037
|
+
const els = [...heading.elements];
|
|
1038
|
+
const stages = c.stages.filter((s) => Number.isFinite(s.value) && s.value >= 0);
|
|
1039
|
+
if (!stages.length)
|
|
1040
|
+
return { elements: els, height: heading.height };
|
|
1041
|
+
const max = Math.max(...stages.map((s) => s.value), 1);
|
|
1042
|
+
const min = Math.max(1, Math.min(...stages.map((s) => s.value)));
|
|
1043
|
+
// A marketing funnel loses 95 % at the first step, so in proportion every
|
|
1044
|
+
// later bar is the same sliver and the shape is gone. Past a 10x spread
|
|
1045
|
+
// the bars follow the order of magnitude instead; the real rate between
|
|
1046
|
+
// two stages is written in the gap either way.
|
|
1047
|
+
const logScale = max / min > 10;
|
|
1048
|
+
const share = (v) => logScale
|
|
1049
|
+
? 0.2 + 0.8 * (Math.log(Math.max(1, v)) / Math.log(Math.max(2, max)))
|
|
1050
|
+
: Math.max(0.12, v / max);
|
|
1051
|
+
const labelW = env.narrow ? env.width : Math.min(240, round(env.width * 0.22));
|
|
1052
|
+
const barX = env.narrow ? env.x : env.x + labelW + SPACE.lg;
|
|
1053
|
+
const barW = env.narrow ? env.width : env.width - labelW - SPACE.lg;
|
|
1054
|
+
const barH = 52;
|
|
1055
|
+
const gap = SPACE.xl;
|
|
1056
|
+
const fmt = new Intl.NumberFormat('de-DE');
|
|
1057
|
+
const conv = c.conversionLabel ?? 'weiter';
|
|
1058
|
+
let y = env.y + heading.height;
|
|
1059
|
+
stages.forEach((s, i) => {
|
|
1060
|
+
if (env.narrow) {
|
|
1061
|
+
els.push(text(env.id(`label-${i}`), env.x, y, env.width, lineHeightOf('body'), s.label, {
|
|
1062
|
+
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.ink, fontWeight: 'bold', fontFamily: st.body,
|
|
1063
|
+
}));
|
|
1064
|
+
y += lineHeightOf('body') + SPACE.xs;
|
|
1065
|
+
}
|
|
1066
|
+
else {
|
|
1067
|
+
els.push(text(env.id(`label-${i}`), env.x, y + round((barH - lineHeightOf('title')) / 2), labelW, lineHeightOf('title'), s.label, {
|
|
1068
|
+
fontSize: TYPE_SCALE.title.size, lineHeight: TYPE_SCALE.title.lineHeight, color: COLOR.ink, fontWeight: 'bold', fontFamily: st.display,
|
|
1069
|
+
}));
|
|
1070
|
+
}
|
|
1071
|
+
const w = round(share(s.value) * barW);
|
|
1072
|
+
const bar = rect(env.id(`bar-${i}`), barX, y, w, barH, { fill: COLOR.primary, cornerRadius: radius().sm });
|
|
1073
|
+
// Later stages fade, so the drop reads before any number is read.
|
|
1074
|
+
bar.opacity = round(1 - (stages.length > 1 ? (i / (stages.length - 1)) * 0.45 : 0));
|
|
1075
|
+
els.push(bar);
|
|
1076
|
+
const shown = s.display ?? fmt.format(s.value);
|
|
1077
|
+
const shownW = textWidth(shown, TYPE_SCALE.title.size, 'bold', st.display) + SPACE.md * 2;
|
|
1078
|
+
const inside = shownW <= w;
|
|
1079
|
+
els.push(text(env.id(`value-${i}`), inside ? barX + SPACE.md : barX + w + SPACE.md, y + round((barH - lineHeightOf('title')) / 2), Math.max(shownW, 120), lineHeightOf('title'), shown, {
|
|
1080
|
+
fontSize: TYPE_SCALE.title.size, lineHeight: TYPE_SCALE.title.lineHeight,
|
|
1081
|
+
color: inside ? COLOR.onPrimary : COLOR.ink, fontWeight: 'bold', fontFamily: st.display,
|
|
1082
|
+
}));
|
|
1083
|
+
y += barH;
|
|
1084
|
+
const next = stages[i + 1];
|
|
1085
|
+
if (next) {
|
|
1086
|
+
const rate = s.value > 0 ? (next.value / s.value) * 100 : 0;
|
|
1087
|
+
const label = `${new Intl.NumberFormat('de-DE', { maximumFractionDigits: 1 }).format(rate)} % ${conv}`;
|
|
1088
|
+
els.push(text(env.id(`conversion-${i}`), barX, y + round((gap - lineHeightOf('body')) / 2), Math.min(barW, MEASURE), lineHeightOf('body'), `↓ ${label}`, {
|
|
1089
|
+
fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.inkMuted, fontFamily: st.body,
|
|
1090
|
+
}));
|
|
1091
|
+
y += gap;
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
return { elements: els, height: y - env.y };
|
|
1095
|
+
}
|
|
766
1096
|
export const SECTION_TYPES = [
|
|
767
1097
|
'hero', 'featureGrid', 'statBand', 'split', 'steps', 'quote',
|
|
768
1098
|
'chartPanel', 'ctaBand', 'comparisonTable', 'timeline', 'logoRow', 'footerMeta', 'imageBand',
|
|
1099
|
+
'statusList', 'beforeAfter', 'funnel',
|
|
769
1100
|
];
|
|
770
1101
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
771
1102
|
const RENDERERS = {
|
|
772
1103
|
hero, featureGrid, statBand, split, steps, quote,
|
|
773
1104
|
chartPanel, ctaBand, comparisonTable, timeline, logoRow, footerMeta, imageBand,
|
|
1105
|
+
statusList, beforeAfter, funnel,
|
|
774
1106
|
};
|
|
775
1107
|
/**
|
|
776
1108
|
* A screen-shaped page for slide layout. 16:9 against the default column,
|
|
@@ -788,7 +1120,8 @@ export const SLIDE_HEIGHT = Math.round(DEFAULT_COLUMN * 9 / 16);
|
|
|
788
1120
|
export function composeBoard(specs, opts = {}) {
|
|
789
1121
|
const width = opts.columnWidth ?? DEFAULT_COLUMN;
|
|
790
1122
|
const margin = opts.margin ?? CANVAS_MARGIN;
|
|
791
|
-
const
|
|
1123
|
+
const base = resolveStyle(opts.style ?? DEFAULT_STYLE);
|
|
1124
|
+
const style = { ...base, ...brandFonts(base) };
|
|
792
1125
|
const gap = gapFor(style);
|
|
793
1126
|
const layout = opts.layout ?? 'page';
|
|
794
1127
|
const elements = [];
|