@uibot/blocks-studio 0.0.0-stage → 0.2.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.
@@ -0,0 +1,1069 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RendererComponent } from "@uibot/renderer-react";
3
+
4
+ /**
5
+ * "Schematic Editorial" section / layout blocks — tranche 3.
6
+ *
7
+ * A breadth-expanding batch of **original** marketing & layout primitives that
8
+ * widen UIBot's catalog toward the category coverage of large design-system kits
9
+ * (announcement banners, alternating feature splits, comparison tables, roadmap
10
+ * timelines, metric spotlights, benefit lists, footers, content accordions,
11
+ * sparkline metric cards, caption galleries) while staying first-party
12
+ * implementations.
13
+ *
14
+ * Design rules these follow (identical to presentation/content/marketing.tsx):
15
+ * ① Work in any context off the core theme tokens (foreground / muted /
16
+ * border / primary / card); under a `.marketing` scope they pick up the
17
+ * brand serif (`--font-display`), mono (`--font-marketing-mono`) and warm
18
+ * amber / teal / rose / indigo accents (`--marketing-accent`,
19
+ * `--mk-accent-2..4`) plus the hairline `.mkt-card` material with hover lift.
20
+ * ② Light + dark via tokens / `color-mix` — no hard-coded colours.
21
+ * ③ Pure SVG / CSS — zero new npm dependencies (icons map to a small inline
22
+ * SVG set, mirroring the sibling block files so specs share icon names).
23
+ * ④ Each ships a full CatalogEntry (see ../catalog.ts).
24
+ *
25
+ * CTA props ({label, href}) render as accessible anchors, matching the sibling
26
+ * blocks' convention.
27
+ */
28
+
29
+ function cn(...cls: (string | false | null | undefined)[]): string {
30
+ return cls.filter(Boolean).join(" ");
31
+ }
32
+
33
+ function str(v: unknown): string | undefined {
34
+ return typeof v === "string" && v.length > 0 ? v : undefined;
35
+ }
36
+
37
+ function strArr(raw: unknown): string[] {
38
+ if (!Array.isArray(raw)) return [];
39
+ return raw.map((v) => str(v)).filter((v): v is string => Boolean(v));
40
+ }
41
+
42
+ function records(raw: unknown): Record<string, unknown>[] {
43
+ if (!Array.isArray(raw)) return [];
44
+ return raw.filter((it): it is Record<string, unknown> => Boolean(it) && typeof it === "object");
45
+ }
46
+
47
+ function num(v: unknown): number | undefined {
48
+ const n = Number(v);
49
+ return Number.isFinite(n) ? n : undefined;
50
+ }
51
+
52
+ /** Clamp a 0-based accent index into the four-hue tint palette (0..3). */
53
+ function tintIndex(raw: unknown, fallback = 0): number {
54
+ const n = Number(raw);
55
+ return Number.isFinite(n) ? ((Math.trunc(n) % 4) + 4) % 4 : fallback;
56
+ }
57
+
58
+ interface Cta {
59
+ label: string;
60
+ href: string;
61
+ }
62
+
63
+ function parseCta(raw: unknown): Cta | undefined {
64
+ if (!raw || typeof raw !== "object") return undefined;
65
+ const rec = raw as Record<string, unknown>;
66
+ const label = str(rec["label"]);
67
+ const href = str(rec["href"]);
68
+ if (!label) return undefined;
69
+ return { label, href: href ?? "#" };
70
+ }
71
+
72
+ // ── Inline icon set (lucide-compatible names, no runtime dep) ──────────────────
73
+ // Mirrors the sibling block files so specs reuse the same icon vocabulary;
74
+ // unknown names fall back to a dot so a block never throws on an unmapped icon.
75
+
76
+ const ICON_PATHS: Record<string, ReactNode> = {
77
+ sparkles: <path d="M12 3l1.9 4.6L18.5 9.5l-4.6 1.9L12 16l-1.9-4.6L5.5 9.5l4.6-1.9z" />,
78
+ zap: <path d="M13 2 4 14h7l-1 8 9-12h-7z" />,
79
+ layers: (
80
+ <>
81
+ <path d="m12 3 9 5-9 5-9-5 9-5z" />
82
+ <path d="m3 12 9 5 9-5" />
83
+ </>
84
+ ),
85
+ boxes: (
86
+ <>
87
+ <rect x="3" y="3" width="7" height="7" rx="1" />
88
+ <rect x="14" y="3" width="7" height="7" rx="1" />
89
+ <rect x="8.5" y="14" width="7" height="7" rx="1" />
90
+ </>
91
+ ),
92
+ code: <path d="m8 6-6 6 6 6M16 6l6 6-6 6" />,
93
+ cpu: (
94
+ <>
95
+ <rect x="6" y="6" width="12" height="12" rx="2" />
96
+ <path d="M9 1v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3" />
97
+ </>
98
+ ),
99
+ workflow: (
100
+ <>
101
+ <rect x="3" y="3" width="7" height="7" rx="1" />
102
+ <rect x="14" y="14" width="7" height="7" rx="1" />
103
+ <path d="M10 6.5h6a2 2 0 0 1 2 2V14" />
104
+ </>
105
+ ),
106
+ gauge: (
107
+ <>
108
+ <path d="M3 14a9 9 0 1 1 18 0" />
109
+ <path d="m13 12-3 3" />
110
+ </>
111
+ ),
112
+ shield: <path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z" />,
113
+ wand: <path d="m15 4 5 5M4 20 14 10M9 4l1 2 2 1-2 1-1 2-1-2-2-1 2-1z" />,
114
+ info: (
115
+ <>
116
+ <circle cx="12" cy="12" r="9" />
117
+ <path d="M12 11v5M12 7.5h.01" />
118
+ </>
119
+ ),
120
+ check: <path d="m20 6-11 11-5-5" />,
121
+ alert: (
122
+ <>
123
+ <path d="M12 3 2 20h20L12 3z" />
124
+ <path d="M12 10v4M12 17.5h.01" />
125
+ </>
126
+ ),
127
+ rocket: (
128
+ <>
129
+ <path d="M5 16c-1.5 1.5-2 5-2 5s3.5-.5 5-2a3 3 0 0 0-3-3z" />
130
+ <path d="M9 14c-1-2 0-6 3.5-9.5C15 2 19 2 21 3c1 2 1 6-1.5 8.5C16 15 12 16 10 15z" />
131
+ <circle cx="15" cy="9" r="1.4" />
132
+ </>
133
+ ),
134
+ flag: (
135
+ <>
136
+ <path d="M4 22V4" />
137
+ <path d="M4 4h13l-2 4 2 4H4" />
138
+ </>
139
+ ),
140
+ star: <path d="m12 3 2.6 5.3 5.9.9-4.3 4.1 1 5.8L12 16.6 6.8 19.1l1-5.8L3.5 9.2l5.9-.9z" />,
141
+ heart: (
142
+ <path d="M12 20s-7-4.5-9.3-9C1.2 8 2.8 4.6 6.2 4.6c2 0 3.2 1.2 3.8 2.2.6-1 1.8-2.2 3.8-2.2 3.4 0 5 3.4 3.5 6.4C19 15.5 12 20 12 20z" />
143
+ ),
144
+ globe: (
145
+ <>
146
+ <circle cx="12" cy="12" r="9" />
147
+ <path d="M3 12h18M12 3c2.5 2.6 2.5 15.4 0 18M12 3c-2.5 2.6-2.5 15.4 0 18" />
148
+ </>
149
+ ),
150
+ lock: (
151
+ <>
152
+ <rect x="5" y="11" width="14" height="9" rx="2" />
153
+ <path d="M8 11V8a4 4 0 0 1 8 0v3" />
154
+ </>
155
+ ),
156
+ clock: (
157
+ <>
158
+ <circle cx="12" cy="12" r="9" />
159
+ <path d="M12 7v5l3 2" />
160
+ </>
161
+ ),
162
+ x: <path d="M6 6l12 12M18 6 6 18" />,
163
+ };
164
+
165
+ function Icon({
166
+ name,
167
+ className = "size-5",
168
+ }: {
169
+ name?: string | undefined;
170
+ className?: string;
171
+ }): React.ReactElement {
172
+ const path = (name && ICON_PATHS[name.toLowerCase()]) || <circle cx="12" cy="12" r="3" />;
173
+ return (
174
+ <svg
175
+ viewBox="0 0 24 24"
176
+ fill="none"
177
+ stroke="currentColor"
178
+ strokeWidth={1.6}
179
+ strokeLinecap="round"
180
+ strokeLinejoin="round"
181
+ className={className}
182
+ aria-hidden="true"
183
+ >
184
+ {path}
185
+ </svg>
186
+ );
187
+ }
188
+
189
+ // ── Shared CTA anchor ────────────────────────────────────────────────────────────
190
+
191
+ function CtaLink({
192
+ cta,
193
+ variant,
194
+ size = "md",
195
+ }: {
196
+ cta: Cta;
197
+ variant: "primary" | "outline" | "inverse" | "ghost";
198
+ size?: "sm" | "md";
199
+ }): React.ReactElement {
200
+ const sizes: Record<string, string> = {
201
+ sm: "px-3.5 py-1.5 text-xs",
202
+ md: "px-5 py-2.5 text-sm",
203
+ };
204
+ const base = cn(
205
+ "inline-flex items-center justify-center gap-2 rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
206
+ sizes[size],
207
+ );
208
+ const variants: Record<typeof variant, string> = {
209
+ primary:
210
+ "bg-[var(--marketing-accent)] text-[var(--marketing-accent-foreground)] hover:bg-[var(--marketing-accent-strong)] focus-visible:ring-[var(--marketing-accent)]",
211
+ outline:
212
+ "border border-border bg-transparent text-foreground hover:border-[var(--marketing-accent)] hover:text-[var(--marketing-accent)] focus-visible:ring-border",
213
+ inverse:
214
+ "bg-gradient-to-r from-[var(--marketing-accent)] to-[var(--mk-accent-3)] text-[var(--marketing-accent-foreground)] hover:opacity-90 focus-visible:ring-[var(--marketing-accent)]",
215
+ ghost:
216
+ "text-[var(--marketing-accent)] underline-offset-4 hover:underline focus-visible:ring-[var(--marketing-accent)]",
217
+ };
218
+ return (
219
+ <a href={cta.href} className={cn(base, variants[variant])}>
220
+ {cta.label}
221
+ </a>
222
+ );
223
+ }
224
+
225
+ // ── Banner ──────────────────────────────────────────────────────────────────────
226
+
227
+ /**
228
+ * Top-of-page announcement bar. A slim full-width strip with an optional icon,
229
+ * a message, an optional inline CTA link and a decorative dismiss "×". `tone`
230
+ * switches the wash between the four brand accents; `solid` fills the strip with
231
+ * the accent instead of a soft tint.
232
+ */
233
+ export const Banner: RendererComponent = (props) => {
234
+ const tone = tintIndex(props["tone"], 0);
235
+ const solid = Boolean(props["solid"]);
236
+ const icon = str(props["icon"]) ?? "sparkles";
237
+ const message = str(props["message"]) ?? "";
238
+ const cta = parseCta(props["cta"]);
239
+ const dismissible = props["dismissible"] !== false;
240
+
241
+ return (
242
+ <div
243
+ className={cn(
244
+ "marketing relative w-full px-4 py-2.5 text-center text-sm",
245
+ solid
246
+ ? "text-[var(--marketing-accent-foreground)]"
247
+ : "border-b border-border text-foreground mkt-tint",
248
+ !solid && `mkt-tint-${tone}`,
249
+ )}
250
+ data-uibot-type="Banner"
251
+ style={
252
+ solid
253
+ ? {
254
+ background: `var(${["--marketing-accent", "--mk-accent-2", "--mk-accent-3", "--mk-accent-4"][tone]})`,
255
+ }
256
+ : undefined
257
+ }
258
+ role="region"
259
+ aria-label="Announcement"
260
+ >
261
+ <div className="mx-auto flex max-w-6xl flex-wrap items-center justify-center gap-x-3 gap-y-1">
262
+ <span className="inline-flex items-center gap-2">
263
+ <Icon name={icon} className="size-4 shrink-0" />
264
+ <span className="font-medium">{message}</span>
265
+ </span>
266
+ {cta && (
267
+ <a
268
+ href={cta.href}
269
+ className={cn(
270
+ "inline-flex items-center gap-1 font-[family-name:var(--font-marketing-mono)] text-xs font-semibold uppercase tracking-[0.12em] underline-offset-4 hover:underline",
271
+ solid ? "" : "text-[var(--marketing-accent)]",
272
+ )}
273
+ >
274
+ {cta.label}
275
+ <Icon name="code" className="size-3.5 rotate-180 [transform:rotateY(180deg)]" />
276
+ </a>
277
+ )}
278
+ </div>
279
+ {dismissible && (
280
+ <span
281
+ aria-hidden="true"
282
+ className="absolute right-3 top-1/2 inline-flex size-6 -translate-y-1/2 items-center justify-center rounded-md opacity-60 hover:opacity-100"
283
+ >
284
+ <Icon name="x" className="size-4" />
285
+ </span>
286
+ )}
287
+ </div>
288
+ );
289
+ };
290
+
291
+ // ── FeatureSplit ──────────────────────────────────────────────────────────────────
292
+
293
+ interface SplitBullet {
294
+ icon?: string | undefined;
295
+ text: string;
296
+ }
297
+
298
+ function parseBullets(raw: unknown): SplitBullet[] {
299
+ if (!Array.isArray(raw)) return [];
300
+ return raw
301
+ .map((b): SplitBullet | undefined => {
302
+ if (typeof b === "string") return b.length > 0 ? { text: b } : undefined;
303
+ if (b && typeof b === "object") {
304
+ const rec = b as Record<string, unknown>;
305
+ const text = str(rec["text"]) ?? "";
306
+ return text.length > 0 ? { icon: str(rec["icon"]), text } : undefined;
307
+ }
308
+ return undefined;
309
+ })
310
+ .filter((b): b is SplitBullet => Boolean(b));
311
+ }
312
+
313
+ /**
314
+ * Alternating two-column feature section: an editorial text column (eyebrow,
315
+ * serif title, body, bullet list, optional CTA) beside a visual column. The
316
+ * visual renders the `visual` slot (or children) — typically a BrowserFrame or a
317
+ * rendered preview — falling back to a tinted blueprint placeholder. `reverse`
318
+ * flips the column order for an alternating rhythm down a page.
319
+ */
320
+ export const FeatureSplit: RendererComponent = (props, ctx) => {
321
+ const eyebrow = str(props["eyebrow"]);
322
+ const title = str(props["title"]) ?? "";
323
+ const body = str(props["body"]);
324
+ const bullets = parseBullets(props["bullets"]);
325
+ const cta = parseCta(props["cta"]);
326
+ const reverse = Boolean(props["reverse"]);
327
+ const tone = tintIndex(props["tone"], 0);
328
+ const visual = (ctx.slots["visual"] as ReactNode[] | undefined) ?? (ctx.children as ReactNode[]);
329
+ const hasVisual = visual && visual.length > 0;
330
+
331
+ return (
332
+ <section className="marketing mx-auto max-w-6xl px-6 md:px-0" data-uibot-type="FeatureSplit">
333
+ <div
334
+ className={cn(
335
+ "grid items-center gap-10 md:grid-cols-2 md:gap-14",
336
+ reverse && "md:[direction:rtl]",
337
+ )}
338
+ >
339
+ <div className={cn("max-w-xl md:[direction:ltr]")}>
340
+ {eyebrow && <p className="mkt-eyebrow">{eyebrow}</p>}
341
+ <h2 className="mt-4 text-3xl md:text-4xl">{title}</h2>
342
+ {body && <p className="mt-4 text-base leading-relaxed text-muted-foreground">{body}</p>}
343
+ {bullets.length > 0 && (
344
+ <ul className="mt-6 flex flex-col gap-3">
345
+ {bullets.map((b, i) => (
346
+ <li key={i} className="flex items-start gap-3 text-sm text-foreground/90">
347
+ <span
348
+ className={cn(
349
+ "mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md border mkt-tint",
350
+ `mkt-tint-${tone}`,
351
+ )}
352
+ >
353
+ <Icon name={b.icon ?? "check"} className="size-3.5" />
354
+ </span>
355
+ <span className="leading-relaxed">{b.text}</span>
356
+ </li>
357
+ ))}
358
+ </ul>
359
+ )}
360
+ {cta && (
361
+ <div className="mt-8">
362
+ <CtaLink cta={cta} variant="primary" />
363
+ </div>
364
+ )}
365
+ </div>
366
+ <div className="md:[direction:ltr]">
367
+ {hasVisual ? (
368
+ visual
369
+ ) : (
370
+ <div
371
+ className={cn(
372
+ "mkt-card flex aspect-[4/3] items-center justify-center [background-image:radial-gradient(color-mix(in_oklch,var(--border)_80%,transparent)_1px,transparent_1px)] [background-size:18px_18px]",
373
+ )}
374
+ >
375
+ <span
376
+ className={cn(
377
+ "inline-flex size-14 items-center justify-center rounded-xl border mkt-tint",
378
+ `mkt-tint-${tone}`,
379
+ )}
380
+ >
381
+ <Icon name="layers" className="size-7" />
382
+ </span>
383
+ </div>
384
+ )}
385
+ </div>
386
+ </div>
387
+ </section>
388
+ );
389
+ };
390
+
391
+ // ── ComparisonTable ────────────────────────────────────────────────────────────
392
+
393
+ interface CompareColumn {
394
+ name: string;
395
+ highlighted?: boolean | undefined;
396
+ }
397
+
398
+ interface CompareRow {
399
+ feature: string;
400
+ values: unknown[];
401
+ }
402
+
403
+ function parseColumns(raw: unknown): CompareColumn[] {
404
+ if (Array.isArray(raw) && raw.every((v) => typeof v === "string")) {
405
+ return strArr(raw).map((name) => ({ name }));
406
+ }
407
+ return records(raw)
408
+ .map((c) => ({ name: str(c["name"]) ?? "", highlighted: Boolean(c["highlighted"]) }))
409
+ .filter((c) => c.name.length > 0);
410
+ }
411
+
412
+ function parseRows(raw: unknown): CompareRow[] {
413
+ return records(raw)
414
+ .map((r) => ({
415
+ feature: str(r["feature"]) ?? "",
416
+ values: Array.isArray(r["values"]) ? (r["values"] as unknown[]) : [],
417
+ }))
418
+ .filter((r) => r.feature.length > 0);
419
+ }
420
+
421
+ /** Render one comparison cell: ✓ / ✗ for booleans, else the verbatim string. */
422
+ function CompareCell({ value }: { value: unknown }): React.ReactElement {
423
+ if (value === true || value === "true" || value === "yes") {
424
+ return (
425
+ <span className="inline-flex text-[var(--marketing-accent)]" aria-label="Yes">
426
+ <Icon name="check" className="size-4" />
427
+ </span>
428
+ );
429
+ }
430
+ if (value === false || value === "false" || value === "no" || value === "" || value == null) {
431
+ return (
432
+ <span className="inline-flex text-muted-foreground/40" aria-label="No">
433
+ <Icon name="x" className="size-4" />
434
+ </span>
435
+ );
436
+ }
437
+ return <span className="text-sm text-foreground/90">{String(value)}</span>;
438
+ }
439
+
440
+ /**
441
+ * Feature comparison table across products/plans. The header row lists columns
442
+ * (a `highlighted` column gets an amber-washed spine); each body row pairs a
443
+ * feature label with one value per column — booleans render as amber check /
444
+ * muted cross glyphs, strings render verbatim. Horizontally scrollable on small
445
+ * screens.
446
+ */
447
+ export const ComparisonTable: RendererComponent = (props) => {
448
+ const columns = parseColumns(props["columns"]);
449
+ const rows = parseRows(props["rows"]);
450
+ const featureLabel = str(props["featureLabel"]) ?? "";
451
+
452
+ return (
453
+ <section className="marketing mx-auto max-w-6xl px-6 md:px-0" data-uibot-type="ComparisonTable">
454
+ <div className="overflow-x-auto rounded-xl border border-border bg-card">
455
+ <table className="w-full border-collapse text-left">
456
+ <thead>
457
+ <tr className="border-b border-border">
458
+ <th className="px-5 py-4 font-[family-name:var(--font-marketing-mono)] text-xs uppercase tracking-[0.14em] text-muted-foreground">
459
+ {featureLabel}
460
+ </th>
461
+ {columns.map((c, i) => (
462
+ <th
463
+ key={i}
464
+ className={cn(
465
+ "px-5 py-4 text-center text-sm font-semibold text-foreground",
466
+ c.highlighted &&
467
+ "bg-[color-mix(in_oklch,var(--marketing-accent)_8%,transparent)] text-[var(--marketing-accent)]",
468
+ )}
469
+ >
470
+ {c.name}
471
+ </th>
472
+ ))}
473
+ </tr>
474
+ </thead>
475
+ <tbody>
476
+ {rows.map((r, ri) => (
477
+ <tr key={ri} className="border-b border-border last:border-0">
478
+ <th
479
+ scope="row"
480
+ className="px-5 py-3.5 text-left text-sm font-medium text-foreground"
481
+ >
482
+ {r.feature}
483
+ </th>
484
+ {columns.map((c, ci) => (
485
+ <td
486
+ key={ci}
487
+ className={cn(
488
+ "px-5 py-3.5 text-center",
489
+ c.highlighted &&
490
+ "bg-[color-mix(in_oklch,var(--marketing-accent)_6%,transparent)]",
491
+ )}
492
+ >
493
+ <CompareCell value={r.values[ci]} />
494
+ </td>
495
+ ))}
496
+ </tr>
497
+ ))}
498
+ </tbody>
499
+ </table>
500
+ </div>
501
+ </section>
502
+ );
503
+ };
504
+
505
+ // ── Roadmap ──────────────────────────────────────────────────────────────────────
506
+
507
+ type MilestoneState = "done" | "active" | "planned";
508
+
509
+ interface Milestone {
510
+ date?: string | undefined;
511
+ title: string;
512
+ desc?: string | undefined;
513
+ state: MilestoneState;
514
+ }
515
+
516
+ function parseMilestones(raw: unknown): Milestone[] {
517
+ return records(raw)
518
+ .map((m) => {
519
+ const s = str(m["state"]);
520
+ const state: MilestoneState =
521
+ s === "done" || s === "active" || s === "planned" ? s : "planned";
522
+ return {
523
+ date: str(m["date"]),
524
+ title: str(m["title"]) ?? "",
525
+ desc: str(m["desc"]),
526
+ state,
527
+ };
528
+ })
529
+ .filter((m) => m.title.length > 0);
530
+ }
531
+
532
+ const MILESTONE_DOT: Record<MilestoneState, string> = {
533
+ done: "bg-[var(--marketing-accent)] border-[var(--marketing-accent)] text-[var(--marketing-accent-foreground)]",
534
+ active:
535
+ "border-[var(--marketing-accent)] text-[var(--marketing-accent)] bg-card ring-4 ring-[color-mix(in_oklch,var(--marketing-accent)_20%,transparent)]",
536
+ planned: "border-border text-muted-foreground bg-card",
537
+ };
538
+
539
+ const MILESTONE_GLYPH: Record<MilestoneState, string> = {
540
+ done: "check",
541
+ active: "rocket",
542
+ planned: "flag",
543
+ };
544
+
545
+ /**
546
+ * Product roadmap / milestone timeline. A vertical rail with one node per
547
+ * milestone; node state (`done` / `active` / `planned`) drives the dot styling
548
+ * — a filled amber check for shipped, an amber ring + rocket for in-progress, an
549
+ * outline flag for planned. Distinct from the data-studio TimelineList (which is
550
+ * an operational activity log); this is a marketing roadmap presentation.
551
+ */
552
+ export const Roadmap: RendererComponent = (props) => {
553
+ const milestones = parseMilestones(props["milestones"]);
554
+
555
+ return (
556
+ <ol className="marketing mx-auto max-w-3xl px-6 md:px-0" data-uibot-type="Roadmap">
557
+ {milestones.map((m, i) => (
558
+ <li key={i} className="relative flex gap-5 pb-8 last:pb-0">
559
+ {i < milestones.length - 1 && (
560
+ <span
561
+ aria-hidden="true"
562
+ className="absolute left-[1.375rem] top-12 bottom-0 w-px bg-border"
563
+ />
564
+ )}
565
+ <span
566
+ className={cn(
567
+ "relative z-10 inline-flex size-11 shrink-0 items-center justify-center rounded-full border",
568
+ MILESTONE_DOT[m.state],
569
+ )}
570
+ >
571
+ <Icon name={MILESTONE_GLYPH[m.state]} className="size-5" />
572
+ </span>
573
+ <div className="pt-1">
574
+ {m.date && (
575
+ <p className="font-[family-name:var(--font-marketing-mono)] text-xs uppercase tracking-[0.14em] text-[var(--marketing-accent)]">
576
+ {m.date}
577
+ </p>
578
+ )}
579
+ <h3 className="mt-1 text-xl">{m.title}</h3>
580
+ {m.desc && (
581
+ <p className="mt-1.5 text-sm leading-relaxed text-muted-foreground">{m.desc}</p>
582
+ )}
583
+ </div>
584
+ </li>
585
+ ))}
586
+ </ol>
587
+ );
588
+ };
589
+
590
+ // ── StatHighlight ──────────────────────────────────────────────────────────────
591
+
592
+ /**
593
+ * Single big-number spotlight. An oversized serif value with an optional trend
594
+ * delta (up = amber, down = rose), a mono label and supporting copy. Use to draw
595
+ * the eye to one headline metric between sections — distinct from StatBand
596
+ * (a multi-stat row).
597
+ */
598
+ export const StatHighlight: RendererComponent = (props) => {
599
+ const value = str(props["value"]) ?? "";
600
+ const label = str(props["label"]);
601
+ const body = str(props["body"]);
602
+ const delta = str(props["delta"]);
603
+ const trend = str(props["trend"]); // "up" | "down"
604
+ const down = trend === "down";
605
+
606
+ return (
607
+ <section
608
+ className="marketing mx-auto max-w-3xl px-6 text-center md:px-0"
609
+ data-uibot-type="StatHighlight"
610
+ >
611
+ <div className="flex items-end justify-center gap-3">
612
+ <span className="mkt-display text-6xl leading-none md:text-8xl">{value}</span>
613
+ {delta && (
614
+ <span
615
+ className={cn(
616
+ "mb-2 inline-flex items-center gap-1 rounded-full px-2.5 py-1 font-[family-name:var(--font-marketing-mono)] text-xs font-semibold",
617
+ down
618
+ ? "bg-[color-mix(in_oklch,var(--mk-accent-3)_16%,transparent)] text-[var(--mk-accent-3)]"
619
+ : "bg-[color-mix(in_oklch,var(--marketing-accent)_18%,transparent)] text-[var(--marketing-accent)]",
620
+ )}
621
+ >
622
+ <svg
623
+ viewBox="0 0 24 24"
624
+ fill="none"
625
+ stroke="currentColor"
626
+ strokeWidth={2.2}
627
+ strokeLinecap="round"
628
+ strokeLinejoin="round"
629
+ className={cn("size-3.5", down && "rotate-180")}
630
+ aria-hidden="true"
631
+ >
632
+ <path d="M12 19V5M6 11l6-6 6 6" />
633
+ </svg>
634
+ {delta}
635
+ </span>
636
+ )}
637
+ </div>
638
+ {label && (
639
+ <p className="mt-4 font-[family-name:var(--font-marketing-mono)] text-sm uppercase tracking-[0.2em] text-muted-foreground">
640
+ {label}
641
+ </p>
642
+ )}
643
+ {body && (
644
+ <p className="mx-auto mt-3 max-w-xl text-base leading-relaxed text-muted-foreground">
645
+ {body}
646
+ </p>
647
+ )}
648
+ </section>
649
+ );
650
+ };
651
+
652
+ // ── IconList ──────────────────────────────────────────────────────────────────────
653
+
654
+ interface BenefitItem {
655
+ icon?: string | undefined;
656
+ title: string;
657
+ desc?: string | undefined;
658
+ }
659
+
660
+ function parseBenefits(raw: unknown): BenefitItem[] {
661
+ if (!Array.isArray(raw)) return [];
662
+ return raw
663
+ .map((b): BenefitItem | undefined => {
664
+ if (typeof b === "string") return b.length > 0 ? { title: b } : undefined;
665
+ if (b && typeof b === "object") {
666
+ const rec = b as Record<string, unknown>;
667
+ const title = str(rec["title"]) ?? "";
668
+ return title.length > 0
669
+ ? { icon: str(rec["icon"]), title, desc: str(rec["desc"]) }
670
+ : undefined;
671
+ }
672
+ return undefined;
673
+ })
674
+ .filter((b): b is BenefitItem => Boolean(b));
675
+ }
676
+
677
+ const ICONLIST_COLS: Record<string, string> = {
678
+ "1": "",
679
+ "2": "sm:grid-cols-2",
680
+ "3": "sm:grid-cols-2 lg:grid-cols-3",
681
+ };
682
+
683
+ /**
684
+ * Benefit / checklist list with icons. Each item shows a tinted icon chip, a
685
+ * title and optional supporting line. `columns` (1–3) lays the items into a
686
+ * grid; tints cycle the four accents. Lighter-weight than FeatureGrid (no card
687
+ * material) — for inline benefit/checklist runs.
688
+ */
689
+ export const IconList: RendererComponent = (props) => {
690
+ const items = parseBenefits(props["items"]);
691
+ const cols = String(props["columns"] ?? "2");
692
+ const colsCls = ICONLIST_COLS[cols] ?? ICONLIST_COLS["2"];
693
+ const defaultIcon = str(props["icon"]) ?? "check";
694
+
695
+ return (
696
+ <section className="marketing mx-auto max-w-5xl px-6 md:px-0" data-uibot-type="IconList">
697
+ <ul className={cn("grid grid-cols-1 gap-x-8 gap-y-6", colsCls)}>
698
+ {items.map((b, i) => (
699
+ <li key={i} className="flex items-start gap-3.5">
700
+ <span
701
+ className={cn(
702
+ "mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-lg border mkt-tint",
703
+ `mkt-tint-${i % 4}`,
704
+ )}
705
+ >
706
+ <Icon name={b.icon ?? defaultIcon} className="size-4" />
707
+ </span>
708
+ <div className="min-w-0">
709
+ <p className="font-medium text-foreground">{b.title}</p>
710
+ {b.desc && (
711
+ <p className="mt-1 text-sm leading-relaxed text-muted-foreground">{b.desc}</p>
712
+ )}
713
+ </div>
714
+ </li>
715
+ ))}
716
+ </ul>
717
+ </section>
718
+ );
719
+ };
720
+
721
+ // ── Footer ──────────────────────────────────────────────────────────────────────
722
+
723
+ interface FooterLink {
724
+ label: string;
725
+ href: string;
726
+ }
727
+
728
+ interface FooterGroup {
729
+ title: string;
730
+ links: FooterLink[];
731
+ }
732
+
733
+ function parseFooterGroups(raw: unknown): FooterGroup[] {
734
+ return records(raw)
735
+ .map((g) => ({
736
+ title: str(g["title"]) ?? "",
737
+ links: records(g["links"])
738
+ .map((l) => ({ label: str(l["label"]) ?? "", href: str(l["href"]) ?? "#" }))
739
+ .filter((l) => l.label.length > 0),
740
+ }))
741
+ .filter((g) => g.title.length > 0 || g.links.length > 0);
742
+ }
743
+
744
+ /**
745
+ * Multi-column marketing footer. A brand block (mono wordmark + tagline) sits
746
+ * beside grouped link columns; a bottom rule carries an optional copyright line
747
+ * and small print. Pure layout off theme tokens; under `.marketing` the brand
748
+ * wordmark uses the serif display face.
749
+ */
750
+ export const Footer: RendererComponent = (props) => {
751
+ const brand = str(props["brand"]) ?? "";
752
+ const tagline = str(props["tagline"]);
753
+ const groups = parseFooterGroups(props["groups"]);
754
+ const copyright = str(props["copyright"]);
755
+ const note = str(props["note"]);
756
+
757
+ return (
758
+ <footer
759
+ className="marketing border-t border-border bg-card/40 px-6 py-14 md:px-10"
760
+ data-uibot-type="Footer"
761
+ >
762
+ <div className="mx-auto grid max-w-6xl gap-10 md:grid-cols-[1.4fr_2.6fr]">
763
+ <div className="max-w-sm">
764
+ {brand && <p className="mkt-display text-2xl">{brand}</p>}
765
+ {tagline && (
766
+ <p className="mt-3 text-sm leading-relaxed text-muted-foreground">{tagline}</p>
767
+ )}
768
+ </div>
769
+ {groups.length > 0 && (
770
+ <div className="grid grid-cols-2 gap-8 sm:grid-cols-3">
771
+ {groups.map((g, i) => (
772
+ <div key={i}>
773
+ <p className="font-[family-name:var(--font-marketing-mono)] text-xs uppercase tracking-[0.16em] text-muted-foreground">
774
+ {g.title}
775
+ </p>
776
+ <ul className="mt-4 flex flex-col gap-2.5">
777
+ {g.links.map((l, li) => (
778
+ <li key={li}>
779
+ <a
780
+ href={l.href}
781
+ className="text-sm text-foreground/80 underline-offset-4 transition-colors hover:text-[var(--marketing-accent)] hover:underline"
782
+ >
783
+ {l.label}
784
+ </a>
785
+ </li>
786
+ ))}
787
+ </ul>
788
+ </div>
789
+ ))}
790
+ </div>
791
+ )}
792
+ </div>
793
+ {(copyright || note) && (
794
+ <div className="mx-auto mt-12 flex max-w-6xl flex-col items-start justify-between gap-2 border-t border-border pt-6 text-xs text-muted-foreground sm:flex-row sm:items-center">
795
+ {copyright && <span>{copyright}</span>}
796
+ {note && (
797
+ <span className="font-[family-name:var(--font-marketing-mono)] uppercase tracking-[0.14em]">
798
+ {note}
799
+ </span>
800
+ )}
801
+ </div>
802
+ )}
803
+ </footer>
804
+ );
805
+ };
806
+
807
+ // ── AccordionList ────────────────────────────────────────────────────────────────
808
+
809
+ interface AccordionItem {
810
+ icon?: string | undefined;
811
+ title: string;
812
+ body: string;
813
+ }
814
+
815
+ function parseAccordionItems(raw: unknown): AccordionItem[] {
816
+ return records(raw)
817
+ .map((it) => ({
818
+ icon: str(it["icon"]),
819
+ title: str(it["title"]) ?? "",
820
+ body: str(it["body"]) ?? "",
821
+ }))
822
+ .filter((it) => it.title.length > 0);
823
+ }
824
+
825
+ /**
826
+ * General-purpose content accordion built on native <details>/<summary> — fully
827
+ * functional with zero JS / state wiring. Each row carries an optional leading
828
+ * icon chip, a title and a body, separated as standalone hairline cards (vs. the
829
+ * Faq block's single divided card). `defaultOpenFirst` opens the first row.
830
+ */
831
+ export const AccordionList: RendererComponent = (props) => {
832
+ const title = str(props["title"]);
833
+ const items = parseAccordionItems(props["items"]);
834
+ const openFirst = Boolean(props["defaultOpenFirst"]);
835
+
836
+ return (
837
+ <section className="marketing mx-auto max-w-3xl px-6 md:px-0" data-uibot-type="AccordionList">
838
+ {title && <h2 className="mb-6 text-3xl md:text-4xl">{title}</h2>}
839
+ <div className="flex flex-col gap-3">
840
+ {items.map((it, i) => (
841
+ <details
842
+ key={i}
843
+ open={openFirst && i === 0}
844
+ className="group mkt-card overflow-hidden p-0 [&_summary::-webkit-details-marker]:hidden"
845
+ >
846
+ <summary className="flex cursor-pointer list-none items-center gap-3.5 px-5 py-4 text-base font-medium text-foreground">
847
+ {it.icon && (
848
+ <span
849
+ className={cn(
850
+ "inline-flex size-8 shrink-0 items-center justify-center rounded-lg border mkt-tint",
851
+ `mkt-tint-${i % 4}`,
852
+ )}
853
+ >
854
+ <Icon name={it.icon} className="size-4" />
855
+ </span>
856
+ )}
857
+ <span className="flex-1">{it.title}</span>
858
+ <svg
859
+ viewBox="0 0 24 24"
860
+ fill="none"
861
+ stroke="currentColor"
862
+ strokeWidth={1.8}
863
+ strokeLinecap="round"
864
+ strokeLinejoin="round"
865
+ className="size-4 shrink-0 text-muted-foreground transition-transform duration-200 group-open:rotate-180"
866
+ aria-hidden="true"
867
+ >
868
+ <path d="m6 9 6 6 6-6" />
869
+ </svg>
870
+ </summary>
871
+ {it.body && (
872
+ <p className="px-5 pb-5 text-sm leading-relaxed text-muted-foreground">{it.body}</p>
873
+ )}
874
+ </details>
875
+ ))}
876
+ </div>
877
+ </section>
878
+ );
879
+ };
880
+
881
+ // ── MetricCard ──────────────────────────────────────────────────────────────────
882
+
883
+ /** Build an SVG sparkline polyline + area path from a numeric series. */
884
+ function sparkline(
885
+ points: number[],
886
+ w: number,
887
+ h: number,
888
+ pad = 2,
889
+ ): { line: string; area: string } {
890
+ if (points.length === 0) return { line: "", area: "" };
891
+ const min = Math.min(...points);
892
+ const max = Math.max(...points);
893
+ const span = max - min || 1;
894
+ const stepX = points.length > 1 ? (w - pad * 2) / (points.length - 1) : 0;
895
+ const coords = points.map((p, i) => {
896
+ const x = pad + i * stepX;
897
+ const y = pad + (h - pad * 2) * (1 - (p - min) / span);
898
+ return [x, y] as const;
899
+ });
900
+ const line = coords.map(([x, y]) => `${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
901
+ const first = coords[0]!;
902
+ const last = coords[coords.length - 1]!;
903
+ const baseline = (h - pad).toFixed(1);
904
+ const through = coords.map(([x, y]) => `L${x.toFixed(1)},${y.toFixed(1)}`).join(" ");
905
+ const area = `M${first[0].toFixed(1)},${baseline} ${through} L${last[0].toFixed(1)},${baseline} Z`;
906
+ return { line, area };
907
+ }
908
+
909
+ /**
910
+ * KPI metric card with an inline SVG sparkline. Shows a label, a big value, a
911
+ * trend delta (up = amber, down = rose) and a pure-SVG sparkline drawn from a
912
+ * `points` series — no chart dependency. A `.mkt-card` with hover lift; tint
913
+ * selects the accent hue. Designed to sit in a Grid/StatGrid for a metrics row.
914
+ */
915
+ export const MetricCard: RendererComponent = (props) => {
916
+ const label = str(props["label"]);
917
+ const value = str(props["value"]) ?? "";
918
+ const delta = str(props["delta"]);
919
+ const trend = str(props["trend"]); // "up" | "down"
920
+ const down = trend === "down";
921
+ const tone = tintIndex(props["tone"], 0);
922
+ const points = Array.isArray(props["points"])
923
+ ? (props["points"] as unknown[]).map((p) => num(p)).filter((n): n is number => n != null)
924
+ : [];
925
+ const W = 120;
926
+ const H = 36;
927
+ const { line, area } = sparkline(points, W, H);
928
+ const stroke = [
929
+ "var(--marketing-accent)",
930
+ "var(--mk-accent-2)",
931
+ "var(--mk-accent-3)",
932
+ "var(--mk-accent-4)",
933
+ ][tone]!;
934
+
935
+ return (
936
+ <article className="mkt-card marketing flex flex-col p-5" data-uibot-type="MetricCard">
937
+ <div className="flex items-start justify-between gap-3">
938
+ {label && (
939
+ <span className="font-[family-name:var(--font-marketing-mono)] text-xs uppercase tracking-[0.14em] text-muted-foreground">
940
+ {label}
941
+ </span>
942
+ )}
943
+ {delta && (
944
+ <span
945
+ className={cn(
946
+ "inline-flex items-center gap-0.5 rounded-full px-2 py-0.5 text-xs font-semibold",
947
+ down
948
+ ? "bg-[color-mix(in_oklch,var(--mk-accent-3)_16%,transparent)] text-[var(--mk-accent-3)]"
949
+ : "bg-[color-mix(in_oklch,var(--marketing-accent)_18%,transparent)] text-[var(--marketing-accent)]",
950
+ )}
951
+ >
952
+ <svg
953
+ viewBox="0 0 24 24"
954
+ fill="none"
955
+ stroke="currentColor"
956
+ strokeWidth={2.4}
957
+ strokeLinecap="round"
958
+ strokeLinejoin="round"
959
+ className={cn("size-3", down && "rotate-180")}
960
+ aria-hidden="true"
961
+ >
962
+ <path d="M12 19V5M6 11l6-6 6 6" />
963
+ </svg>
964
+ {delta}
965
+ </span>
966
+ )}
967
+ </div>
968
+ <span className="mt-3 mkt-display text-3xl md:text-4xl">{value}</span>
969
+ {line && (
970
+ <svg
971
+ viewBox={`0 0 ${W} ${H}`}
972
+ className="mt-4 h-9 w-full"
973
+ preserveAspectRatio="none"
974
+ aria-hidden="true"
975
+ >
976
+ <path d={area} fill={stroke} opacity={0.12} />
977
+ <polyline
978
+ points={line}
979
+ fill="none"
980
+ stroke={stroke}
981
+ strokeWidth={1.6}
982
+ strokeLinecap="round"
983
+ strokeLinejoin="round"
984
+ vectorEffect="non-scaling-stroke"
985
+ />
986
+ </svg>
987
+ )}
988
+ </article>
989
+ );
990
+ };
991
+
992
+ // ── GalleryGrid ──────────────────────────────────────────────────────────────────
993
+
994
+ interface GalleryItem {
995
+ src?: string | undefined;
996
+ caption?: string | undefined;
997
+ tone?: unknown;
998
+ wide?: boolean | undefined;
999
+ }
1000
+
1001
+ function parseGalleryItems(raw: unknown): GalleryItem[] {
1002
+ return records(raw).map((g) => ({
1003
+ src: str(g["src"]),
1004
+ caption: str(g["caption"]),
1005
+ tone: g["tone"],
1006
+ wide: Boolean(g["wide"]),
1007
+ }));
1008
+ }
1009
+
1010
+ const GALLERY_COLS: Record<string, string> = {
1011
+ "2": "sm:grid-cols-2",
1012
+ "3": "sm:grid-cols-2 lg:grid-cols-3",
1013
+ "4": "sm:grid-cols-2 lg:grid-cols-4",
1014
+ };
1015
+
1016
+ /**
1017
+ * Caption gallery grid. Lays image tiles (or, with no `src`, a tinted blueprint
1018
+ * placeholder) onto a responsive grid; an item may opt into `wide` to span two
1019
+ * columns for a mixed-rhythm mosaic. Captions sit on a gradient scrim over each
1020
+ * tile. Hairline framing, hover lift. No external images required.
1021
+ */
1022
+ export const GalleryGrid: RendererComponent = (props) => {
1023
+ const items = parseGalleryItems(props["items"]);
1024
+ const cols = String(props["columns"] ?? "3");
1025
+ const colsCls = GALLERY_COLS[cols] ?? GALLERY_COLS["3"];
1026
+
1027
+ return (
1028
+ <section className="marketing mx-auto max-w-6xl px-6 md:px-0" data-uibot-type="GalleryGrid">
1029
+ <div className={cn("grid grid-cols-1 gap-4 [grid-auto-rows:minmax(11rem,1fr)]", colsCls)}>
1030
+ {items.map((g, i) => {
1031
+ const tone = tintIndex(g.tone, i % 4);
1032
+ const isUrl = g.src && /^(https?:|data:|\/)/.test(g.src);
1033
+ return (
1034
+ <figure
1035
+ key={i}
1036
+ className={cn(
1037
+ "mkt-card group/g relative overflow-hidden p-0",
1038
+ g.wide && "sm:col-span-2",
1039
+ )}
1040
+ >
1041
+ {isUrl ? (
1042
+ // eslint-disable-next-line @next/next/no-img-element
1043
+ <img
1044
+ src={g.src}
1045
+ alt={g.caption ?? ""}
1046
+ className="h-full w-full object-cover transition-transform duration-300 group-hover/g:scale-[1.03]"
1047
+ />
1048
+ ) : (
1049
+ <div
1050
+ className={cn(
1051
+ "flex h-full w-full items-center justify-center mkt-tint [background-image:radial-gradient(color-mix(in_oklch,var(--border)_75%,transparent)_1px,transparent_1px)] [background-size:16px_16px]",
1052
+ `mkt-tint-${tone}`,
1053
+ )}
1054
+ >
1055
+ <Icon name="boxes" className="size-8 opacity-60" />
1056
+ </div>
1057
+ )}
1058
+ {g.caption && (
1059
+ <figcaption className="absolute inset-x-0 bottom-0 bg-gradient-to-t from-[color-mix(in_oklch,var(--foreground)_55%,transparent)] to-transparent px-4 pb-3 pt-10 text-sm font-medium text-background">
1060
+ {g.caption}
1061
+ </figcaption>
1062
+ )}
1063
+ </figure>
1064
+ );
1065
+ })}
1066
+ </div>
1067
+ </section>
1068
+ );
1069
+ };