@dversum/mcp-server 2.11.1 → 2.12.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.
Files changed (58) hide show
  1. package/README.md +5 -0
  2. package/dist/src/client.d.ts +10 -0
  3. package/dist/src/client.d.ts.map +1 -1
  4. package/dist/src/client.js +21 -4
  5. package/dist/src/client.js.map +1 -1
  6. package/dist/src/index.d.ts.map +1 -1
  7. package/dist/src/index.js +6 -0
  8. package/dist/src/index.js.map +1 -1
  9. package/dist/src/tools/creatives.d.ts +4 -0
  10. package/dist/src/tools/creatives.d.ts.map +1 -0
  11. package/dist/src/tools/creatives.js +78 -0
  12. package/dist/src/tools/creatives.js.map +1 -0
  13. package/dist/src/tools/request-bodies.spec.js +16 -0
  14. package/dist/src/tools/request-bodies.spec.js.map +1 -1
  15. package/dist/src/tools/subtasks.d.ts +14 -0
  16. package/dist/src/tools/subtasks.d.ts.map +1 -0
  17. package/dist/src/tools/subtasks.js +51 -0
  18. package/dist/src/tools/subtasks.js.map +1 -0
  19. package/dist/src/tools/subtasks.spec.d.ts +2 -0
  20. package/dist/src/tools/subtasks.spec.d.ts.map +1 -0
  21. package/dist/src/tools/subtasks.spec.js +90 -0
  22. package/dist/src/tools/subtasks.spec.js.map +1 -0
  23. package/dist/src/tools/universum.d.ts +42 -0
  24. package/dist/src/tools/universum.d.ts.map +1 -1
  25. package/dist/src/tools/universum.js +76 -2
  26. package/dist/src/tools/universum.js.map +1 -1
  27. package/dist/src/tools/whiteboard-brand.d.ts +4 -0
  28. package/dist/src/tools/whiteboard-brand.d.ts.map +1 -0
  29. package/dist/src/tools/whiteboard-brand.js +158 -0
  30. package/dist/src/tools/whiteboard-brand.js.map +1 -0
  31. package/dist/src/tools/whiteboard-compose.d.ts +39 -0
  32. package/dist/src/tools/whiteboard-compose.d.ts.map +1 -1
  33. package/dist/src/tools/whiteboard-compose.js +45 -21
  34. package/dist/src/tools/whiteboard-compose.js.map +1 -1
  35. package/dist/src/tools/whiteboards.d.ts.map +1 -1
  36. package/dist/src/tools/whiteboards.js +34 -10
  37. package/dist/src/tools/whiteboards.js.map +1 -1
  38. package/dist/src/whiteboard/brand.d.ts +58 -0
  39. package/dist/src/whiteboard/brand.d.ts.map +1 -0
  40. package/dist/src/whiteboard/brand.js +111 -0
  41. package/dist/src/whiteboard/brand.js.map +1 -0
  42. package/dist/src/whiteboard/elements.d.ts +1 -1
  43. package/dist/src/whiteboard/elements.d.ts.map +1 -1
  44. package/dist/src/whiteboard/elements.js.map +1 -1
  45. package/dist/src/whiteboard/measure.d.ts.map +1 -1
  46. package/dist/src/whiteboard/measure.js +4 -7
  47. package/dist/src/whiteboard/measure.js.map +1 -1
  48. package/dist/src/whiteboard/sections.d.ts +85 -2
  49. package/dist/src/whiteboard/sections.d.ts.map +1 -1
  50. package/dist/src/whiteboard/sections.js +401 -62
  51. package/dist/src/whiteboard/sections.js.map +1 -1
  52. package/dist/src/whiteboard/sections.spec.js +131 -3
  53. package/dist/src/whiteboard/sections.spec.js.map +1 -1
  54. package/dist/src/whiteboard/theme.d.ts +159 -0
  55. package/dist/src/whiteboard/theme.d.ts.map +1 -0
  56. package/dist/src/whiteboard/theme.js +441 -0
  57. package/dist/src/whiteboard/theme.js.map +1 -0
  58. 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, RADIUS, STROKE, COLOR, SHADOW, SURFACE, CARD_PADDING, } from './tokens.js';
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: RADIUS.md }),
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: RADIUS.md });
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 sideBySide = hasVisual && !env.narrow;
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 the hero claims a screen and its content sits in the
189
- // middle of it. Measure first at a throwaway origin, then place.
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 minHeight = env.layout === 'page' ? (env.narrow ? 420 : HERO_HEIGHT) : 0;
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 height = Math.max(measured, minHeight);
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.ink, cornerRadius: RADIUS.pill, ...(href ? { link: href } : {}),
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.surface, fontWeight: 'bold', align: 'center', fontFamily: st.body,
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')
@@ -283,7 +412,10 @@ export function featureGrid(env, c) {
283
412
  const pad = st.cards === 'divided' ? 0 : CARD_PADDING;
284
413
  const inner = cardW - pad * 2;
285
414
  const lead = st.cards === 'divided' ? SPACE.md : 0;
286
- const contentHeights = items.map((it) => lead + CARD_ICON + SPACE.md
415
+ // The icon row is kept while ANY card has an icon, so titles still line
416
+ // up across the row; a grid with no icons at all drops the row.
417
+ const iconRow = items.some((it) => it.icon?.trim()) ? ICON_BADGE + SPACE.md : 0;
418
+ const contentHeights = items.map((it) => lead + iconRow
287
419
  + textBlockHeight(it.title, inner, 'title', st.display)
288
420
  + SPACE.sm
289
421
  + textBlockHeight(it.body, inner, 'body', st.body));
@@ -301,22 +433,31 @@ export function featureGrid(env, c) {
301
433
  // divided: no panel at all, a hairline doing the separating.
302
434
  if (st.cards === 'raised') {
303
435
  els.push(rect(env.id(`card-${i}`), cx, cy, cardW, cardH, {
304
- fill: SURFACE.card.fill, cornerRadius: SURFACE.card.cornerRadius, shadow: { ...SHADOW.soft },
436
+ fill: COLOR.surface, cornerRadius: radius().md, shadow: { ...SHADOW.soft },
305
437
  }));
306
438
  }
307
439
  else if (st.cards === 'flat') {
308
440
  els.push(rect(env.id(`card-${i}`), cx, cy, cardW, cardH, {
309
- fill: COLOR.surfaceMuted, cornerRadius: RADIUS.sm,
441
+ fill: COLOR.surfaceMuted, cornerRadius: radius().sm,
310
442
  }));
311
443
  }
312
444
  else {
313
445
  els.push(hrule(env.id(`rule-${i}`), cx, cy, cardW, { stroke: COLOR.border, strokeWidth: STROKE.hairline }));
314
446
  }
315
447
  const pad = st.cards === 'divided' ? 0 : CARD_PADDING;
316
- els.push(icon(env.id(`icon-${i}`), cx + pad, cy + pad + (st.cards === 'divided' ? SPACE.md : 0), CARD_ICON, {
317
- iconName: it.icon, color: COLOR.accentStrong,
318
- }));
319
- let ty = cy + pad + (st.cards === 'divided' ? SPACE.md : 0) + CARD_ICON + SPACE.md;
448
+ const iconName = it.icon?.trim();
449
+ if (iconName) {
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, {
457
+ iconName, color: COLOR.accentStrong,
458
+ }));
459
+ }
460
+ let ty = cy + pad + lead + iconRow;
320
461
  const title = block(env.id(`title-${i}`), cx + pad, ty, inner, it.title, 'title', {
321
462
  color: COLOR.ink, family: st.display,
322
463
  });
@@ -338,18 +479,23 @@ export function statBand(env, c) {
338
479
  const st = env.style;
339
480
  const bare = st.statBand === 'bare';
340
481
  const onDark = st.statBand === 'ink';
341
- const pad = bare ? SPACE.md : SPACE.xl;
482
+ const pad = bare ? SPACE.lg : SPACE.xxl;
342
483
  const n = c.stats.length;
343
484
  const perRow = env.narrow ? Math.min(n, 2) : n;
344
485
  const rows = Math.ceil(n / perRow);
345
- const cellW = round((env.width - (bare ? 0 : CARD_PADDING * 2)) / perRow);
346
- const valueH = lineHeightOf('headline');
347
- const deltaH = c.stats.some((s) => s.delta) ? lineHeightOf('caption') + SPACE.xs : 0;
348
- const labelH = lineHeightOf('caption');
349
- const rowH = valueH + deltaH + SPACE.sm + labelH;
350
- const height = pad * 2 + rows * rowH + (rows - 1) * SPACE.lg;
351
- // A number does not need a panel to be loud. Two styles give it one
352
- // anyway, in opposite colours; one lets it sit on the page under a rule.
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;
353
499
  // A dark or accent band reaching both edges of the window is the single
354
500
  // clearest "this is a page" signal available here. Bare figures stay in
355
501
  // the column: a rule that runs off the screen is just a stray line.
@@ -359,37 +505,31 @@ export function statBand(env, c) {
359
505
  const els = bare
360
506
  ? [hrule(env.id('rule'), env.x, env.y, env.width, { stroke: COLOR.border, strokeWidth: STROKE.hairline })]
361
507
  : [rect(env.id('panel'), panelX, env.y, panelW, height, {
362
- fill: onDark ? SURFACE.ink.fill : COLOR.accent, cornerRadius: bleeds ? 0 : RADIUS.lg,
508
+ fill: onDark ? COLOR.primary : COLOR.accent, cornerRadius: bleeds ? 0 : radius().lg,
363
509
  })];
364
- const valueColor = onDark ? COLOR.surface : COLOR.ink;
365
- const labelColor = onDark ? COLOR.surfaceMuted : COLOR.ink;
366
- 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;
367
512
  c.stats.forEach((s, i) => {
368
- const cx = env.x + (bare ? 0 : CARD_PADDING) + (i % perRow) * cellW;
369
- let cy = env.y + pad + Math.floor(i / perRow) * (rowH + SPACE.lg);
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;
370
520
  els.push(text(env.id(`value-${i}`), cx, cy, cellW, valueH, s.value, {
371
- fontSize: TYPE_SCALE.headline.size, lineHeight: TYPE_SCALE.headline.lineHeight,
372
- color: valueColor, fontWeight: 'bold', align: bare ? 'left' : 'center',
373
- fontFamily: st.display,
521
+ fontSize: TYPE_SCALE[valueRole].size, lineHeight: TYPE_SCALE[valueRole].lineHeight,
522
+ color: valueColor, fontWeight: 'bold', align, fontFamily: st.display,
374
523
  }));
375
524
  cy += valueH;
376
525
  if (s.delta) {
377
- cy += SPACE.xs;
378
- els.push(text(env.id(`delta-${i}`), cx, cy, cellW, lineHeightOf('caption'), s.delta.text, {
379
- fontSize: TYPE_SCALE.caption.size,
380
- lineHeight: TYPE_SCALE.caption.lineHeight,
381
- color: onDark || bare ? (s.delta.tone === 'down' ? COLOR.danger : COLOR.success) : COLOR.ink,
382
- fontWeight: 'bold', align: bare ? 'left' : 'center',
383
- }));
384
- 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);
385
532
  }
386
- cy += SPACE.sm;
387
- // Off-white at reduced opacity, because inkMuted is unreadable on ink.
388
- els.push(text(env.id(`label-${i}`), cx, cy, cellW, labelH, s.label, {
389
- fontSize: TYPE_SCALE.caption.size, lineHeight: TYPE_SCALE.caption.lineHeight,
390
- color: bare ? COLOR.inkMuted : labelColor, align: bare ? 'left' : 'center',
391
- opacity: labelOpacity, fontFamily: st.body,
392
- }));
393
533
  });
394
534
  return { elements: els, height, bleeds };
395
535
  }
@@ -456,7 +596,7 @@ export function steps(env, c) {
456
596
  fill: COLOR.accent,
457
597
  text: String(i + 1),
458
598
  fontSize: TYPE_SCALE.title.size,
459
- fontColor: COLOR.ink,
599
+ fontColor: COLOR.onAccent,
460
600
  fontWeight: 'bold',
461
601
  }));
