@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.
- package/dist/blocks/charts.d.ts +9 -0
- package/dist/blocks/content.d.ts +40 -0
- package/dist/blocks/data-studio.d.ts +18 -0
- package/dist/blocks/grid.d.ts +7 -0
- package/dist/blocks/interactive.d.ts +27 -0
- package/dist/blocks/kanban.d.ts +9 -0
- package/dist/blocks/marketing.d.ts +36 -0
- package/dist/blocks/presentation.d.ts +37 -0
- package/dist/blocks/sections.d.ts +74 -0
- package/dist/catalog.d.ts +8 -0
- package/dist/catalog.js +2 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.js +3 -0
- package/dist/registry-source.d.ts +21 -0
- package/dist/registry-source.js +21 -0
- package/package.json +51 -4
- package/src/blocks/charts.tsx +140 -0
- package/src/blocks/content.tsx +637 -0
- package/src/blocks/data-studio.tsx +293 -0
- package/src/blocks/grid.tsx +62 -0
- package/src/blocks/interactive.tsx +374 -0
- package/src/blocks/kanban.tsx +150 -0
- package/src/blocks/marketing.tsx +531 -0
- package/src/blocks/presentation.tsx +435 -0
- package/src/blocks/sections.tsx +1069 -0
- package/README.md +0 -3
|
@@ -0,0 +1,637 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RendererComponent } from "@uibot/renderer-react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* "Schematic Editorial" content / layout blocks.
|
|
6
|
+
*
|
|
7
|
+
* A second tranche of marketing/layout primitives (Faq, TeamGrid, Steps,
|
|
8
|
+
* BentoGrid + BentoCell, Callout) that broaden UIBot's catalog toward the block
|
|
9
|
+
* breadth of design-system kits while staying **original** implementations.
|
|
10
|
+
*
|
|
11
|
+
* Design rules these follow:
|
|
12
|
+
* ① Work in any context off the core theme tokens (foreground / muted /
|
|
13
|
+
* border / primary / card); under a `.marketing` scope they pick up the
|
|
14
|
+
* brand serif/mono fonts, hairline `.mkt-card` material and accent washes
|
|
15
|
+
* defined in `apps/studio/src/styles.css`.
|
|
16
|
+
* ② Light + dark via tokens / `color-mix` (no hard-coded colours).
|
|
17
|
+
* ③ Pure SVG / CSS — zero new npm dependencies (icons map to a small inline
|
|
18
|
+
* SVG set, identical to presentation.tsx so specs share icon names).
|
|
19
|
+
* ④ Each ships a full CatalogEntry (see ./catalog.ts).
|
|
20
|
+
*
|
|
21
|
+
* Bento span classes use a static lookup table (BENTO_COL_SPAN / BENTO_ROW_SPAN)
|
|
22
|
+
* so Tailwind's JIT never purges a dynamically-built `col-span-${n}` class —
|
|
23
|
+
* mirroring the COLS map in ./grid.tsx.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
function cn(...cls: (string | false | null | undefined)[]): string {
|
|
27
|
+
return cls.filter(Boolean).join(" ");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function str(v: unknown): string | undefined {
|
|
31
|
+
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function records(raw: unknown): Record<string, unknown>[] {
|
|
35
|
+
if (!Array.isArray(raw)) return [];
|
|
36
|
+
return raw.filter((it): it is Record<string, unknown> => Boolean(it) && typeof it === "object");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Clamp a 0-based accent index into the four-hue tint palette (0..3). */
|
|
40
|
+
function tintIndex(raw: unknown, fallback = 0): number {
|
|
41
|
+
const n = Number(raw);
|
|
42
|
+
return Number.isFinite(n) ? ((Math.trunc(n) % 4) + 4) % 4 : fallback;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ── Inline icon set (lucide-compatible names, no runtime dep) ──────────────────
|
|
46
|
+
// Mirrors presentation.tsx so specs can reuse the same icon vocabulary; unknown
|
|
47
|
+
// names fall back to a dot so a block never throws on an unmapped icon.
|
|
48
|
+
|
|
49
|
+
const ICON_PATHS: Record<string, ReactNode> = {
|
|
50
|
+
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" />,
|
|
51
|
+
zap: <path d="M13 2 4 14h7l-1 8 9-12h-7z" />,
|
|
52
|
+
layers: (
|
|
53
|
+
<>
|
|
54
|
+
<path d="m12 3 9 5-9 5-9-5 9-5z" />
|
|
55
|
+
<path d="m3 12 9 5 9-5" />
|
|
56
|
+
</>
|
|
57
|
+
),
|
|
58
|
+
boxes: (
|
|
59
|
+
<>
|
|
60
|
+
<rect x="3" y="3" width="7" height="7" rx="1" />
|
|
61
|
+
<rect x="14" y="3" width="7" height="7" rx="1" />
|
|
62
|
+
<rect x="8.5" y="14" width="7" height="7" rx="1" />
|
|
63
|
+
</>
|
|
64
|
+
),
|
|
65
|
+
code: <path d="m8 6-6 6 6 6M16 6l6 6-6 6" />,
|
|
66
|
+
cpu: (
|
|
67
|
+
<>
|
|
68
|
+
<rect x="6" y="6" width="12" height="12" rx="2" />
|
|
69
|
+
<path d="M9 1v3M15 1v3M9 20v3M15 20v3M1 9h3M1 15h3M20 9h3M20 15h3" />
|
|
70
|
+
</>
|
|
71
|
+
),
|
|
72
|
+
workflow: (
|
|
73
|
+
<>
|
|
74
|
+
<rect x="3" y="3" width="7" height="7" rx="1" />
|
|
75
|
+
<rect x="14" y="14" width="7" height="7" rx="1" />
|
|
76
|
+
<path d="M10 6.5h6a2 2 0 0 1 2 2V14" />
|
|
77
|
+
</>
|
|
78
|
+
),
|
|
79
|
+
gauge: (
|
|
80
|
+
<>
|
|
81
|
+
<path d="M3 14a9 9 0 1 1 18 0" />
|
|
82
|
+
<path d="m13 12-3 3" />
|
|
83
|
+
</>
|
|
84
|
+
),
|
|
85
|
+
shield: <path d="M12 3l8 3v6c0 5-3.5 8-8 9-4.5-1-8-4-8-9V6z" />,
|
|
86
|
+
wand: <path d="m15 4 5 5M4 20 14 10M9 4l1 2 2 1-2 1-1 2-1-2-2-1 2-1z" />,
|
|
87
|
+
info: (
|
|
88
|
+
<>
|
|
89
|
+
<circle cx="12" cy="12" r="9" />
|
|
90
|
+
<path d="M12 11v5M12 7.5h.01" />
|
|
91
|
+
</>
|
|
92
|
+
),
|
|
93
|
+
check: <path d="m20 6-11 11-5-5" />,
|
|
94
|
+
alert: (
|
|
95
|
+
<>
|
|
96
|
+
<path d="M12 3 2 20h20L12 3z" />
|
|
97
|
+
<path d="M12 10v4M12 17.5h.01" />
|
|
98
|
+
</>
|
|
99
|
+
),
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
function Icon({
|
|
103
|
+
name,
|
|
104
|
+
className = "size-5",
|
|
105
|
+
}: {
|
|
106
|
+
name?: string | undefined;
|
|
107
|
+
className?: string;
|
|
108
|
+
}): React.ReactElement {
|
|
109
|
+
const path = (name && ICON_PATHS[name.toLowerCase()]) || <circle cx="12" cy="12" r="3" />;
|
|
110
|
+
return (
|
|
111
|
+
<svg
|
|
112
|
+
viewBox="0 0 24 24"
|
|
113
|
+
fill="none"
|
|
114
|
+
stroke="currentColor"
|
|
115
|
+
strokeWidth={1.6}
|
|
116
|
+
strokeLinecap="round"
|
|
117
|
+
strokeLinejoin="round"
|
|
118
|
+
className={className}
|
|
119
|
+
aria-hidden="true"
|
|
120
|
+
>
|
|
121
|
+
{path}
|
|
122
|
+
</svg>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ── Faq ────────────────────────────────────────────────────────────────────────
|
|
127
|
+
|
|
128
|
+
interface FaqItem {
|
|
129
|
+
q: string;
|
|
130
|
+
a: string;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function parseFaqItems(raw: unknown): FaqItem[] {
|
|
134
|
+
return records(raw)
|
|
135
|
+
.map((it) => ({ q: str(it["q"]) ?? "", a: str(it["a"]) ?? "" }))
|
|
136
|
+
.filter((it) => it.q.length > 0);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
const FAQ_MONO = { fontFamily: "var(--font-marketing-mono)" } as const;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Accordion FAQ list, editorial style. Uses native <details>/<summary> so it is
|
|
143
|
+
* fully functional with zero JS / zero state wiring (works in any host,
|
|
144
|
+
* including static render). Each row carries a mono index numeral; a hairline
|
|
145
|
+
* plus-mark rotates 45° into a close-mark on open, and the answer expands via
|
|
146
|
+
* a grid-rows transition. `defaultOpenFirst` opens the first row on mount.
|
|
147
|
+
*/
|
|
148
|
+
export const Faq: RendererComponent = (props) => {
|
|
149
|
+
const eyebrow = str(props["eyebrow"]);
|
|
150
|
+
const title = str(props["title"]);
|
|
151
|
+
const lead = str(props["lead"]);
|
|
152
|
+
const defaultOpenFirst = props["defaultOpenFirst"] === true;
|
|
153
|
+
const items = parseFaqItems(props["items"]);
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<section className="marketing mx-auto max-w-3xl px-6 md:px-0" data-uibot-type="Faq">
|
|
157
|
+
{(eyebrow || title || lead) && (
|
|
158
|
+
<header className="mb-8 md:mb-10">
|
|
159
|
+
{eyebrow && (
|
|
160
|
+
<p
|
|
161
|
+
className="text-[0.65rem] uppercase tracking-[0.28em] text-[var(--marketing-accent)]"
|
|
162
|
+
style={FAQ_MONO}
|
|
163
|
+
>
|
|
164
|
+
{eyebrow}
|
|
165
|
+
</p>
|
|
166
|
+
)}
|
|
167
|
+
{title && <h2 className="mt-3 text-3xl md:text-4xl">{title}</h2>}
|
|
168
|
+
{lead && (
|
|
169
|
+
<p className="mt-3 max-w-xl text-sm leading-relaxed text-muted-foreground">{lead}</p>
|
|
170
|
+
)}
|
|
171
|
+
</header>
|
|
172
|
+
)}
|
|
173
|
+
<div className="border-t border-border/70">
|
|
174
|
+
{items.map((it, i) => (
|
|
175
|
+
<details
|
|
176
|
+
key={i}
|
|
177
|
+
className="group border-b border-border/70 [&_summary::-webkit-details-marker]:hidden"
|
|
178
|
+
open={defaultOpenFirst && i === 0 ? true : undefined}
|
|
179
|
+
>
|
|
180
|
+
<summary className="flex cursor-pointer list-none items-baseline gap-4 py-5 md:gap-6">
|
|
181
|
+
<span
|
|
182
|
+
aria-hidden="true"
|
|
183
|
+
className="w-7 shrink-0 text-[0.65rem] tracking-[0.18em] text-muted-foreground/60 transition-colors duration-200 group-open:text-[var(--marketing-accent)]"
|
|
184
|
+
style={FAQ_MONO}
|
|
185
|
+
>
|
|
186
|
+
{String(i + 1).padStart(2, "0")}
|
|
187
|
+
</span>
|
|
188
|
+
<span className="flex-1 text-base font-medium text-foreground/90 transition-colors duration-200 group-hover:text-foreground group-open:text-foreground md:text-lg">
|
|
189
|
+
{it.q}
|
|
190
|
+
</span>
|
|
191
|
+
<span
|
|
192
|
+
aria-hidden="true"
|
|
193
|
+
className="relative mt-1 size-3.5 shrink-0 self-center text-muted-foreground/70 transition-transform duration-300 ease-out group-hover:text-foreground group-open:rotate-45 group-open:text-[var(--marketing-accent)]"
|
|
194
|
+
>
|
|
195
|
+
<span className="absolute left-0 top-1/2 h-px w-full -translate-y-1/2 bg-current" />
|
|
196
|
+
<span className="absolute left-1/2 top-0 h-full w-px -translate-x-1/2 bg-current" />
|
|
197
|
+
</span>
|
|
198
|
+
</summary>
|
|
199
|
+
{it.a && (
|
|
200
|
+
<div className="grid grid-rows-[0fr] transition-[grid-template-rows] duration-300 ease-out group-open:grid-rows-[1fr]">
|
|
201
|
+
<div className="overflow-hidden">
|
|
202
|
+
<p className="pb-6 pl-11 pr-2 text-sm leading-relaxed text-muted-foreground md:pl-[3.25rem]">
|
|
203
|
+
{it.a}
|
|
204
|
+
</p>
|
|
205
|
+
</div>
|
|
206
|
+
</div>
|
|
207
|
+
)}
|
|
208
|
+
</details>
|
|
209
|
+
))}
|
|
210
|
+
</div>
|
|
211
|
+
</section>
|
|
212
|
+
);
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// ── TeamGrid ────────────────────────────────────────────────────────────────────
|
|
216
|
+
|
|
217
|
+
interface TeamMember {
|
|
218
|
+
name: string;
|
|
219
|
+
role?: string | undefined;
|
|
220
|
+
bio?: string | undefined;
|
|
221
|
+
avatar?: string | undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function parseMembers(raw: unknown): TeamMember[] {
|
|
225
|
+
return records(raw)
|
|
226
|
+
.map((it) => ({
|
|
227
|
+
name: str(it["name"]) ?? "",
|
|
228
|
+
role: str(it["role"]),
|
|
229
|
+
bio: str(it["bio"]),
|
|
230
|
+
avatar: str(it["avatar"]),
|
|
231
|
+
}))
|
|
232
|
+
.filter((it) => it.name.length > 0);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const TEAM_COLS: Record<string, string> = {
|
|
236
|
+
"2": "sm:grid-cols-2",
|
|
237
|
+
"3": "sm:grid-cols-2 lg:grid-cols-3",
|
|
238
|
+
"4": "sm:grid-cols-2 lg:grid-cols-4",
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/** Derive up-to-two-letter initials from a member name for the avatar fallback. */
|
|
242
|
+
function initials(name: string): string {
|
|
243
|
+
const parts = name.trim().split(/\s+/).filter(Boolean);
|
|
244
|
+
if (parts.length === 0) return "?";
|
|
245
|
+
if (parts.length === 1) return parts[0]!.slice(0, 2).toUpperCase();
|
|
246
|
+
return (parts[0]![0]! + parts[parts.length - 1]![0]!).toUpperCase();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Grid of team member cards. Each card shows an avatar (an image when `avatar`
|
|
251
|
+
* is a URL, otherwise tinted initials), name, role and optional bio. Hairline
|
|
252
|
+
* `.mkt-card` material with hover lift under `.marketing`.
|
|
253
|
+
*/
|
|
254
|
+
export const TeamGrid: RendererComponent = (props) => {
|
|
255
|
+
const members = parseMembers(props["members"]);
|
|
256
|
+
const cols = String(props["columns"] ?? "3");
|
|
257
|
+
const colsCls = TEAM_COLS[cols] ?? TEAM_COLS["3"];
|
|
258
|
+
|
|
259
|
+
return (
|
|
260
|
+
<div
|
|
261
|
+
className={cn("marketing mx-auto grid max-w-6xl grid-cols-1 gap-5 px-6 md:px-0", colsCls)}
|
|
262
|
+
data-uibot-type="TeamGrid"
|
|
263
|
+
>
|
|
264
|
+
{members.map((m, i) => {
|
|
265
|
+
const isUrl = m.avatar && /^(https?:|data:|\/)/.test(m.avatar);
|
|
266
|
+
return (
|
|
267
|
+
<article
|
|
268
|
+
key={i}
|
|
269
|
+
className={cn(
|
|
270
|
+
"mkt-card mkt-reveal flex flex-col items-center p-6 text-center",
|
|
271
|
+
`mkt-reveal-${Math.min(i + 1, 6)}`,
|
|
272
|
+
)}
|
|
273
|
+
>
|
|
274
|
+
{isUrl ? (
|
|
275
|
+
// eslint-disable-next-line @next/next/no-img-element
|
|
276
|
+
<img src={m.avatar} alt={m.name} className="size-16 rounded-full object-cover" />
|
|
277
|
+
) : (
|
|
278
|
+
<span
|
|
279
|
+
className={cn(
|
|
280
|
+
"inline-flex size-16 items-center justify-center rounded-full border text-lg font-semibold mkt-tint",
|
|
281
|
+
`mkt-tint-${i % 4}`,
|
|
282
|
+
)}
|
|
283
|
+
>
|
|
284
|
+
{str(m.avatar) ?? initials(m.name)}
|
|
285
|
+
</span>
|
|
286
|
+
)}
|
|
287
|
+
<h3 className="mt-4 text-lg">{m.name}</h3>
|
|
288
|
+
{m.role && (
|
|
289
|
+
<p className="mt-1 font-[family-name:var(--font-marketing-mono)] text-xs uppercase tracking-[0.14em] text-[var(--marketing-accent)]">
|
|
290
|
+
{m.role}
|
|
291
|
+
</p>
|
|
292
|
+
)}
|
|
293
|
+
{m.bio && <p className="mt-3 text-sm leading-relaxed text-muted-foreground">{m.bio}</p>}
|
|
294
|
+
</article>
|
|
295
|
+
);
|
|
296
|
+
})}
|
|
297
|
+
</div>
|
|
298
|
+
);
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
// ── Steps ────────────────────────────────────────────────────────────────────
|
|
302
|
+
|
|
303
|
+
interface StepItem {
|
|
304
|
+
title: string;
|
|
305
|
+
desc?: string | undefined;
|
|
306
|
+
icon?: string | undefined;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
function parseSteps(raw: unknown): StepItem[] {
|
|
310
|
+
return records(raw)
|
|
311
|
+
.map((it) => ({
|
|
312
|
+
title: str(it["title"]) ?? "",
|
|
313
|
+
desc: str(it["desc"]),
|
|
314
|
+
icon: str(it["icon"]),
|
|
315
|
+
}))
|
|
316
|
+
.filter((it) => it.title.length > 0);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Big step numeral colours cycle through the four accent hues (amber / teal /
|
|
320
|
+
// rose / indigo) so a sequence reads as distinct stages.
|
|
321
|
+
const STEP_TONE: string[] = [
|
|
322
|
+
"var(--marketing-accent)",
|
|
323
|
+
"var(--mk-accent-2)",
|
|
324
|
+
"var(--mk-accent-3)",
|
|
325
|
+
"var(--mk-accent-4)",
|
|
326
|
+
];
|
|
327
|
+
|
|
328
|
+
// Column count derives from the step count (clamped 2–4) so a 4-stage pipeline
|
|
329
|
+
// fills one row instead of leaving an orphaned card (mirrors StatBand).
|
|
330
|
+
const STEP_COLS: Record<number, string> = {
|
|
331
|
+
2: "lg:grid-cols-2",
|
|
332
|
+
3: "lg:grid-cols-3",
|
|
333
|
+
4: "lg:grid-cols-2 xl:grid-cols-4",
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* "How it works" steps. Oversized mono numerals lead each step.
|
|
338
|
+
* - variant `numbered` (default): a responsive card row, each with a big number.
|
|
339
|
+
* - variant `connected`: a vertical rail with a connecting line between dots,
|
|
340
|
+
* reading top-to-bottom like a sequence.
|
|
341
|
+
*/
|
|
342
|
+
export const Steps: RendererComponent = (props) => {
|
|
343
|
+
const steps = parseSteps(props["steps"]);
|
|
344
|
+
const variant = str(props["variant"]) === "connected" ? "connected" : "numbered";
|
|
345
|
+
const num = (i: number) => String(i + 1).padStart(2, "0");
|
|
346
|
+
|
|
347
|
+
if (variant === "connected") {
|
|
348
|
+
return (
|
|
349
|
+
<ol className="marketing mx-auto max-w-3xl px-6 md:px-0" data-uibot-type="Steps">
|
|
350
|
+
{steps.map((s, i) => (
|
|
351
|
+
<li key={i} className="relative flex gap-5 pb-8 last:pb-0">
|
|
352
|
+
{i < steps.length - 1 && (
|
|
353
|
+
<span
|
|
354
|
+
aria-hidden="true"
|
|
355
|
+
className="absolute left-[1.375rem] top-12 bottom-0 w-px bg-border"
|
|
356
|
+
/>
|
|
357
|
+
)}
|
|
358
|
+
<span
|
|
359
|
+
className={cn(
|
|
360
|
+
"relative z-10 inline-flex size-11 shrink-0 items-center justify-center rounded-full border font-[family-name:var(--font-marketing-mono)] text-sm font-semibold tabular-nums mkt-tint",
|
|
361
|
+
`mkt-tint-${i % 4}`,
|
|
362
|
+
)}
|
|
363
|
+
>
|
|
364
|
+
{s.icon ? <Icon name={s.icon} /> : num(i)}
|
|
365
|
+
</span>
|
|
366
|
+
<div className="pt-1.5">
|
|
367
|
+
<h3 className="text-xl">{s.title}</h3>
|
|
368
|
+
{s.desc && (
|
|
369
|
+
<p className="mt-2 text-sm leading-relaxed text-muted-foreground">{s.desc}</p>
|
|
370
|
+
)}
|
|
371
|
+
</div>
|
|
372
|
+
</li>
|
|
373
|
+
))}
|
|
374
|
+
</ol>
|
|
375
|
+
);
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return (
|
|
379
|
+
<ol
|
|
380
|
+
className={cn(
|
|
381
|
+
"marketing mx-auto grid max-w-6xl grid-cols-1 gap-6 px-6 sm:grid-cols-2 md:px-0",
|
|
382
|
+
STEP_COLS[Math.min(Math.max(steps.length, 2), 4)] ?? "lg:grid-cols-3",
|
|
383
|
+
)}
|
|
384
|
+
data-uibot-type="Steps"
|
|
385
|
+
>
|
|
386
|
+
{steps.map((s, i) => (
|
|
387
|
+
<li key={i} className={cn("mkt-card mkt-reveal p-6", `mkt-reveal-${Math.min(i + 1, 6)}`)}>
|
|
388
|
+
<span
|
|
389
|
+
className="mkt-sectno block text-5xl md:text-6xl"
|
|
390
|
+
style={{ color: STEP_TONE[i % 4] }}
|
|
391
|
+
>
|
|
392
|
+
{num(i)}
|
|
393
|
+
</span>
|
|
394
|
+
<h3 className="mt-4 text-xl">{s.title}</h3>
|
|
395
|
+
{s.desc && <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{s.desc}</p>}
|
|
396
|
+
</li>
|
|
397
|
+
))}
|
|
398
|
+
</ol>
|
|
399
|
+
);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// ── BentoGrid + BentoCell ───────────────────────────────────────────────────────
|
|
403
|
+
|
|
404
|
+
// Static span lookup tables. Tailwind's JIT cannot see a runtime-built
|
|
405
|
+
// `col-span-${n}` token, so we map clamped 1–4 spans to literal class strings —
|
|
406
|
+
// the same defensive pattern as the COLS map in ./grid.tsx.
|
|
407
|
+
const BENTO_GRID_COLS: Record<string, string> = {
|
|
408
|
+
"2": "sm:grid-cols-2",
|
|
409
|
+
"3": "sm:grid-cols-2 lg:grid-cols-3",
|
|
410
|
+
"4": "sm:grid-cols-2 lg:grid-cols-4",
|
|
411
|
+
"6": "sm:grid-cols-3 lg:grid-cols-6",
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
const BENTO_GAP: Record<string, string> = {
|
|
415
|
+
none: "gap-0",
|
|
416
|
+
sm: "gap-3",
|
|
417
|
+
md: "gap-4",
|
|
418
|
+
lg: "gap-6",
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const BENTO_COL_SPAN: Record<string, string> = {
|
|
422
|
+
"1": "col-span-1",
|
|
423
|
+
"2": "sm:col-span-2",
|
|
424
|
+
"3": "sm:col-span-2 lg:col-span-3",
|
|
425
|
+
"4": "sm:col-span-2 lg:col-span-4",
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
const BENTO_ROW_SPAN: Record<string, string> = {
|
|
429
|
+
"1": "row-span-1",
|
|
430
|
+
"2": "row-span-2",
|
|
431
|
+
"3": "row-span-3",
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
function spanClass(raw: unknown, table: Record<string, string>, max: number): string {
|
|
435
|
+
const n = Number(raw);
|
|
436
|
+
if (!Number.isFinite(n)) return "";
|
|
437
|
+
const clamped = Math.min(Math.max(Math.trunc(n), 1), max);
|
|
438
|
+
return table[String(clamped)] ?? "";
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
interface BentoItem {
|
|
442
|
+
title?: string | undefined;
|
|
443
|
+
desc?: string | undefined;
|
|
444
|
+
icon?: string | undefined;
|
|
445
|
+
tone?: unknown;
|
|
446
|
+
span?: { col?: unknown; row?: unknown } | undefined;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
function parseBentoItems(raw: unknown): BentoItem[] {
|
|
450
|
+
return records(raw).map((it) => {
|
|
451
|
+
const span = it["span"];
|
|
452
|
+
return {
|
|
453
|
+
title: str(it["title"]),
|
|
454
|
+
desc: str(it["desc"]),
|
|
455
|
+
icon: str(it["icon"]),
|
|
456
|
+
tone: it["tone"],
|
|
457
|
+
span:
|
|
458
|
+
span && typeof span === "object"
|
|
459
|
+
? {
|
|
460
|
+
col: (span as Record<string, unknown>)["col"],
|
|
461
|
+
row: (span as Record<string, unknown>)["row"],
|
|
462
|
+
}
|
|
463
|
+
: undefined,
|
|
464
|
+
};
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/** Render the inner content of one bento cell (shared by `items` and children). */
|
|
469
|
+
function BentoCellBody({
|
|
470
|
+
title,
|
|
471
|
+
desc,
|
|
472
|
+
icon,
|
|
473
|
+
tone,
|
|
474
|
+
children,
|
|
475
|
+
}: {
|
|
476
|
+
title?: string | undefined;
|
|
477
|
+
desc?: string | undefined;
|
|
478
|
+
icon?: string | undefined;
|
|
479
|
+
tone: number;
|
|
480
|
+
children?: ReactNode;
|
|
481
|
+
}): React.ReactElement {
|
|
482
|
+
return (
|
|
483
|
+
<>
|
|
484
|
+
{icon && (
|
|
485
|
+
<span
|
|
486
|
+
className={cn(
|
|
487
|
+
"mb-4 inline-flex size-11 items-center justify-center rounded-lg border mkt-tint",
|
|
488
|
+
`mkt-tint-${tone}`,
|
|
489
|
+
)}
|
|
490
|
+
>
|
|
491
|
+
<Icon name={icon} />
|
|
492
|
+
</span>
|
|
493
|
+
)}
|
|
494
|
+
{title && <h3 className="text-xl">{title}</h3>}
|
|
495
|
+
{desc && <p className="mt-2 text-sm leading-relaxed text-muted-foreground">{desc}</p>}
|
|
496
|
+
{children}
|
|
497
|
+
</>
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
* Asymmetric bento layout. Lays children (BentoCell) or an `items` array onto a
|
|
503
|
+
* CSS grid whose base column count is `cols`; cells opt into `col`/`row` spans
|
|
504
|
+
* to break the rhythm. `gridAutoRows` keeps row spans visually even.
|
|
505
|
+
*/
|
|
506
|
+
export const BentoGrid: RendererComponent = (props, ctx) => {
|
|
507
|
+
const cols = String(props["cols"] ?? "3");
|
|
508
|
+
const colsCls = BENTO_GRID_COLS[cols] ?? BENTO_GRID_COLS["3"];
|
|
509
|
+
const gapCls = BENTO_GAP[str(props["gap"]) ?? "md"] ?? BENTO_GAP["md"];
|
|
510
|
+
const items = parseBentoItems(props["items"]);
|
|
511
|
+
const children = ctx.children as ReactNode[];
|
|
512
|
+
|
|
513
|
+
return (
|
|
514
|
+
<div
|
|
515
|
+
className={cn(
|
|
516
|
+
"marketing mx-auto grid max-w-6xl grid-cols-1 px-6 md:px-0 [grid-auto-rows:minmax(11rem,auto)]",
|
|
517
|
+
colsCls,
|
|
518
|
+
gapCls,
|
|
519
|
+
)}
|
|
520
|
+
data-uibot-type="BentoGrid"
|
|
521
|
+
>
|
|
522
|
+
{children.length > 0
|
|
523
|
+
? children
|
|
524
|
+
: items.map((it, i) => {
|
|
525
|
+
const tone = tintIndex(it.tone, i % 4);
|
|
526
|
+
const colCls = spanClass(it.span?.col, BENTO_COL_SPAN, 4);
|
|
527
|
+
const rowCls = spanClass(it.span?.row, BENTO_ROW_SPAN, 3);
|
|
528
|
+
return (
|
|
529
|
+
<article
|
|
530
|
+
key={i}
|
|
531
|
+
className={cn(
|
|
532
|
+
"mkt-card mkt-reveal flex flex-col p-6",
|
|
533
|
+
colCls,
|
|
534
|
+
rowCls,
|
|
535
|
+
`mkt-reveal-${Math.min(i + 1, 6)}`,
|
|
536
|
+
)}
|
|
537
|
+
>
|
|
538
|
+
<BentoCellBody title={it.title} desc={it.desc} icon={it.icon} tone={tone} />
|
|
539
|
+
</article>
|
|
540
|
+
);
|
|
541
|
+
})}
|
|
542
|
+
</div>
|
|
543
|
+
);
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* A single bento tile, usable standalone inside a BentoGrid. Reads `span.col` /
|
|
548
|
+
* `span.row` and maps them to static span classes so an authored cell can be
|
|
549
|
+
* as wide/tall as the layout needs.
|
|
550
|
+
*/
|
|
551
|
+
export const BentoCell: RendererComponent = (props, ctx) => {
|
|
552
|
+
const span = (props["span"] as { col?: unknown; row?: unknown } | undefined) ?? undefined;
|
|
553
|
+
const tone = tintIndex(props["tone"], 0);
|
|
554
|
+
const colCls = spanClass(span?.col, BENTO_COL_SPAN, 4);
|
|
555
|
+
const rowCls = spanClass(span?.row, BENTO_ROW_SPAN, 3);
|
|
556
|
+
const children = ctx.children as ReactNode[];
|
|
557
|
+
|
|
558
|
+
return (
|
|
559
|
+
<article
|
|
560
|
+
className={cn("mkt-card marketing flex flex-col p-6", colCls, rowCls)}
|
|
561
|
+
data-uibot-type="BentoCell"
|
|
562
|
+
>
|
|
563
|
+
<BentoCellBody
|
|
564
|
+
title={str(props["title"])}
|
|
565
|
+
desc={str(props["desc"])}
|
|
566
|
+
icon={str(props["icon"])}
|
|
567
|
+
tone={tone}
|
|
568
|
+
>
|
|
569
|
+
{children.length > 0 ? <div className="mt-4">{children}</div> : null}
|
|
570
|
+
</BentoCellBody>
|
|
571
|
+
</article>
|
|
572
|
+
);
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
// ── Callout ────────────────────────────────────────────────────────────────────
|
|
576
|
+
|
|
577
|
+
type CalloutVariant = "info" | "success" | "warn" | "accent";
|
|
578
|
+
|
|
579
|
+
const CALLOUT_VARIANTS: Record<CalloutVariant, { color: string; icon: string }> = {
|
|
580
|
+
// `color` is a CSS custom-property reference; tint is applied via color-mix so
|
|
581
|
+
// both light + dark stay legible off the same token.
|
|
582
|
+
info: { color: "var(--mk-accent-4)", icon: "info" },
|
|
583
|
+
success: { color: "var(--success)", icon: "check" },
|
|
584
|
+
warn: { color: "var(--warning)", icon: "alert" },
|
|
585
|
+
accent: { color: "var(--marketing-accent)", icon: "sparkles" },
|
|
586
|
+
};
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Emphasis callout block. A tinted panel (semantic/brand colour) with an accent
|
|
590
|
+
* left bar, icon, optional title and body. `color-mix` against the chosen token
|
|
591
|
+
* keeps the wash subtle and theme-correct in light and dark.
|
|
592
|
+
*/
|
|
593
|
+
export const Callout: RendererComponent = (props, ctx) => {
|
|
594
|
+
const variantRaw = str(props["variant"]) as CalloutVariant | undefined;
|
|
595
|
+
const variant: CalloutVariant =
|
|
596
|
+
variantRaw && variantRaw in CALLOUT_VARIANTS ? variantRaw : "info";
|
|
597
|
+
const { color, icon: defaultIcon } = CALLOUT_VARIANTS[variant];
|
|
598
|
+
const icon = str(props["icon"]) ?? defaultIcon;
|
|
599
|
+
const title = str(props["title"]);
|
|
600
|
+
const body = str(props["body"]);
|
|
601
|
+
const children = ctx.children as ReactNode[];
|
|
602
|
+
|
|
603
|
+
return (
|
|
604
|
+
<aside
|
|
605
|
+
className="marketing mx-auto flex max-w-3xl gap-4 rounded-lg border p-5"
|
|
606
|
+
data-uibot-type="Callout"
|
|
607
|
+
style={{
|
|
608
|
+
borderColor: `color-mix(in oklch, ${color} 35%, var(--border))`,
|
|
609
|
+
background: `color-mix(in oklch, ${color} 8%, var(--card))`,
|
|
610
|
+
}}
|
|
611
|
+
>
|
|
612
|
+
<span
|
|
613
|
+
aria-hidden="true"
|
|
614
|
+
className="mt-0.5 inline-flex size-8 shrink-0 items-center justify-center rounded-md"
|
|
615
|
+
style={{
|
|
616
|
+
color,
|
|
617
|
+
background: `color-mix(in oklch, ${color} 16%, transparent)`,
|
|
618
|
+
}}
|
|
619
|
+
>
|
|
620
|
+
<Icon name={icon} className="size-5" />
|
|
621
|
+
</span>
|
|
622
|
+
<div className="min-w-0">
|
|
623
|
+
{title && (
|
|
624
|
+
<p className="font-medium text-foreground" style={{ color }}>
|
|
625
|
+
{title}
|
|
626
|
+
</p>
|
|
627
|
+
)}
|
|
628
|
+
{body && (
|
|
629
|
+
<p className={cn("text-sm leading-relaxed text-muted-foreground", title && "mt-1")}>
|
|
630
|
+
{body}
|
|
631
|
+
</p>
|
|
632
|
+
)}
|
|
633
|
+
{children.length > 0 && <div className="mt-2">{children}</div>}
|
|
634
|
+
</div>
|
|
635
|
+
</aside>
|
|
636
|
+
);
|
|
637
|
+
};
|