@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,435 @@
1
+ import type { ReactNode } from "react";
2
+ import type { RendererComponent } from "@uibot/renderer-react";
3
+
4
+ /**
5
+ * Premium "Schematic Editorial" presentation blocks.
6
+ *
7
+ * These are layout-only marketing primitives (Hero, SectionHeader, FeatureGrid,
8
+ * FeatureCard, CodeShowcase, CtaBand). They lean on the `.mkt-*` design-system
9
+ * classes defined in `apps/studio/src/styles.css` (serif display font, mono
10
+ * eyebrow/section numbers, hairline cards, warm amber accent, grain + dot-grid
11
+ * hero backdrop, staggered reveal). Like the rest of blocks-studio they ship
12
+ * with **zero third-party runtime deps** — lucide icon *names* map onto a small
13
+ * inline-SVG set rather than pulling in `lucide-react`.
14
+ *
15
+ * CTA props ({label, href}) render as accessible anchors styled as button /
16
+ * outline; everything else (rich Link blocks, etc.) stays the host spec's job.
17
+ */
18
+
19
+ function cn(...cls: (string | false | null | undefined)[]): string {
20
+ return cls.filter(Boolean).join(" ");
21
+ }
22
+
23
+ function str(v: unknown): string | undefined {
24
+ return typeof v === "string" && v.length > 0 ? v : undefined;
25
+ }
26
+
27
+ interface Cta {
28
+ label: string;
29
+ href: string;
30
+ }
31
+
32
+ function parseCta(raw: unknown): Cta | undefined {
33
+ if (!raw || typeof raw !== "object") return undefined;
34
+ const rec = raw as Record<string, unknown>;
35
+ const label = str(rec["label"]);
36
+ const href = str(rec["href"]);
37
+ if (!label) return undefined;
38
+ return { label, href: href ?? "#" };
39
+ }
40
+
41
+ // ── Inline icon set (lucide-compatible names, no runtime dep) ──────────────────
42
+
43
+ // Minimal stroke icons keyed by lucide name. Unknown names fall back to a dot,
44
+ // so the block never throws on an unmapped icon.
45
+ const ICON_PATHS: Record<string, ReactNode> = {
46
+ 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" />,
47
+ zap: <path d="M13 2 4 14h7l-1 8 9-12h-7z" />,
48
+ layers: (
49
+ <>
50
+ <path d="m12 3 9 5-9 5-9-5 9-5z" />
51
+ <path d="m3 12 9 5 9-5" />
52
+ </>
53
+ ),
54
+ boxes: (
55
+ <>
56
+ <rect x="3" y="3" width="7" height="7" rx="1" />
57
+ <rect x="14" y="3" width="7" height="7" rx="1" />
58
+ <rect x="8.5" y="14" width="7" height="7" rx="1" />
59
+ </>
60
+ ),
61
+ code: <path d="m8 6-6 6 6 6M16 6l6 6-6 6" />,
62
+ cpu: (
63
+ <>
64
+ <rect x="6" y="6" width="12" height="12" rx="2" />
65
+ <path d="M9 1v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3" />
66
+ </>
67
+ ),
68
+ workflow: (
69
+ <>
70
+ <rect x="3" y="3" width="7" height="7" rx="1" />
71
+ <rect x="14" y="14" width="7" height="7" rx="1" />
72
+ <path d="M10 6.5h6a2 2 0 0 1 2 2V14" />
73
+ </>
74
+ ),
75
+ gauge: (
76
+ <>
77
+ <path d="M3 14a9 9 0 1 1 18 0" />
78
+ <path d="m13 12-3 3" />
79
+ </>
80
+ ),
81
+ shield: <path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z" />,
82
+ wand: <path d="m15 4 5 5M4 20 14 10M9 4l1 2 2 1-2 1-1 2-1-2-2-1 2-1z" />,
83
+ };
84
+
85
+ function Icon({ name }: { name?: string | undefined }): React.ReactElement {
86
+ const path = (name && ICON_PATHS[name.toLowerCase()]) || <circle cx="12" cy="12" r="3" />;
87
+ return (
88
+ <svg
89
+ viewBox="0 0 24 24"
90
+ fill="none"
91
+ stroke="currentColor"
92
+ strokeWidth={1.6}
93
+ strokeLinecap="round"
94
+ strokeLinejoin="round"
95
+ className="size-5"
96
+ aria-hidden="true"
97
+ >
98
+ {path}
99
+ </svg>
100
+ );
101
+ }
102
+
103
+ // ── Shared CTA anchor ──────────────────────────────────────────────────────────
104
+
105
+ function CtaLink({
106
+ cta,
107
+ variant,
108
+ }: {
109
+ cta: Cta;
110
+ variant: "primary" | "outline" | "inverse";
111
+ }): React.ReactElement {
112
+ const base =
113
+ "inline-flex items-center justify-center gap-2 rounded-md px-5 py-2.5 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2";
114
+ const variants: Record<typeof variant, string> = {
115
+ primary:
116
+ "bg-[var(--marketing-accent)] text-[var(--marketing-accent-foreground)] hover:bg-[var(--marketing-accent-strong)] focus-visible:ring-[var(--marketing-accent)]",
117
+ outline:
118
+ "border border-border bg-transparent text-foreground hover:border-[var(--marketing-accent)] hover:text-[var(--marketing-accent)] focus-visible:ring-border",
119
+ inverse:
120
+ "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)]",
121
+ };
122
+ return (
123
+ <a href={cta.href} className={cn(base, variants[variant])}>
124
+ {cta.label}
125
+ </a>
126
+ );
127
+ }
128
+
129
+ // ── Hero ────────────────────────────────────────────────────────────────────
130
+
131
+ /**
132
+ * Asymmetric editorial hero. Serif display title (with optional italic emphasis
133
+ * via the `titleEmphasis` prop), mono eyebrow with amber dot, warm radial glow +
134
+ * blueprint dot grid backdrop, grain overlay, and staggered reveal. Renders an
135
+ * optional spec/preview visual on the right via the `aside` slot or children.
136
+ */
137
+ export const Hero: RendererComponent = (props, ctx) => {
138
+ const eyebrow = str(props["eyebrow"]);
139
+ const title = str(props["title"]) ?? "";
140
+ const titleEmphasis = str(props["titleEmphasis"]);
141
+ const subtitle = str(props["subtitle"]);
142
+ const note = str(props["note"]);
143
+ const primary = parseCta(props["primaryCta"]);
144
+ const secondary = parseCta(props["secondaryCta"]);
145
+ const aside = (ctx.slots["aside"] as ReactNode[] | undefined) ?? (ctx.children as ReactNode[]);
146
+
147
+ return (
148
+ <section
149
+ className="marketing mkt-hero relative px-6 py-20 md:px-10 md:py-28"
150
+ data-uibot-type="Hero"
151
+ >
152
+ <span className="mkt-hero-backdrop" aria-hidden="true" />
153
+ <span className="mkt-grain" aria-hidden="true" />
154
+ <div className="mx-auto grid max-w-6xl items-center gap-12 md:grid-cols-[1.15fr_0.85fr]">
155
+ <div className="max-w-2xl">
156
+ {eyebrow && <p className="mkt-eyebrow mkt-reveal mkt-reveal-1">{eyebrow}</p>}
157
+ <h1 className="mkt-reveal mkt-reveal-2 mt-5 text-5xl md:text-7xl">
158
+ {title}
159
+ {titleEmphasis && (
160
+ <>
161
+ {" "}
162
+ <span className="mkt-display-italic text-[var(--marketing-accent)]">
163
+ {titleEmphasis}
164
+ </span>
165
+ </>
166
+ )}
167
+ </h1>
168
+ {subtitle && (
169
+ <p className="mkt-reveal mkt-reveal-3 mt-6 max-w-xl text-lg leading-relaxed text-muted-foreground">
170
+ {subtitle}
171
+ </p>
172
+ )}
173
+ {(primary || secondary) && (
174
+ <div className="mkt-reveal mkt-reveal-4 mt-8 flex flex-wrap items-center gap-3">
175
+ {primary && <CtaLink cta={primary} variant="primary" />}
176
+ {secondary && <CtaLink cta={secondary} variant="outline" />}
177
+ </div>
178
+ )}
179
+ {note && (
180
+ <p className="mkt-reveal mkt-reveal-5 mt-6 font-[family-name:var(--font-marketing-mono)] text-xs uppercase tracking-[0.18em] text-muted-foreground">
181
+ {note}
182
+ </p>
183
+ )}
184
+ </div>
185
+ {aside && aside.length > 0 && (
186
+ <div className="mkt-reveal mkt-reveal-4 hidden md:block">{aside}</div>
187
+ )}
188
+ </div>
189
+ </section>
190
+ );
191
+ };
192
+
193
+ // ── BrowserFrame ──────────────────────────────────────────────────────────────
194
+
195
+ /**
196
+ * Product-screenshot window shell. Frames its `content` slot (or children) in a
197
+ * precise browser/app chrome — three traffic-light dots + a mono title/address
198
+ * bar — with a hairline border, long soft shadow, and an optional subtle 3D tilt
199
+ * (`variant: "tilt"`). Used on the marketing surface to present a *live-rendered*
200
+ * UIBot UI as the hero/showcase visual: the platform renders a real product
201
+ * interface inside the frame instead of pasting a static screenshot (dogfood).
202
+ *
203
+ * Pure layout + `.mkt-*` CSS — zero runtime deps. The framed content is whatever
204
+ * spec blocks the host drops into the `content` slot (StatGrid, TrendChart,
205
+ * SearchableTable, KanbanBoard, …), so it renders for real.
206
+ */
207
+ export const BrowserFrame: RendererComponent = (props, ctx) => {
208
+ const title = str(props["title"]);
209
+ const variant = str(props["variant"]); // "flat" (default) | "tilt"
210
+ const tone = str(props["tone"]); // accent index 0–3 for the chrome wash
211
+ const tintRaw = Number(tone);
212
+ const tint = Number.isFinite(tintRaw) ? ((tintRaw % 4) + 4) % 4 : 0;
213
+ const content =
214
+ (ctx.slots["content"] as ReactNode[] | undefined) ?? (ctx.children as ReactNode[]);
215
+
216
+ return (
217
+ <div
218
+ className={cn("mkt-frame marketing", variant === "tilt" && "mkt-frame-tilt")}
219
+ data-uibot-type="BrowserFrame"
220
+ >
221
+ <div className={cn("mkt-frame-chrome", `mkt-frame-tint-${tint}`)}>
222
+ <span className="mkt-frame-dot mkt-frame-dot-r" aria-hidden="true" />
223
+ <span className="mkt-frame-dot mkt-frame-dot-y" aria-hidden="true" />
224
+ <span className="mkt-frame-dot mkt-frame-dot-g" aria-hidden="true" />
225
+ <span className="mkt-frame-addr">{title ?? "app.uibot.studio"}</span>
226
+ </div>
227
+ <div className="mkt-frame-body">{content}</div>
228
+ </div>
229
+ );
230
+ };
231
+
232
+ // ── SectionHeader ──────────────────────────────────────────────────────────────
233
+
234
+ /** Oversized mono section number + serif title + lead paragraph. */
235
+ export const SectionHeader: RendererComponent = (props) => {
236
+ const sectionNo = str(props["sectionNo"]);
237
+ const eyebrow = str(props["eyebrow"]);
238
+ const title = str(props["title"]) ?? "";
239
+ const lead = str(props["lead"]);
240
+
241
+ return (
242
+ <header className="marketing mx-auto max-w-3xl px-6 md:px-0" data-uibot-type="SectionHeader">
243
+ <div className="flex items-baseline gap-4">
244
+ {sectionNo && <span className="mkt-sectno text-4xl md:text-5xl">{sectionNo}</span>}
245
+ <div>
246
+ {eyebrow && <p className="mkt-eyebrow">{eyebrow}</p>}
247
+ <h2 className="mt-2 text-3xl md:text-4xl">{title}</h2>
248
+ </div>
249
+ </div>
250
+ {lead && (
251
+ <p className="mt-4 max-w-2xl text-base leading-relaxed text-muted-foreground">{lead}</p>
252
+ )}
253
+ </header>
254
+ );
255
+ };
256
+
257
+ // ── FeatureGrid + FeatureCard ──────────────────────────────────────────────────
258
+
259
+ interface FeatureItem {
260
+ icon?: string | undefined;
261
+ title: string;
262
+ desc?: string | undefined;
263
+ }
264
+
265
+ function parseFeatureItems(raw: unknown): FeatureItem[] {
266
+ if (!Array.isArray(raw)) return [];
267
+ return raw
268
+ .filter((it): it is Record<string, unknown> => Boolean(it) && typeof it === "object")
269
+ .map((it) => ({
270
+ icon: str(it["icon"]),
271
+ title: str(it["title"]) ?? "",
272
+ desc: str(it["desc"]),
273
+ }));
274
+ }
275
+
276
+ const FEATURE_COLS: Record<string, string> = {
277
+ "2": "sm:grid-cols-2",
278
+ "3": "sm:grid-cols-2 lg:grid-cols-3",
279
+ "4": "sm:grid-cols-2 lg:grid-cols-4",
280
+ };
281
+
282
+ /**
283
+ * Responsive grid of hairline feature cards with hover lift. Accepts an `items`
284
+ * array (each → a FeatureCard) and/or rendered FeatureCard children.
285
+ */
286
+ export const FeatureGrid: RendererComponent = (props, ctx) => {
287
+ const items = parseFeatureItems(props["items"]);
288
+ const cols = String(props["cols"] ?? "3");
289
+ const colsCls = FEATURE_COLS[cols] ?? FEATURE_COLS["3"];
290
+ const children = ctx.children as ReactNode[];
291
+
292
+ return (
293
+ <div
294
+ className={cn("marketing mx-auto grid max-w-6xl gap-5 px-6 md:px-0 grid-cols-1", colsCls)}
295
+ data-uibot-type="FeatureGrid"
296
+ >
297
+ {children.length > 0
298
+ ? children
299
+ : items.map((it, i) => (
300
+ <article
301
+ key={i}
302
+ className={cn("mkt-card mkt-reveal p-6", `mkt-reveal-${Math.min(i + 1, 6)}`)}
303
+ >
304
+ <span
305
+ className={cn(
306
+ "inline-flex size-11 items-center justify-center rounded-lg border mkt-tint",
307
+ `mkt-tint-${i % 4}`,
308
+ )}
309
+ >
310
+ <Icon name={it.icon} />
311
+ </span>
312
+ <h3 className="mt-5 text-xl">{it.title}</h3>
313
+ {it.desc && (
314
+ <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{it.desc}</p>
315
+ )}
316
+ </article>
317
+ ))}
318
+ </div>
319
+ );
320
+ };
321
+
322
+ /** Single hairline feature card. Usable standalone inside a FeatureGrid. */
323
+ export const FeatureCard: RendererComponent = (props, ctx) => {
324
+ const icon = str(props["icon"]);
325
+ const title = str(props["title"]) ?? "";
326
+ const desc = str(props["desc"]);
327
+ // Optional `tint` (0–3) selects one of the four accent hues for the icon wash;
328
+ // when standalone it defaults to the amber accent (tier 0).
329
+ const tintRaw = Number(props["tint"]);
330
+ const tint = Number.isFinite(tintRaw) ? ((tintRaw % 4) + 4) % 4 : 0;
331
+ const children = ctx.children as ReactNode[];
332
+
333
+ return (
334
+ <article className="mkt-card marketing p-6" data-uibot-type="FeatureCard">
335
+ <span
336
+ className={cn(
337
+ "inline-flex size-11 items-center justify-center rounded-lg border mkt-tint",
338
+ `mkt-tint-${tint}`,
339
+ )}
340
+ >
341
+ <Icon name={icon} />
342
+ </span>
343
+ <h3 className="mt-5 text-xl">{title}</h3>
344
+ {desc && <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{desc}</p>}
345
+ {children.length > 0 && <div className="mt-4">{children}</div>}
346
+ </article>
347
+ );
348
+ };
349
+
350
+ // ── CodeShowcase ──────────────────────────────────────────────────────────────
351
+
352
+ /**
353
+ * Mono code panel with window chrome (three dots) + line numbers — used to show
354
+ * a UIBot YAML/JSON spec. Pure CSS, no syntax highlighter dependency.
355
+ */
356
+ export const CodeShowcase: RendererComponent = (props) => {
357
+ const title = str(props["title"]);
358
+ const code = str(props["code"]) ?? "";
359
+ const caption = str(props["caption"]);
360
+ const lines = code.replace(/\n$/, "").split("\n");
361
+
362
+ return (
363
+ <figure className="marketing mx-auto max-w-3xl px-6 md:px-0" data-uibot-type="CodeShowcase">
364
+ <div className="mkt-card overflow-hidden p-0">
365
+ <div className="flex items-center gap-2 border-b border-border bg-muted/40 px-4 py-2.5">
366
+ <span className="size-2.5 rounded-full bg-[color-mix(in_oklch,var(--destructive)_70%,transparent)]" />
367
+ <span className="size-2.5 rounded-full bg-[color-mix(in_oklch,var(--warning)_80%,transparent)]" />
368
+ <span className="size-2.5 rounded-full bg-[color-mix(in_oklch,var(--success)_70%,transparent)]" />
369
+ {title && (
370
+ <span className="ml-3 font-[family-name:var(--font-marketing-mono)] text-xs text-muted-foreground">
371
+ {title}
372
+ </span>
373
+ )}
374
+ </div>
375
+ <pre className="overflow-x-auto bg-card px-0 py-4 text-[0.8125rem] leading-relaxed">
376
+ <code className="font-[family-name:var(--font-marketing-mono)]">
377
+ {lines.map((line, i) => (
378
+ <div key={i} className="grid grid-cols-[2.5rem_1fr] hover:bg-muted/30">
379
+ <span className="select-none px-2 text-right text-muted-foreground/50 tabular-nums">
380
+ {i + 1}
381
+ </span>
382
+ <span className="whitespace-pre px-2 text-foreground">{line || " "}</span>
383
+ </div>
384
+ ))}
385
+ </code>
386
+ </pre>
387
+ </div>
388
+ {caption && (
389
+ <figcaption className="mt-3 text-center text-sm text-muted-foreground">
390
+ {caption}
391
+ </figcaption>
392
+ )}
393
+ </figure>
394
+ );
395
+ };
396
+
397
+ // ── CtaBand ──────────────────────────────────────────────────────────────────
398
+
399
+ /** Inverted ink-black panel with a single amber CTA. */
400
+ export const CtaBand: RendererComponent = (props) => {
401
+ const title = str(props["title"]) ?? "";
402
+ const subtitle = str(props["subtitle"]);
403
+ const cta = parseCta(props["cta"]);
404
+
405
+ return (
406
+ <section className="marketing mx-auto max-w-6xl px-6 md:px-0" data-uibot-type="CtaBand">
407
+ <div className="mkt-hero relative overflow-hidden rounded-2xl bg-foreground px-8 py-14 text-background md:px-14">
408
+ {/* Warm amber → rose gradient glow on the inverted ink panel for a hit
409
+ of colour and energy without overpowering the high-contrast type. */}
410
+ <span
411
+ aria-hidden="true"
412
+ className="pointer-events-none absolute inset-0"
413
+ style={{
414
+ background:
415
+ "radial-gradient(60% 120% at 12% 0%, color-mix(in oklch, var(--marketing-accent) 30%, transparent) 0%, transparent 55%), radial-gradient(60% 120% at 100% 100%, color-mix(in oklch, var(--mk-accent-3) 26%, transparent) 0%, transparent 55%)",
416
+ }}
417
+ />
418
+ <span className="mkt-grain" aria-hidden="true" />
419
+ <div className="relative flex flex-col items-start gap-6 md:flex-row md:items-center md:justify-between">
420
+ <div className="max-w-xl">
421
+ <h2 className="text-3xl md:text-4xl">{title}</h2>
422
+ {subtitle && (
423
+ <p className="mt-3 text-base leading-relaxed text-background/70">{subtitle}</p>
424
+ )}
425
+ </div>
426
+ {cta && (
427
+ <div className="shrink-0">
428
+ <CtaLink cta={cta} variant="inverse" />
429
+ </div>
430
+ )}
431
+ </div>
432
+ </div>
433
+ </section>
434
+ );
435
+ };