@kyro-cms/studio 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -2
- package/components/KyroStudioPage.astro +7 -0
- package/package.json +32 -3
- package/src/blocks.tsx +709 -0
- package/src/bridge.ts +55 -0
- package/src/fonts.ts +49 -0
- package/src/forms.tsx +194 -0
- package/src/image-framing.ts +33 -0
- package/src/index.ts +18 -0
- package/src/layout-styles.ts +93 -0
- package/src/picked-icon.tsx +26 -0
- package/src/primitives.tsx +144 -0
- package/src/react.tsx +306 -0
- package/src/references.ts +71 -0
- package/src/styles.ts +8 -0
- package/src/types.ts +36 -0
package/src/blocks.tsx
ADDED
|
@@ -0,0 +1,709 @@
|
|
|
1
|
+
import { PickedIcon } from "./picked-icon";
|
|
2
|
+
import React, { useId, useState } from "react";
|
|
3
|
+
import { KyroRichTextRenderer } from "@kyro-cms/rich-text-react";
|
|
4
|
+
import type { StudioRenderProps, StudioComponent } from "./types";
|
|
5
|
+
import { attr, Buttons, Heading, IconGlyph, Intro, list, Media, reference, safeStudioUrl, text } from "./primitives";
|
|
6
|
+
const section =
|
|
7
|
+
(Component: React.ComponentType<StudioRenderProps>, className = "") =>
|
|
8
|
+
(props: StudioRenderProps) => (
|
|
9
|
+
<section className={`kyro-section ${className}`}>
|
|
10
|
+
<Component {...props} />
|
|
11
|
+
</section>
|
|
12
|
+
);
|
|
13
|
+
export function Hero(props: StudioRenderProps) {
|
|
14
|
+
const { block, editing } = props;
|
|
15
|
+
const [slideIndex, setSlideIndex] = useState(0);
|
|
16
|
+
const slides = block.isMultiScreen ? list(block.multiSlides?.multiSlides) : [block.singleSlide || {}];
|
|
17
|
+
const index = Math.min(slideIndex, Math.max(0, slides.length - 1));
|
|
18
|
+
const slide = slides[index] || {};
|
|
19
|
+
const prefix = block.isMultiScreen ? `multiSlides.multiSlides.${index}` : "singleSlide";
|
|
20
|
+
return (
|
|
21
|
+
<section className="kyro-hero">
|
|
22
|
+
<div className={`kyro-split ${slide.backgroundImage ? "" : "kyro-single"}`}>
|
|
23
|
+
<div>
|
|
24
|
+
<h1 {...attr(props, `${prefix}.title`)}>
|
|
25
|
+
{text(slide.title) || (editing ? "Your next great story starts here." : "")}
|
|
26
|
+
</h1>
|
|
27
|
+
<p {...attr(props, `${prefix}.subtitle`)}>
|
|
28
|
+
{text(slide.subtitle) || (editing ? "Add a short introduction that gives visitors a reason to stay." : "")}
|
|
29
|
+
</p>
|
|
30
|
+
<Buttons items={slide.buttons} path={`${prefix}.buttons`} props={props} />
|
|
31
|
+
</div>
|
|
32
|
+
{slide.backgroundImage && (
|
|
33
|
+
<Media value={slide.backgroundImage} path={`${prefix}.backgroundImage`} props={props} />
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
{slides.length > 1 && (
|
|
37
|
+
<div className="kyro-carousel-controls" data-kyro-interactive>
|
|
38
|
+
{slides.map((_, i) => (
|
|
39
|
+
<button
|
|
40
|
+
type="button"
|
|
41
|
+
key={i}
|
|
42
|
+
aria-label={`Show slide ${i + 1}`}
|
|
43
|
+
aria-pressed={index === i}
|
|
44
|
+
onClick={() => setSlideIndex(i)}
|
|
45
|
+
>
|
|
46
|
+
{i + 1}
|
|
47
|
+
</button>
|
|
48
|
+
))}
|
|
49
|
+
</div>
|
|
50
|
+
)}
|
|
51
|
+
</section>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
function RichText(props: StudioRenderProps) {
|
|
55
|
+
let content = props.block.content;
|
|
56
|
+
if (typeof content === "string") {
|
|
57
|
+
try {
|
|
58
|
+
content = JSON.parse(content);
|
|
59
|
+
} catch {
|
|
60
|
+
return <p {...attr(props, "content")}>{content}</p>;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return (
|
|
64
|
+
<div className="kyro-rich-content" {...attr(props, "content")}>
|
|
65
|
+
{content && (
|
|
66
|
+
<KyroRichTextRenderer
|
|
67
|
+
content={content}
|
|
68
|
+
components={{
|
|
69
|
+
marks: { link: ({ mark, children }: any) => <a href={safeStudioUrl(mark.attrs?.href)}>{children}</a> },
|
|
70
|
+
types: {
|
|
71
|
+
image: ({ node }: any) =>
|
|
72
|
+
safeStudioUrl(node.attrs?.src) ? (
|
|
73
|
+
<img src={safeStudioUrl(node.attrs.src)} alt={text(node.attrs?.alt)} />
|
|
74
|
+
) : null,
|
|
75
|
+
},
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
)}
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function Card(props: StudioRenderProps) {
|
|
83
|
+
const multi = props.block.isMultiCard;
|
|
84
|
+
const cards = multi ? list(props.block.multiCards?.cards) : [props.block.singleCard || {}];
|
|
85
|
+
return (
|
|
86
|
+
<div className={multi ? "kyro-grid" : ""}>
|
|
87
|
+
{cards.map((card, index) => {
|
|
88
|
+
const prefix = multi ? `multiCards.cards.${index}` : "singleCard";
|
|
89
|
+
return (
|
|
90
|
+
<article className="kyro-card" key={card.id || index}>
|
|
91
|
+
{card.image && <Media value={card.image} props={props} path={`${prefix}.image`} />}
|
|
92
|
+
<h3 {...attr(props, `${prefix}.title`)}>{text(card.title)}</h3>
|
|
93
|
+
<p {...attr(props, `${prefix}.description`)}>{text(card.description)}</p>
|
|
94
|
+
{card.icon && (
|
|
95
|
+
<small {...attr(props, `${prefix}.icon`)}>
|
|
96
|
+
<IconGlyph name={card.icon} />
|
|
97
|
+
</small>
|
|
98
|
+
)}
|
|
99
|
+
{card.linkText && (
|
|
100
|
+
<a href={safeStudioUrl(card.link)} {...attr(props, `${prefix}.linkText`)}>
|
|
101
|
+
{text(card.linkText)} ↗
|
|
102
|
+
</a>
|
|
103
|
+
)}
|
|
104
|
+
</article>
|
|
105
|
+
);
|
|
106
|
+
})}
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
function ImageBlock(props: StudioRenderProps) {
|
|
111
|
+
const b = props.block;
|
|
112
|
+
const ratios: Record<string, string> = { "16-9": "16/9", "4-3": "4/3", "1-1": "1", "2-3": "2/3" };
|
|
113
|
+
const image = (
|
|
114
|
+
<div style={{ aspectRatio: ratios[b.aspectRatio] }}>
|
|
115
|
+
<Media value={b.image} props={props} path="image" alt={text(b.alt)} />
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
return (
|
|
119
|
+
<figure className="kyro-image">
|
|
120
|
+
{b.enableLightbox ? (
|
|
121
|
+
<details data-kyro-interactive>
|
|
122
|
+
<summary>
|
|
123
|
+
{image}
|
|
124
|
+
<span>Enlarge image</span>
|
|
125
|
+
</summary>
|
|
126
|
+
<Media value={b.image} props={props} path="image" alt={text(b.alt)} />
|
|
127
|
+
</details>
|
|
128
|
+
) : (
|
|
129
|
+
image
|
|
130
|
+
)}
|
|
131
|
+
{b.caption && <figcaption {...attr(props, "caption")}>{text(b.caption)}</figcaption>}
|
|
132
|
+
</figure>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
function FeatureSplit(props: StudioRenderProps) {
|
|
136
|
+
const b = props.block;
|
|
137
|
+
return (
|
|
138
|
+
<>
|
|
139
|
+
<Intro props={props} />
|
|
140
|
+
<div className="kyro-split">
|
|
141
|
+
<div>
|
|
142
|
+
{list(b.checkpoints).map((item, index) => (
|
|
143
|
+
<article className="kyro-checkpoint" key={item.id || index}>
|
|
144
|
+
{item.image && <Media value={item.image} path={`checkpoints.${index}.image`} props={props} />}
|
|
145
|
+
<h3 {...attr(props, `checkpoints.${index}.title`)}>
|
|
146
|
+
{item.icon && (
|
|
147
|
+
<small>
|
|
148
|
+
<IconGlyph name={item.icon} />
|
|
149
|
+
</small>
|
|
150
|
+
)}
|
|
151
|
+
{text(item.title)}
|
|
152
|
+
</h3>
|
|
153
|
+
<p {...attr(props, `checkpoints.${index}.description`)}>{text(item.description)}</p>
|
|
154
|
+
{item.itemText && (
|
|
155
|
+
<a href={safeStudioUrl(item.itemUrl)} {...attr(props, `checkpoints.${index}.itemText`)}>
|
|
156
|
+
{text(item.itemText)}
|
|
157
|
+
</a>
|
|
158
|
+
)}
|
|
159
|
+
</article>
|
|
160
|
+
))}
|
|
161
|
+
<Buttons items={b.buttons} props={props} />
|
|
162
|
+
</div>
|
|
163
|
+
<div>
|
|
164
|
+
{list(b.images).map((item, index) => (
|
|
165
|
+
<Media key={item.id || index} value={item.image} path={`images.${index}.image`} props={props} />
|
|
166
|
+
))}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
function FeatureGrid(props: StudioRenderProps) {
|
|
173
|
+
return (
|
|
174
|
+
<>
|
|
175
|
+
<Intro props={props} />
|
|
176
|
+
<div className="kyro-grid">
|
|
177
|
+
{list(props.block.features).map((item, index) => (
|
|
178
|
+
<article className="kyro-card" key={item.id || index}>
|
|
179
|
+
{item.image && <Media value={item.image} path={`features.${index}.image`} props={props} />}
|
|
180
|
+
<h3 {...attr(props, `features.${index}.title`)}>{text(item.title)}</h3>
|
|
181
|
+
<p {...attr(props, `features.${index}.description`)}>{text(item.description)}</p>
|
|
182
|
+
{item.icon && (
|
|
183
|
+
<small {...attr(props, `features.${index}.icon`)}>
|
|
184
|
+
<IconGlyph name={item.icon} />
|
|
185
|
+
</small>
|
|
186
|
+
)}
|
|
187
|
+
{item.itemUrl && (
|
|
188
|
+
<a href={safeStudioUrl(item.itemUrl)} {...attr(props, `features.${index}.itemUrl`)}>
|
|
189
|
+
Explore ↗
|
|
190
|
+
</a>
|
|
191
|
+
)}
|
|
192
|
+
</article>
|
|
193
|
+
))}
|
|
194
|
+
</div>
|
|
195
|
+
</>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
function CTA(props: StudioRenderProps) {
|
|
199
|
+
return (
|
|
200
|
+
<div className="kyro-cta">
|
|
201
|
+
<Intro props={props} />
|
|
202
|
+
{props.block.backgroundImage && (
|
|
203
|
+
<Media value={props.block.backgroundImage} path="backgroundImage" props={props} />
|
|
204
|
+
)}
|
|
205
|
+
<Buttons items={props.block.buttons} props={props} />
|
|
206
|
+
</div>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
function Testimonials(props: StudioRenderProps) {
|
|
210
|
+
return (
|
|
211
|
+
<>
|
|
212
|
+
<Intro props={props} />
|
|
213
|
+
<div className="kyro-grid">
|
|
214
|
+
{list(props.block.items).map((item, index) => (
|
|
215
|
+
<figure className="kyro-card" key={item.id || index}>
|
|
216
|
+
<span {...attr(props, `items.${index}.rating`)} aria-label={`${item.rating || 5} out of 5 stars`}>
|
|
217
|
+
{"★".repeat(Math.max(0, Math.min(5, Number(item.rating) || 0)))}
|
|
218
|
+
</span>
|
|
219
|
+
<blockquote {...attr(props, `items.${index}.quote`)}>{text(item.quote)}</blockquote>
|
|
220
|
+
<figcaption>
|
|
221
|
+
{item.avatar && (
|
|
222
|
+
<Media value={item.avatar} path={`items.${index}.avatar`} props={props} className="kyro-avatar" />
|
|
223
|
+
)}
|
|
224
|
+
<strong {...attr(props, `items.${index}.authorName`)}>{text(item.authorName)}</strong>
|
|
225
|
+
<p {...attr(props, `items.${index}.authorRole`)}>{text(item.authorRole)}</p>
|
|
226
|
+
{item.companyLogo && (
|
|
227
|
+
<Media
|
|
228
|
+
value={item.companyLogo}
|
|
229
|
+
path={`items.${index}.companyLogo`}
|
|
230
|
+
props={props}
|
|
231
|
+
className="kyro-logo"
|
|
232
|
+
/>
|
|
233
|
+
)}
|
|
234
|
+
</figcaption>
|
|
235
|
+
</figure>
|
|
236
|
+
))}
|
|
237
|
+
</div>
|
|
238
|
+
</>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
function FAQ(props: StudioRenderProps) {
|
|
242
|
+
return (
|
|
243
|
+
<>
|
|
244
|
+
<Intro props={props} />
|
|
245
|
+
{list(props.block.items).map((item, index) => (
|
|
246
|
+
<details className="kyro-faq" key={item.id || index} data-kyro-interactive>
|
|
247
|
+
<summary {...attr(props, `items.${index}.question`)}>
|
|
248
|
+
{item.tag && <small>{text(item.tag)} · </small>}
|
|
249
|
+
{text(item.question)}
|
|
250
|
+
</summary>
|
|
251
|
+
<p {...attr(props, `items.${index}.answer`)}>{text(item.answer)}</p>
|
|
252
|
+
</details>
|
|
253
|
+
))}
|
|
254
|
+
{props.block.footerTitle && (
|
|
255
|
+
<a className="kyro-faq-footer" href={safeStudioUrl(props.block.footerCtaUrl)} {...attr(props, "footerTitle")}>
|
|
256
|
+
{text(props.block.footerTitle)} ↗
|
|
257
|
+
</a>
|
|
258
|
+
)}
|
|
259
|
+
</>
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function Stats(props: StudioRenderProps) {
|
|
263
|
+
return (
|
|
264
|
+
<>
|
|
265
|
+
<Intro props={props} />
|
|
266
|
+
<div className="kyro-grid">
|
|
267
|
+
{list(props.block.items).map((item, index) => (
|
|
268
|
+
<article key={item.id || index}>
|
|
269
|
+
<p className="kyro-stat" {...attr(props, `items.${index}.value`)}>
|
|
270
|
+
{text(item.prefix)}
|
|
271
|
+
{text(item.value)}
|
|
272
|
+
{text(item.suffix)}
|
|
273
|
+
</p>
|
|
274
|
+
<h3 {...attr(props, `items.${index}.label`)}>{text(item.label)}</h3>
|
|
275
|
+
<p {...attr(props, `items.${index}.description`)}>{text(item.description)}</p>
|
|
276
|
+
</article>
|
|
277
|
+
))}
|
|
278
|
+
</div>
|
|
279
|
+
</>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
function Logos(props: StudioRenderProps) {
|
|
283
|
+
return (
|
|
284
|
+
<>
|
|
285
|
+
<Intro props={props} />
|
|
286
|
+
<div className="kyro-logos">
|
|
287
|
+
{list(props.block.logos).map((item, index) => (
|
|
288
|
+
<a key={item.id || index} href={safeStudioUrl(item.url)}>
|
|
289
|
+
<Media
|
|
290
|
+
value={item.logo}
|
|
291
|
+
props={props}
|
|
292
|
+
path={`logos.${index}.logo`}
|
|
293
|
+
alt={text(item.name)}
|
|
294
|
+
className="kyro-logo"
|
|
295
|
+
/>
|
|
296
|
+
<span {...attr(props, `logos.${index}.name`)}>{text(item.name)}</span>
|
|
297
|
+
</a>
|
|
298
|
+
))}
|
|
299
|
+
</div>
|
|
300
|
+
</>
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
function Pricing(props: StudioRenderProps) {
|
|
304
|
+
return (
|
|
305
|
+
<>
|
|
306
|
+
<Intro props={props} />
|
|
307
|
+
{props.block.annualDiscount && <p {...attr(props, "annualDiscount")}>{text(props.block.annualDiscount)}</p>}
|
|
308
|
+
<div className="kyro-grid">
|
|
309
|
+
{list(props.block.plans).map((item, index) => (
|
|
310
|
+
<article className={`kyro-card ${item.isFeatured ? "kyro-featured" : ""}`} key={item.id || index}>
|
|
311
|
+
<small {...attr(props, `plans.${index}.popularBadgeText`)}>{text(item.popularBadgeText)}</small>
|
|
312
|
+
<h3 {...attr(props, `plans.${index}.name`)}>{text(item.name)}</h3>
|
|
313
|
+
<p {...attr(props, `plans.${index}.description`)}>{text(item.description)}</p>
|
|
314
|
+
<p className="kyro-stat" {...attr(props, `plans.${index}.price`)}>
|
|
315
|
+
{text(item.currency)}
|
|
316
|
+
{text(item.price)}
|
|
317
|
+
<small>{text(item.billingPeriod)}</small>
|
|
318
|
+
</p>
|
|
319
|
+
<ul {...attr(props, `plans.${index}.features`)}>
|
|
320
|
+
{list(item.features).map((feature, n) => (
|
|
321
|
+
<li key={n}>{text(feature?.text ?? feature?.value ?? feature)}</li>
|
|
322
|
+
))}
|
|
323
|
+
</ul>
|
|
324
|
+
<Buttons items={item.buttons} path={`plans.${index}.buttons`} props={props} />
|
|
325
|
+
<small {...attr(props, `plans.${index}.footnote`)}>{text(item.footnote)}</small>
|
|
326
|
+
</article>
|
|
327
|
+
))}
|
|
328
|
+
</div>
|
|
329
|
+
</>
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
function Team(props: StudioRenderProps) {
|
|
333
|
+
return (
|
|
334
|
+
<>
|
|
335
|
+
<Intro props={props} />
|
|
336
|
+
<div className="kyro-grid">
|
|
337
|
+
{list(props.block.members).map((item, index) => (
|
|
338
|
+
<article key={item.id || index}>
|
|
339
|
+
{item.avatar && <Media value={item.avatar} path={`members.${index}.avatar`} props={props} />}
|
|
340
|
+
<small {...attr(props, `members.${index}.department`)}>{text(item.department)}</small>
|
|
341
|
+
<h3 {...attr(props, `members.${index}.name`)}>{text(item.name)}</h3>
|
|
342
|
+
<p {...attr(props, `members.${index}.role`)}>{text(item.role)}</p>
|
|
343
|
+
<p {...attr(props, `members.${index}.bio`)}>{text(item.bio)}</p>
|
|
344
|
+
<div className="kyro-actions">
|
|
345
|
+
{["websiteUrl", "twitterUrl", "linkedinUrl", "githubUrl"]
|
|
346
|
+
.filter((key) => item[key])
|
|
347
|
+
.map((key) => (
|
|
348
|
+
<a key={key} {...attr(props, `members.${index}.${key}`)} href={safeStudioUrl(item[key])}>
|
|
349
|
+
{key.replace("Url", "")} ↗
|
|
350
|
+
</a>
|
|
351
|
+
))}
|
|
352
|
+
</div>
|
|
353
|
+
</article>
|
|
354
|
+
))}
|
|
355
|
+
</div>
|
|
356
|
+
</>
|
|
357
|
+
);
|
|
358
|
+
}
|
|
359
|
+
function Feed(props: StudioRenderProps) {
|
|
360
|
+
return (
|
|
361
|
+
<>
|
|
362
|
+
<Intro props={props} />
|
|
363
|
+
<div className="kyro-grid">
|
|
364
|
+
{list(props.block.selectedItems).map((item, index) => {
|
|
365
|
+
const doc = reference(item, item?.relationTo || "*", props);
|
|
366
|
+
return doc ? (
|
|
367
|
+
<article className="kyro-card" key={doc.id || index}>
|
|
368
|
+
<h3 {...attr(props, `selectedItems.${index}`)}>{text(doc.title || doc.name)}</h3>
|
|
369
|
+
<p>{text(doc.excerpt || doc.description)}</p>
|
|
370
|
+
</article>
|
|
371
|
+
) : props.editing ? (
|
|
372
|
+
<p key={index} {...attr(props, `selectedItems.${index}`)}>
|
|
373
|
+
Resolving selected content…
|
|
374
|
+
</p>
|
|
375
|
+
) : null;
|
|
376
|
+
})}
|
|
377
|
+
</div>
|
|
378
|
+
<Buttons items={props.block.buttons} props={props} />
|
|
379
|
+
</>
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
function Steps(props: StudioRenderProps) {
|
|
383
|
+
return (
|
|
384
|
+
<>
|
|
385
|
+
<Intro props={props} />
|
|
386
|
+
<ol className="kyro-grid kyro-steps">
|
|
387
|
+
{list(props.block.steps).map((step, index) => (
|
|
388
|
+
<li key={step.id || index}>
|
|
389
|
+
{step.icon && <Media value={step.icon} path={`steps.${index}.icon`} props={props} />}
|
|
390
|
+
<span className="kyro-stat" {...attr(props, `steps.${index}.stepNumber`)}>
|
|
391
|
+
{text(step.stepNumber) || String(index + 1).padStart(2, "0")}
|
|
392
|
+
</span>
|
|
393
|
+
<h3 {...attr(props, `steps.${index}.title`)}>{text(step.title)}</h3>
|
|
394
|
+
<p {...attr(props, `steps.${index}.description`)}>{text(step.description)}</p>
|
|
395
|
+
</li>
|
|
396
|
+
))}
|
|
397
|
+
</ol>
|
|
398
|
+
</>
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
function FormEmbed(props: StudioRenderProps) {
|
|
402
|
+
const form = reference(props.block.form, "forms", props);
|
|
403
|
+
if (form && props.context?.renderForm)
|
|
404
|
+
return (
|
|
405
|
+
<>
|
|
406
|
+
<Intro props={props} />
|
|
407
|
+
{props.context.renderForm(form, props)}
|
|
408
|
+
</>
|
|
409
|
+
);
|
|
410
|
+
return (
|
|
411
|
+
<>
|
|
412
|
+
<Intro props={props} />
|
|
413
|
+
<div className="kyro-form-preview" {...attr(props, "form")}>
|
|
414
|
+
{form ? (
|
|
415
|
+
<>
|
|
416
|
+
{list(form.fields).map((f, index) => (
|
|
417
|
+
<label key={f.id || index}>
|
|
418
|
+
{text(f.fieldName)}
|
|
419
|
+
{f.isRequired && " *"}
|
|
420
|
+
{f.inputType === "textarea" ? (
|
|
421
|
+
<textarea disabled placeholder={text(f.placeholder)} />
|
|
422
|
+
) : (
|
|
423
|
+
<input
|
|
424
|
+
disabled
|
|
425
|
+
type={["text", "email", "tel", "checkbox"].includes(f.inputType) ? f.inputType : "text"}
|
|
426
|
+
placeholder={text(f.placeholder)}
|
|
427
|
+
/>
|
|
428
|
+
)}
|
|
429
|
+
</label>
|
|
430
|
+
))}
|
|
431
|
+
<button type="button" disabled>
|
|
432
|
+
{text(form.submitButtonText) || "Submit"}
|
|
433
|
+
</button>
|
|
434
|
+
</>
|
|
435
|
+
) : (
|
|
436
|
+
<p>Choose a form in the inspector.</p>
|
|
437
|
+
)}
|
|
438
|
+
{props.editing && <small>Form preview · submission adapter required</small>}
|
|
439
|
+
</div>
|
|
440
|
+
</>
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
function Video(props: StudioRenderProps) {
|
|
444
|
+
const b = props.block;
|
|
445
|
+
const source = safeStudioUrl(b.videoUrl || b.url || reference(b.file, "media", props)?.url);
|
|
446
|
+
const embed = source?.match(/^https:\/\/(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]{6,})/);
|
|
447
|
+
const vimeo = source?.match(/^https:\/\/(?:www\.)?vimeo\.com\/(\d+)/);
|
|
448
|
+
return (
|
|
449
|
+
<>
|
|
450
|
+
<Intro props={props} />
|
|
451
|
+
<figure {...attr(props, b.videoUrl ? "videoUrl" : "url")}>
|
|
452
|
+
{props.editing ? (
|
|
453
|
+
<div className="kyro-video-preview">
|
|
454
|
+
{b.coverImage ? <Media value={b.coverImage} path="coverImage" props={props} /> : <span aria-hidden>▶</span>}
|
|
455
|
+
<p>{text(b.videoTitle) || source || "Choose a video"}</p>
|
|
456
|
+
{b.durationBadge && <small>{text(b.durationBadge)}</small>}
|
|
457
|
+
</div>
|
|
458
|
+
) : embed || vimeo ? (
|
|
459
|
+
<iframe
|
|
460
|
+
title={text(b.videoTitle) || "Video"}
|
|
461
|
+
src={
|
|
462
|
+
embed
|
|
463
|
+
? `https://www.youtube-nocookie.com/embed/${embed[1]}`
|
|
464
|
+
: `https://player.vimeo.com/video/${vimeo![1]}`
|
|
465
|
+
}
|
|
466
|
+
loading="lazy"
|
|
467
|
+
allowFullScreen
|
|
468
|
+
sandbox="allow-scripts allow-same-origin allow-presentation"
|
|
469
|
+
/>
|
|
470
|
+
) : source ? (
|
|
471
|
+
<video
|
|
472
|
+
controls
|
|
473
|
+
muted={!!b.autoplay}
|
|
474
|
+
autoPlay={!!b.autoplay}
|
|
475
|
+
poster={safeStudioUrl(reference(b.coverImage, "media", props)?.url)}
|
|
476
|
+
src={source}
|
|
477
|
+
/>
|
|
478
|
+
) : null}
|
|
479
|
+
{b.caption && <figcaption {...attr(props, "caption")}>{text(b.caption)}</figcaption>}
|
|
480
|
+
</figure>
|
|
481
|
+
</>
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
function Gallery(props: StudioRenderProps) {
|
|
485
|
+
return (
|
|
486
|
+
<>
|
|
487
|
+
<Intro props={props} />
|
|
488
|
+
<div className="kyro-grid">
|
|
489
|
+
{list(props.block.images).map((item, index) => (
|
|
490
|
+
<figure key={item.id || index}>
|
|
491
|
+
<Media value={item.image} path={`images.${index}.image`} props={props} />
|
|
492
|
+
{item.caption && <figcaption {...attr(props, `images.${index}.caption`)}>{text(item.caption)}</figcaption>}
|
|
493
|
+
</figure>
|
|
494
|
+
))}
|
|
495
|
+
</div>
|
|
496
|
+
</>
|
|
497
|
+
);
|
|
498
|
+
}
|
|
499
|
+
function Tabs(props: StudioRenderProps) {
|
|
500
|
+
const [active, setActive] = useState(0);
|
|
501
|
+
const id = useId();
|
|
502
|
+
const items = list(props.block.items);
|
|
503
|
+
const index = Math.min(active, Math.max(0, items.length - 1));
|
|
504
|
+
return (
|
|
505
|
+
<>
|
|
506
|
+
<Intro props={props} />
|
|
507
|
+
<div className="kyro-tabs" role="tablist" data-kyro-interactive>
|
|
508
|
+
{items.map((item, i) => (
|
|
509
|
+
<button
|
|
510
|
+
key={item.id || i}
|
|
511
|
+
type="button"
|
|
512
|
+
id={`${id}-tab-${i}`}
|
|
513
|
+
role="tab"
|
|
514
|
+
aria-selected={i === index}
|
|
515
|
+
aria-controls={`${id}-panel`}
|
|
516
|
+
tabIndex={i === index ? 0 : -1}
|
|
517
|
+
onClick={() => setActive(i)}
|
|
518
|
+
onKeyDown={(event) => {
|
|
519
|
+
let next = i;
|
|
520
|
+
if (event.key === "ArrowRight") next = (i + 1) % items.length;
|
|
521
|
+
else if (event.key === "ArrowLeft") next = (i + items.length - 1) % items.length;
|
|
522
|
+
else if (event.key === "Home") next = 0;
|
|
523
|
+
else if (event.key === "End") next = items.length - 1;
|
|
524
|
+
else return;
|
|
525
|
+
event.preventDefault();
|
|
526
|
+
setActive(next);
|
|
527
|
+
event.currentTarget.ownerDocument.getElementById(`${id}-tab-${next}`)?.focus();
|
|
528
|
+
}}
|
|
529
|
+
{...attr(props, `items.${i}.title`)}
|
|
530
|
+
>
|
|
531
|
+
{text(item.title)}
|
|
532
|
+
</button>
|
|
533
|
+
))}
|
|
534
|
+
</div>
|
|
535
|
+
{items[index] && (
|
|
536
|
+
<div id={`${id}-panel`} role="tabpanel" aria-labelledby={`${id}-tab-${index}`}>
|
|
537
|
+
<RichText
|
|
538
|
+
{...props}
|
|
539
|
+
block={{ ...props.block, content: items[index].content }}
|
|
540
|
+
pathPrefix={props.pathPrefix ? `${props.pathPrefix}.items.${index}` : `items.${index}`}
|
|
541
|
+
/>
|
|
542
|
+
</div>
|
|
543
|
+
)}
|
|
544
|
+
</>
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
const item = (
|
|
549
|
+
type: string,
|
|
550
|
+
label: string,
|
|
551
|
+
Component: React.ComponentType<StudioRenderProps>,
|
|
552
|
+
category: string,
|
|
553
|
+
defaults: Record<string, any> = {},
|
|
554
|
+
): StudioComponent => ({
|
|
555
|
+
type,
|
|
556
|
+
label,
|
|
557
|
+
Component: section(Component),
|
|
558
|
+
category,
|
|
559
|
+
defaults,
|
|
560
|
+
requiresFormAdapter: type === "formEmbed",
|
|
561
|
+
});
|
|
562
|
+
export const contentComponents: StudioComponent[] = [
|
|
563
|
+
{
|
|
564
|
+
type: "hero",
|
|
565
|
+
label: "Hero",
|
|
566
|
+
Component: Hero,
|
|
567
|
+
category: "Marketing",
|
|
568
|
+
defaults: {
|
|
569
|
+
isMultiScreen: false,
|
|
570
|
+
singleSlide: {
|
|
571
|
+
title: "Your next great story starts here.",
|
|
572
|
+
subtitle: "A clear introduction to what you do and why it matters.",
|
|
573
|
+
buttons: [{ text: "Explore more", url: "#" }],
|
|
574
|
+
},
|
|
575
|
+
},
|
|
576
|
+
},
|
|
577
|
+
item("card", "Cards", Card, "Marketing", {
|
|
578
|
+
isMultiCard: false,
|
|
579
|
+
singleCard: { title: "A useful idea", description: "Share the details that matter." },
|
|
580
|
+
}),
|
|
581
|
+
item("text", "Text section", RichText, "Content"),
|
|
582
|
+
item("image", "Image", ImageBlock, "Media", { aspectRatio: "original" }),
|
|
583
|
+
item("featureSplit", "Feature split", FeatureSplit, "Marketing", {
|
|
584
|
+
title: "Built around your needs",
|
|
585
|
+
checkpoints: [],
|
|
586
|
+
}),
|
|
587
|
+
item("featureGrid", "Feature grid", FeatureGrid, "Marketing", { title: "Everything you need", features: [] }),
|
|
588
|
+
item("ctaBanner", "Call to action", CTA, "Marketing", {
|
|
589
|
+
title: "Ready for your next step?",
|
|
590
|
+
buttons: [{ text: "Get started", url: "#" }],
|
|
591
|
+
}),
|
|
592
|
+
item("testimonials", "Testimonials", Testimonials, "Marketing", { title: "In good company", items: [] }),
|
|
593
|
+
item("faq", "FAQ", FAQ, "Interactive", { title: "Frequently asked questions", items: [] }),
|
|
594
|
+
item("stats", "Stats", Stats, "Marketing", { title: "Progress in numbers", items: [] }),
|
|
595
|
+
item("logoCloud", "Logos", Logos, "Marketing", { title: "Trusted by", logos: [] }),
|
|
596
|
+
item("pricing", "Pricing", Pricing, "Marketing", { title: "A plan for your next chapter", plans: [] }),
|
|
597
|
+
item("team", "Team", Team, "Marketing", { title: "Meet the team", members: [] }),
|
|
598
|
+
item("recentFeed", "Content feed", Feed, "Dynamic", { title: "Latest stories", selectedItems: [] }),
|
|
599
|
+
item("processSteps", "Process steps", Steps, "Marketing", { title: "How it works", steps: [] }),
|
|
600
|
+
item("formEmbed", "Form", FormEmbed, "Dynamic"),
|
|
601
|
+
item("videoShowcase", "Video showcase", Video, "Media"),
|
|
602
|
+
item(
|
|
603
|
+
"headingElement",
|
|
604
|
+
"Heading",
|
|
605
|
+
(p) => <Heading props={p} path="content" level={Number(p.block.level) || 2} />,
|
|
606
|
+
"Content",
|
|
607
|
+
{ content: "A clear heading" },
|
|
608
|
+
),
|
|
609
|
+
item("textElement", "Paragraph", (p) => <p {...attr(p, "content")}>{text(p.block.content)}</p>, "Content", {
|
|
610
|
+
content: "Tell your story, one paragraph at a time.",
|
|
611
|
+
}),
|
|
612
|
+
item("richtextElement", "Rich text", RichText, "Content"),
|
|
613
|
+
item("imageElement", "Inline image", ImageBlock, "Media"),
|
|
614
|
+
item(
|
|
615
|
+
"buttonElement",
|
|
616
|
+
"Button",
|
|
617
|
+
(p) => (
|
|
618
|
+
<a className="kyro-action" href={safeStudioUrl(p.block.buttonData?.url)} {...attr(p, "buttonData.text")}>
|
|
619
|
+
{text(p.block.buttonData?.text)}
|
|
620
|
+
</a>
|
|
621
|
+
),
|
|
622
|
+
"Content",
|
|
623
|
+
{ buttonData: { text: "Explore", url: "#" } },
|
|
624
|
+
),
|
|
625
|
+
item("videoElement", "Video", Video, "Media"),
|
|
626
|
+
item(
|
|
627
|
+
"listElement",
|
|
628
|
+
"List",
|
|
629
|
+
(p) => (
|
|
630
|
+
<ul>
|
|
631
|
+
{list(p.block.items).map((v, i) => (
|
|
632
|
+
<li key={v.id || i} {...attr(p, `items.${i}.text`)}>
|
|
633
|
+
{text(v.text)}
|
|
634
|
+
</li>
|
|
635
|
+
))}
|
|
636
|
+
</ul>
|
|
637
|
+
),
|
|
638
|
+
"Content",
|
|
639
|
+
{ items: [{ text: "Your first point" }] },
|
|
640
|
+
),
|
|
641
|
+
item(
|
|
642
|
+
"quote",
|
|
643
|
+
"Quote",
|
|
644
|
+
(p) => (
|
|
645
|
+
<figure>
|
|
646
|
+
<blockquote {...attr(p, "quote")}>{text(p.block.quote)}</blockquote>
|
|
647
|
+
<figcaption {...attr(p, "author")}>{text(p.block.author)}</figcaption>
|
|
648
|
+
</figure>
|
|
649
|
+
),
|
|
650
|
+
"Content",
|
|
651
|
+
{ quote: "Words worth remembering", author: "Author" },
|
|
652
|
+
),
|
|
653
|
+
item("gallery", "Gallery", Gallery, "Media", { images: [] }),
|
|
654
|
+
item("accordion", "Accordion", FAQ, "Interactive", { items: [] }),
|
|
655
|
+
item("tabs", "Tabs", Tabs, "Interactive", { items: [{ title: "First tab", content: { type: "doc", content: [] } }] }),
|
|
656
|
+
item(
|
|
657
|
+
"iconElement",
|
|
658
|
+
"Icon",
|
|
659
|
+
(p) => {
|
|
660
|
+
const paths: Record<string, string> = {
|
|
661
|
+
check: "m5 12 4 4L19 6",
|
|
662
|
+
star: "m12 3 2.8 5.7 6.2.9-4.5 4.4 1.1 6.2-5.6-3-5.6 3 1.1-6.2L3 9.6l6.2-.9Z",
|
|
663
|
+
arrow: "M4 12h16m-6-6 6 6-6 6",
|
|
664
|
+
heart: "M20 5c-3-3-6-1-8 1-2-2-5-4-8-1-4 4 2 10 8 14 6-4 12-10 8-14",
|
|
665
|
+
};
|
|
666
|
+
if (p.block.icon && !paths[p.block.icon]) return <span {...attr(p, "icon")}><PickedIcon name={String(p.block.icon)} size={Math.max(16, Math.min(96, Number(p.block.size) || 32))} label={text(p.block.label) || "Icon"} /></span>;
|
|
667
|
+
return (
|
|
668
|
+
<svg
|
|
669
|
+
{...attr(p, "icon")}
|
|
670
|
+
width={Math.max(16, Math.min(96, Number(p.block.size) || 32))}
|
|
671
|
+
height={Math.max(16, Math.min(96, Number(p.block.size) || 32))}
|
|
672
|
+
viewBox="0 0 24 24"
|
|
673
|
+
fill="none"
|
|
674
|
+
stroke="currentColor"
|
|
675
|
+
strokeWidth="1.5"
|
|
676
|
+
role="img"
|
|
677
|
+
aria-label={text(p.block.label) || text(p.block.icon) || "Icon"}
|
|
678
|
+
>
|
|
679
|
+
<path d={paths[p.block.icon] || paths.check} />
|
|
680
|
+
</svg>
|
|
681
|
+
);
|
|
682
|
+
},
|
|
683
|
+
"Content",
|
|
684
|
+
{ icon: "check", size: 32 },
|
|
685
|
+
),
|
|
686
|
+
item(
|
|
687
|
+
"badge",
|
|
688
|
+
"Badge",
|
|
689
|
+
(p) => (
|
|
690
|
+
<span className="kyro-badge" {...attr(p, "text")}>
|
|
691
|
+
{text(p.block.text)}
|
|
692
|
+
</span>
|
|
693
|
+
),
|
|
694
|
+
"Content",
|
|
695
|
+
{ text: "New" },
|
|
696
|
+
),
|
|
697
|
+
item(
|
|
698
|
+
"notice",
|
|
699
|
+
"Notice",
|
|
700
|
+
(p) => (
|
|
701
|
+
<aside className="kyro-notice" role="note">
|
|
702
|
+
<h3 {...attr(p, "title")}>{text(p.block.title)}</h3>
|
|
703
|
+
<p {...attr(p, "content")}>{text(p.block.content)}</p>
|
|
704
|
+
</aside>
|
|
705
|
+
),
|
|
706
|
+
"Content",
|
|
707
|
+
{ title: "Good to know", content: "Share a helpful detail with your readers." },
|
|
708
|
+
),
|
|
709
|
+
];
|