462
602
  let ty = top + dot + SPACE.md;
@@ -495,7 +635,7 @@ function stepsStacked(env, c) {
495
635
  fill: COLOR.accent,
496
636
  text: String(i + 1),
497
637
  fontSize: TYPE_SCALE.body.size,
498
- fontColor: COLOR.ink,
638
+ fontColor: COLOR.onAccent,
499
639
  fontWeight: 'bold',
500
640
  }));
501
641
  let ty = y + round((dot - lineHeightOf('title')) / 2);
@@ -521,13 +661,17 @@ export function quote(env, c) {
521
661
  const pad = SPACE.xl;
522
662
  const inner = Math.min(env.width - pad * 2, 760);
523
663
  const innerX = env.x + round((env.width - inner) / 2);
524
- const quoteFamily = env.style.display === 'serif' ? 'sans' : 'serif';
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';
525
669
  const quoteH = textBlockHeight(c.quote, inner, 'headline', quoteFamily);
526
670
  const attrH = c.attribution ? lineHeightOf('caption') + SPACE.md : 0;
527
671
  const height = pad * 2 + quoteH + attrH;
528
672
  const els = [
529
673
  rect(env.id('panel'), env.x, env.y, env.width, height, {
530
- fill: SURFACE.muted.fill, cornerRadius: RADIUS.lg,
674
+ fill: COLOR.surfaceMuted, cornerRadius: radius().lg,
531
675
  }),
532
676
  block(env.id('quote'), innerX, env.y + pad, inner, c.quote, 'headline', {
533
677
  color: COLOR.ink, align: 'center', family: quoteFamily,
@@ -548,7 +692,7 @@ export function chartPanel(env, c) {
548
692
  const height = CARD_PADDING * 2 + titleH + SPACE.md + chartH + capH;
549
693
  const els = [
550
694
  rect(env.id('panel'), env.x, env.y, env.width, height, {
551
- fill: SURFACE.card.fill, cornerRadius: SURFACE.card.cornerRadius, shadow: { ...SHADOW.soft },
695
+ fill: COLOR.surface, cornerRadius: radius().md, shadow: { ...SHADOW.soft },
552
696
  }),
553
697
  ];
554
698
  let y = env.y + CARD_PADDING;
@@ -579,15 +723,15 @@ export function ctaBand(env, c) {
579
723
  const bleeds = env.style.bleedBands;
580
724
  const els = [
581
725
  rect(env.id('panel'), bleeds ? env.bleedX : env.x, env.y, bleeds ? env.bleedWidth : env.width, height, {
582
- fill: SURFACE.accent.fill, cornerRadius: bleeds ? 0 : RADIUS.lg,
726
+ fill: COLOR.accent, cornerRadius: bleeds ? 0 : radius().lg,
583
727
  }),
584
728
  ];
585
729
  let y = env.y + pad + round(Math.max(0, btnH - stack) / 2);
586
- els.push(block(env.id('headline'), env.x + pad, y, textW, c.headline, 'headline', { color: COLOR.ink, family: env.style.display }).el);
730
+ els.push(block(env.id('headline'), env.x + pad, y, textW, c.headline, 'headline', { color: COLOR.onAccent, family: env.style.display }).el);
587
731
  y += headH;
588
732
  if (c.note) {
589
733
  y += SPACE.sm;
590
- els.push(block(env.id('note'), env.x + pad, y, textW, c.note, 'caption', { color: COLOR.ink, opacity: 0.7 }).el);
734
+ els.push(block(env.id('note'), env.x + pad, y, textW, c.note, 'caption', { color: COLOR.onAccent, opacity: 0.7 }).el);
591
735
  }
592
736
  const btnX = env.x + env.width - pad - btnW;
593
737
  const btnY = env.y + round((height - btnH) / 2);
@@ -595,10 +739,10 @@ export function ctaBand(env, c) {
595
739
  // clickable rather than just the few pixels of text in the middle.
596
740
  const href = safeLinkHref(c.href) ?? undefined;
597
741
  els.push(rect(env.id('button'), btnX, btnY, btnW, btnH, {
598
- fill: COLOR.ink, cornerRadius: RADIUS.pill, ...(href ? { link: href } : {}),
742
+ fill: COLOR.primary, cornerRadius: radius().pill, ...(href ? { link: href } : {}),
599
743
  }));
600
744
  els.push(text(env.id('button-label'), btnX, btnY + round((btnH - lineHeightOf('body')) / 2), btnW, lineHeightOf('body'), c.buttonLabel, {
601
- fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.surface, fontWeight: 'bold', align: 'center',
745
+ fontSize: TYPE_SCALE.body.size, lineHeight: TYPE_SCALE.body.lineHeight, color: COLOR.onPrimary, fontWeight: 'bold', align: 'center',
602
746
  ...(href ? { link: href } : {}),
603
747
  }));
604
748
  return { elements: els, height, bleeds };
@@ -757,14 +901,208 @@ export function imageBand(env, c) {
757
901
  }
758
902
  return { elements: els, height };
759
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
+ }
760
1096
  export const SECTION_TYPES = [
761
1097
  'hero', 'featureGrid', 'statBand', 'split', 'steps', 'quote',
762
1098
  'chartPanel', 'ctaBand', 'comparisonTable', 'timeline', 'logoRow', 'footerMeta', 'imageBand',
1099
+ 'statusList', 'beforeAfter', 'funnel',
763
1100
  ];
764
1101
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
765
1102
  const RENDERERS = {
766
1103
  hero, featureGrid, statBand, split, steps, quote,
767
1104
  chartPanel, ctaBand, comparisonTable, timeline, logoRow, footerMeta, imageBand,
1105
+ statusList, beforeAfter, funnel,
768
1106
  };
769
1107
  /**
770
1108
  * A screen-shaped page for slide layout. 16:9 against the default column,
@@ -782,7 +1120,8 @@ export const SLIDE_HEIGHT = Math.round(DEFAULT_COLUMN * 9 / 16);
782
1120
  export function composeBoard(specs, opts = {}) {
783
1121
  const width = opts.columnWidth ?? DEFAULT_COLUMN;
784
1122
  const margin = opts.margin ?? CANVAS_MARGIN;
785
- const style = resolveStyle(opts.style ?? DEFAULT_STYLE);
1123
+ const base = resolveStyle(opts.style ?? DEFAULT_STYLE);
1124
+ const style = { ...base, ...brandFonts(base) };
786
1125
  const gap = gapFor(style);
787
1126
  const layout = opts.layout ?? 'page';
788
1127
  const elements = [];