@veluai/velu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/cli.js +11 -0
  2. package/package.json +52 -0
  3. package/runtime/velu-ui/base.css +311 -0
  4. package/runtime/velu-ui/components/Accordion.jsx +64 -0
  5. package/runtime/velu-ui/components/ApiClient.jsx +121 -0
  6. package/runtime/velu-ui/components/ApiField.jsx +87 -0
  7. package/runtime/velu-ui/components/ApiPath.jsx +63 -0
  8. package/runtime/velu-ui/components/ApiSidebar.jsx +122 -0
  9. package/runtime/velu-ui/components/AskBar.jsx +71 -0
  10. package/runtime/velu-ui/components/Callout.jsx +114 -0
  11. package/runtime/velu-ui/components/Card.jsx +131 -0
  12. package/runtime/velu-ui/components/Chatbot.jsx +596 -0
  13. package/runtime/velu-ui/components/CodeBlock.jsx +375 -0
  14. package/runtime/velu-ui/components/Columns.jsx +56 -0
  15. package/runtime/velu-ui/components/Field.jsx +81 -0
  16. package/runtime/velu-ui/components/Image.jsx +163 -0
  17. package/runtime/velu-ui/components/MethodBadge.jsx +31 -0
  18. package/runtime/velu-ui/components/NavSelect.jsx +108 -0
  19. package/runtime/velu-ui/components/PageFeedback.jsx +219 -0
  20. package/runtime/velu-ui/components/PageFooter.jsx +213 -0
  21. package/runtime/velu-ui/components/PageHeader.jsx +414 -0
  22. package/runtime/velu-ui/components/PageNav.jsx +77 -0
  23. package/runtime/velu-ui/components/PoweredBy.jsx +51 -0
  24. package/runtime/velu-ui/components/Prompt.jsx +115 -0
  25. package/runtime/velu-ui/components/Search.jsx +366 -0
  26. package/runtime/velu-ui/components/Sidebar.jsx +191 -0
  27. package/runtime/velu-ui/components/Steps.jsx +65 -0
  28. package/runtime/velu-ui/components/ThemeToggle.jsx +48 -0
  29. package/runtime/velu-ui/components/Toc.jsx +537 -0
  30. package/runtime/velu-ui/components/TocBar.jsx +195 -0
  31. package/runtime/velu-ui/components/Tree.jsx +87 -0
  32. package/runtime/velu-ui/components/TryItBar.jsx +90 -0
  33. package/runtime/velu-ui/components/accordion.css +92 -0
  34. package/runtime/velu-ui/components/api.css +479 -0
  35. package/runtime/velu-ui/components/ask-bar.css +94 -0
  36. package/runtime/velu-ui/components/card.css +105 -0
  37. package/runtime/velu-ui/components/chatbot.css +617 -0
  38. package/runtime/velu-ui/components/code-block.css +263 -0
  39. package/runtime/velu-ui/components/docs-layout.css +775 -0
  40. package/runtime/velu-ui/components/field.css +82 -0
  41. package/runtime/velu-ui/components/image.css +237 -0
  42. package/runtime/velu-ui/components/nav-select.css +157 -0
  43. package/runtime/velu-ui/components/page-feedback.css +241 -0
  44. package/runtime/velu-ui/components/page-footer.css +130 -0
  45. package/runtime/velu-ui/components/page-header.css +520 -0
  46. package/runtime/velu-ui/components/page-nav.css +50 -0
  47. package/runtime/velu-ui/components/powered-by.css +66 -0
  48. package/runtime/velu-ui/components/prompt.css +99 -0
  49. package/runtime/velu-ui/components/search.css +307 -0
  50. package/runtime/velu-ui/components/sidebar.css +144 -0
  51. package/runtime/velu-ui/components/steps.css +77 -0
  52. package/runtime/velu-ui/components/theme-toggle.css +70 -0
  53. package/runtime/velu-ui/components/toc-bar.css +234 -0
  54. package/runtime/velu-ui/components/tree.css +49 -0
  55. package/runtime/velu-ui/index.js +45 -0
  56. package/runtime/velu-ui/lib/copyText.js +64 -0
  57. package/runtime/velu-ui/lib/lang-icons.jsx +156 -0
  58. package/runtime/velu-ui/lib/prism-langs.js +957 -0
  59. package/runtime/velu-ui/lib/prism-loader.js +74 -0
  60. package/runtime/velu-ui/lib/resolveIcon.jsx +29 -0
  61. package/runtime/velu-ui/lib/scrollIntoNearestView.js +66 -0
  62. package/runtime/velu-ui/mdx-components.jsx +85 -0
  63. package/runtime/velu-ui/primitives/Cluster.jsx +49 -0
  64. package/runtime/velu-ui/primitives/Stack.jsx +63 -0
  65. package/runtime/velu-ui/primitives/Switcher.jsx +57 -0
  66. package/runtime/velu-ui/primitives/stack.css +3 -0
  67. package/runtime/velu-ui/primitives/switcher.css +25 -0
  68. package/runtime/velu-ui/styles.css +43 -0
  69. package/runtime/velu-ui/tokens.css +4 -0
  70. package/schema/velu.schema.json +167 -0
  71. package/src/navigation.js +434 -0
  72. package/src/runtime/App.jsx +1473 -0
  73. package/src/runtime/client-entry.jsx +22 -0
  74. package/src/runtime/server-entry.jsx +16 -0
  75. package/src/template.html +48 -0
  76. package/templates/starter/ai-tools/claude-code.mdx +26 -0
  77. package/templates/starter/ai-tools/cursor.mdx +17 -0
  78. package/templates/starter/api-reference/endpoint/create.mdx +24 -0
  79. package/templates/starter/api-reference/endpoint/get.mdx +27 -0
  80. package/templates/starter/api-reference/introduction.mdx +28 -0
  81. package/templates/starter/development.mdx +19 -0
  82. package/templates/starter/essentials/code.mdx +28 -0
  83. package/templates/starter/essentials/images.mdx +29 -0
  84. package/templates/starter/essentials/markdown.mdx +25 -0
  85. package/templates/starter/essentials/navigation.mdx +39 -0
  86. package/templates/starter/essentials/settings.mdx +30 -0
  87. package/templates/starter/favicon.svg +6 -0
  88. package/templates/starter/index.mdx +31 -0
  89. package/templates/starter/quickstart.mdx +31 -0
  90. package/templates/starter/velu.json +33 -0
@@ -0,0 +1,375 @@
1
+ import React, {
2
+ Children,
3
+ isValidElement,
4
+ useCallback,
5
+ useEffect,
6
+ useRef,
7
+ useState,
8
+ } from 'react';
9
+ import { Highlight } from 'prism-react-renderer';
10
+ import { ensureLang, hasLang, resolveLang } from '../lib/prism-loader.js';
11
+ import { iconForLang } from '../lib/lang-icons.jsx';
12
+ import resolveIcon from '../lib/resolveIcon.jsx';
13
+ import copyText from '../lib/copyText.js';
14
+
15
+ /**
16
+ * CodeBlock + CodeGroup — syntax-highlighted code with optional filename
17
+ * label or tabbed group of language alternatives.
18
+ *
19
+ * Standalone (with filename):
20
+ * <CodeBlock filename="index.js" language="javascript" lineNumbers
21
+ * icon="file-code">
22
+ * {`let greeting = function (name) {
23
+ * console.log(\`Hello, \${name}!\`);
24
+ * };`}
25
+ * </CodeBlock>
26
+ *
27
+ * Grouped (tabbed):
28
+ * <CodeGroup>
29
+ * <CodeBlock title="Javascript" language="javascript">{js}</CodeBlock>
30
+ * <CodeBlock title="Ruby" language="ruby">{rb}</CodeBlock>
31
+ * <CodeBlock title="Python" language="python">{py}</CodeBlock>
32
+ * </CodeGroup>
33
+ *
34
+ * Highlighting uses prism-react-renderer with an empty theme — token CSS
35
+ * classes (`.token.<type>`) are styled in code-block.css using
36
+ * `--syntax-*` tokens that switch per [data-theme]. Languages outside the
37
+ * prism-react-renderer default bundle are LAZY-LOADED from prismjs on
38
+ * first use via the loader in lib/prism-loader.js — SSR (and the first
39
+ * client render) shows plain code for unloaded langs, then upgrades to
40
+ * highlighted once the lang's prism file has fetched. No 1.4 MB bundle
41
+ * tax for languages the page doesn't actually use.
42
+ */
43
+
44
+ // Empty theme so prism-react-renderer emits class names but no inline
45
+ // colors — all styling lives in code-block.css.
46
+ const NO_THEME = { plain: {}, styles: [] };
47
+
48
+ function normalize(code) {
49
+ if (typeof code !== 'string') return '';
50
+ return code.replace(/^\n+/, '').replace(/\n+$/, '');
51
+ }
52
+
53
+ // Parse a highlight spec into a Set of 1-based line numbers.
54
+ // "1-3,5,7-9" → {1,2,3,5,7,8,9}
55
+ // [1, 2, 5] → {1,2,5}
56
+ // null / '' → null (nothing highlighted)
57
+ function parseHighlight(spec) {
58
+ if (spec == null || spec === '') return null;
59
+ if (Array.isArray(spec)) {
60
+ const s = new Set();
61
+ for (const n of spec) {
62
+ const v = Number(n);
63
+ if (Number.isFinite(v)) s.add(v);
64
+ }
65
+ return s.size ? s : null;
66
+ }
67
+ if (typeof spec !== 'string') return null;
68
+ const s = new Set();
69
+ for (const part of spec.split(',')) {
70
+ const t = part.trim();
71
+ if (!t) continue;
72
+ const dash = t.indexOf('-');
73
+ if (dash > 0) {
74
+ const a = parseInt(t.slice(0, dash), 10);
75
+ const b = parseInt(t.slice(dash + 1), 10);
76
+ if (Number.isFinite(a) && Number.isFinite(b)) {
77
+ const lo = Math.min(a, b);
78
+ const hi = Math.max(a, b);
79
+ for (let i = lo; i <= hi; i++) s.add(i);
80
+ }
81
+ } else {
82
+ const n = parseInt(t, 10);
83
+ if (Number.isFinite(n)) s.add(n);
84
+ }
85
+ }
86
+ return s.size ? s : null;
87
+ }
88
+
89
+ function TabLabel({ icon, label }) {
90
+ return (
91
+ <>
92
+ {icon != null && (
93
+ <span className="velu-code-block__tab-icon" aria-hidden="true">
94
+ {typeof icon === 'string' ? resolveIcon(icon, { size: '1em' }) : icon}
95
+ </span>
96
+ )}
97
+ <span className="velu-code-block__tab-label">{label}</span>
98
+ </>
99
+ );
100
+ }
101
+
102
+ function Tab({ active, onClick, icon, label }) {
103
+ const cls = `velu-code-block__tab${
104
+ active ? ' velu-code-block__tab--active' : ''
105
+ }`;
106
+ if (onClick) {
107
+ return (
108
+ <button
109
+ type="button"
110
+ role="tab"
111
+ aria-selected={active}
112
+ className={cls}
113
+ onClick={onClick}
114
+ >
115
+ <TabLabel icon={icon} label={label} />
116
+ </button>
117
+ );
118
+ }
119
+ return (
120
+ <div className={cls}>
121
+ <TabLabel icon={icon} label={label} />
122
+ </div>
123
+ );
124
+ }
125
+
126
+ function CopyButton({ code }) {
127
+ const [copied, setCopied] = useState(false);
128
+
129
+ function copy() {
130
+ copyText(code).then(
131
+ () => {
132
+ setCopied(true);
133
+ setTimeout(() => setCopied(false), 1400);
134
+ },
135
+ () => {
136
+ /* clipboard write rejected (permissions / no focus) — silently noop */
137
+ },
138
+ );
139
+ }
140
+
141
+ return (
142
+ <button
143
+ type="button"
144
+ onClick={copy}
145
+ className="velu-code-block__copy"
146
+ aria-label={copied ? 'Copied' : 'Copy code'}
147
+ title={copied ? 'Copied' : 'Copy'}
148
+ >
149
+ {resolveIcon(copied ? 'check' : 'copy', { size: '1em' })}
150
+ </button>
151
+ );
152
+ }
153
+
154
+ function CodeBody({ code, language, lineNumbers, highlight }) {
155
+ const canonical = resolveLang(language) || 'text';
156
+ const highlightSet = parseHighlight(highlight);
157
+
158
+ // Initial render uses 'text' (no highlighting) — this guarantees SSR
159
+ // and the first client render produce identical HTML regardless of
160
+ // what's in Prism.languages on each side (which may diverge in dev
161
+ // mode due to HMR leaving cached grammar mutations behind). After
162
+ // hydration, useEffect kicks ensureLang and bumps to the real lang —
163
+ // highlighting then upgrades in a normal state-update render.
164
+ const [renderLang, setRenderLang] = useState('text');
165
+
166
+ useEffect(() => {
167
+ let cancelled = false;
168
+ ensureLang(canonical).then(() => {
169
+ if (!cancelled && hasLang(canonical)) setRenderLang(canonical);
170
+ });
171
+ return () => {
172
+ cancelled = true;
173
+ };
174
+ }, [canonical]);
175
+
176
+ return (
177
+ <div className="velu-code-block__body">
178
+ <CopyButton code={normalize(code)} />
179
+ <Highlight
180
+ code={normalize(code)}
181
+ language={renderLang}
182
+ theme={NO_THEME}
183
+ >
184
+ {({ tokens, getLineProps, getTokenProps }) => (
185
+ <pre className="velu-code-block__pre">
186
+ {tokens.map((line, i) => {
187
+ const lineProps = getLineProps({ line });
188
+ const isHi = highlightSet?.has(i + 1);
189
+ return (
190
+ <div
191
+ key={i}
192
+ {...lineProps}
193
+ className={`velu-code-block__line ${
194
+ lineProps.className || ''
195
+ } ${isHi ? 'velu-code-block__line--highlight' : ''}`.trim()}
196
+ >
197
+ {lineNumbers && (
198
+ <span
199
+ className="velu-code-block__line-number"
200
+ aria-hidden="true"
201
+ >
202
+ {i + 1}
203
+ </span>
204
+ )}
205
+ <span className="velu-code-block__line-code">
206
+ {line.map((token, j) => (
207
+ <span key={j} {...getTokenProps({ token })} />
208
+ ))}
209
+ </span>
210
+ </div>
211
+ );
212
+ })}
213
+ </pre>
214
+ )}
215
+ </Highlight>
216
+ </div>
217
+ );
218
+ }
219
+
220
+ // Explicit `icon` always wins. `withIcon` defaults to true, so an icon
221
+ // is auto-rendered from `lib/lang-icons.jsx` based on the language;
222
+ // pass `withIcon={false}` to suppress.
223
+ function pickIcon({ icon, withIcon, language }) {
224
+ if (icon != null) return icon;
225
+ if (withIcon === false) return null;
226
+ return iconForLang(language);
227
+ }
228
+
229
+ export function CodeBlock({
230
+ filename,
231
+ title,
232
+ language = 'text',
233
+ icon,
234
+ withIcon = true,
235
+ lineNumbers = false,
236
+ highlight,
237
+ children,
238
+ className = '',
239
+ ...rest
240
+ }) {
241
+ const cls = `velu-code-block ${className}`.trim();
242
+ const label = filename || title;
243
+ const tabIcon = pickIcon({ icon, withIcon, language });
244
+ return (
245
+ <div className={cls} {...rest}>
246
+ {label && (
247
+ <div className="velu-code-block__header">
248
+ <Tab active icon={tabIcon} label={label} />
249
+ </div>
250
+ )}
251
+ <CodeBody
252
+ code={children}
253
+ language={language}
254
+ lineNumbers={lineNumbers}
255
+ highlight={highlight}
256
+ />
257
+ </div>
258
+ );
259
+ }
260
+ CodeBlock.displayName = 'CodeBlock';
261
+
262
+ // Hook that tracks whether a scrollable element can scroll further left
263
+ // or right. Resolves layout-driven overflow without media queries.
264
+ function useScrollEdges(ref) {
265
+ const [canLeft, setCanLeft] = useState(false);
266
+ const [canRight, setCanRight] = useState(false);
267
+
268
+ const update = useCallback(() => {
269
+ const el = ref.current;
270
+ if (!el) return;
271
+ setCanLeft(el.scrollLeft > 1);
272
+ setCanRight(el.scrollLeft + el.clientWidth < el.scrollWidth - 1);
273
+ }, [ref]);
274
+
275
+ useEffect(() => {
276
+ const el = ref.current;
277
+ if (!el) return;
278
+ update();
279
+ const ro = new ResizeObserver(update);
280
+ ro.observe(el);
281
+ // Also observe each child so adding/removing tabs retriggers update.
282
+ for (const c of el.children) ro.observe(c);
283
+ el.addEventListener('scroll', update, { passive: true });
284
+ return () => {
285
+ ro.disconnect();
286
+ el.removeEventListener('scroll', update);
287
+ };
288
+ }, [ref, update]);
289
+
290
+ return { canLeft, canRight, update };
291
+ }
292
+
293
+ export function CodeGroup({
294
+ children,
295
+ className = '',
296
+ defaultIndex = 0,
297
+ ...rest
298
+ }) {
299
+ const blocks = Children.toArray(children).filter(
300
+ (c) =>
301
+ isValidElement(c) &&
302
+ (c.type === CodeBlock || c.type?.displayName === 'CodeBlock'),
303
+ );
304
+ const [active, setActive] = useState(defaultIndex);
305
+ const tabsRef = useRef(null);
306
+ const { canLeft, canRight } = useScrollEdges(tabsRef);
307
+ const block = blocks[active] || blocks[0];
308
+ if (!block) return null;
309
+
310
+ const {
311
+ language = 'text',
312
+ lineNumbers = false,
313
+ highlight,
314
+ children: code,
315
+ } = block.props;
316
+ const cls = `velu-code-block velu-code-block--group ${className}`.trim();
317
+
318
+ function scrollDir(dir) {
319
+ tabsRef.current?.scrollBy({ left: dir * 160, behavior: 'smooth' });
320
+ }
321
+
322
+ return (
323
+ <div className={cls} {...rest}>
324
+ <div className="velu-code-block__header">
325
+ {canLeft && (
326
+ <button
327
+ type="button"
328
+ className="velu-code-block__nav"
329
+ onClick={() => scrollDir(-1)}
330
+ aria-label="Scroll tabs left"
331
+ >
332
+ {resolveIcon('chevron-left', { size: '1em' })}
333
+ </button>
334
+ )}
335
+ <div
336
+ ref={tabsRef}
337
+ className="velu-code-block__tabs"
338
+ role="tablist"
339
+ >
340
+ {blocks.map((b, i) => {
341
+ const { title, icon, withIcon, language } = b.props;
342
+ const tabIcon = pickIcon({ icon, withIcon, language });
343
+ return (
344
+ <Tab
345
+ key={i}
346
+ active={i === active}
347
+ onClick={() => setActive(i)}
348
+ icon={tabIcon}
349
+ label={title || `Tab ${i + 1}`}
350
+ />
351
+ );
352
+ })}
353
+ </div>
354
+ {canRight && (
355
+ <button
356
+ type="button"
357
+ className="velu-code-block__nav"
358
+ onClick={() => scrollDir(1)}
359
+ aria-label="Scroll tabs right"
360
+ >
361
+ {resolveIcon('chevron-right', { size: '1em' })}
362
+ </button>
363
+ )}
364
+ </div>
365
+ <CodeBody
366
+ code={code}
367
+ language={language}
368
+ lineNumbers={lineNumbers}
369
+ highlight={highlight}
370
+ />
371
+ </div>
372
+ );
373
+ }
374
+
375
+ export default CodeBlock;
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import Switcher from '../primitives/Switcher.jsx';
3
+
4
+ /**
5
+ * Columns — generic column layout for heterogeneous content (Card,
6
+ * Callout, CodeBlock, Image, plain JSX — anything). Thin wrapper over
7
+ * the Switcher primitive, mirroring CardGroup's responsive pattern but
8
+ * without coupling to any specific child component.
9
+ *
10
+ * <Columns cols={2}>
11
+ * <Card title="A" />
12
+ * <CodeBlock language="js">{snippet}</CodeBlock>
13
+ * </Columns>
14
+ *
15
+ * Behavior:
16
+ * - `cols` (default 2) — max number of items in a row. Acts as
17
+ * Switcher's `limit`: passing more children than `cols` collapses
18
+ * the layout to a full vertical stack (matches CardGroup).
19
+ * - `min` — per-item minimum width (default --columns-min token, 18ch).
20
+ * The instant any one column would fall below `min`, all columns
21
+ * stack vertically. Driven by Switcher's count-aware threshold
22
+ * math; no media queries.
23
+ * - `space` — gap between items (default --s1).
24
+ *
25
+ * Want multiple items in a single column? Wrap them in a Stack:
26
+ *
27
+ * <Columns cols={3}>
28
+ * <Card title="left" />
29
+ * <Stack>
30
+ * <Card title="middle top" />
31
+ * <Card title="middle bottom" />
32
+ * </Stack>
33
+ * <Callout>right</Callout>
34
+ * </Columns>
35
+ */
36
+
37
+ export default function Columns({
38
+ cols = 2,
39
+ space = 'var(--s1)',
40
+ min = 'var(--columns-min, 18ch)',
41
+ children,
42
+ className = '',
43
+ ...rest
44
+ }) {
45
+ return (
46
+ <Switcher
47
+ className={`velu-columns ${className}`.trim()}
48
+ space={space}
49
+ min={min}
50
+ limit={cols}
51
+ {...rest}
52
+ >
53
+ {children}
54
+ </Switcher>
55
+ );
56
+ }
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ import Cluster from '../primitives/Cluster.jsx';
3
+
4
+ /**
5
+ * Field — a documentation row for an API parameter / config option.
6
+ *
7
+ * <Field name="depth" pre="GET" type="number" required default={3}
8
+ * post="optional"
9
+ * >
10
+ * An example of a parameter field. Description text wraps below
11
+ * the chip row.
12
+ * </Field>
13
+ *
14
+ * Layout (left → right, all in a single flex-wrap row):
15
+ * [pre chip] [name] [type chip] [required pill]
16
+ * [default: VALUE] [post chip] followed by the description
17
+ *
18
+ * - `name` — required-ish; the parameter identifier (accent, bold, mono)
19
+ * - `pre` — small monospace chip rendered before `name` (e.g. method
20
+ * or namespace). React-node or string.
21
+ * - `type` — small monospace chip after `name` (e.g. "string", "number")
22
+ * - `required` — boolean → renders the red "required" pill
23
+ * - `default` — value rendered as `default: <value>` in italic monospace
24
+ * (renamed locally because `default` is a reserved word)
25
+ * - `post` — trailing chip after default
26
+ * - `children` — description block beneath the chip row
27
+ *
28
+ * Sibling Field elements get a hairline divider via CSS — drop them next
29
+ * to each other and the separators appear; no wrapper required.
30
+ *
31
+ * Fully tokenized: chips use --surface-color, required pill mixes with
32
+ * --accent-color, default is --muted-color italic. Light/dark
33
+ * automatic via [data-theme] like the rest of velu-ui.
34
+ */
35
+
36
+ export default function Field({
37
+ name,
38
+ pre,
39
+ type,
40
+ required = false,
41
+ default: defaultValue,
42
+ post,
43
+ children,
44
+ className = '',
45
+ ...rest
46
+ }) {
47
+ const hasDefault = defaultValue !== undefined && defaultValue !== null;
48
+ return (
49
+ <div className={`velu-field ${className}`.trim()} {...rest}>
50
+ {/* Cluster handles the wrap-friendly inline row layout — chips +
51
+ name + type + required + default + post — with a 16px gap and
52
+ baseline alignment so the bold name doesn't shift vertically
53
+ relative to its sibling chips. */}
54
+ <Cluster space="var(--s0)" align="baseline">
55
+ {pre != null && (
56
+ <span className="velu-field__chip">{pre}</span>
57
+ )}
58
+ {name != null && (
59
+ <span className="velu-field__name">{name}</span>
60
+ )}
61
+ {type != null && (
62
+ <span className="velu-field__chip">{type}</span>
63
+ )}
64
+ {required && (
65
+ <span className="velu-field__required">required</span>
66
+ )}
67
+ {hasDefault && (
68
+ <span className="velu-field__default">
69
+ default: {String(defaultValue)}
70
+ </span>
71
+ )}
72
+ {post != null && (
73
+ <span className="velu-field__chip">{post}</span>
74
+ )}
75
+ </Cluster>
76
+ {children != null && children !== false && (
77
+ <div className="velu-field__body">{children}</div>
78
+ )}
79
+ </div>
80
+ );
81
+ }
@@ -0,0 +1,163 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Image — image content with optional caption and decorative chrome.
5
+ *
6
+ * Variants:
7
+ * - plain <Image src alt />
8
+ * - captioned <Image src alt caption="..." />
9
+ * - window <Image src alt chrome="window" caption?/>
10
+ * - frame <Image src alt chrome="frame" caption?/>
11
+ *
12
+ * Window/frame use a pure SVG+CSS liquid-glass pattern (lucasromerodb/
13
+ * liquid-glass-effect-macos): an SVG <filter> with feTurbulence →
14
+ * feDisplacementMap provides real refraction; a 4-layer div stack
15
+ * (effect/tint/shine/content) builds the glass material.
16
+ * No library, no SSR/hydration concerns — pure declarative DOM + CSS.
17
+ */
18
+
19
+ const GLASS_FILTER_ID = 'velu-glass-distortion';
20
+
21
+ function GlassFilterDefs() {
22
+ return (
23
+ <svg
24
+ aria-hidden="true"
25
+ style={{ position: 'absolute', inlineSize: 0, blockSize: 0 }}
26
+ >
27
+ {/* Turbulence-driven displacement of the backdrop. Used via
28
+ `backdrop-filter: url(#...)` so SourceGraphic IS the backdrop. */}
29
+ <filter
30
+ id={GLASS_FILTER_ID}
31
+ x="0%"
32
+ y="0%"
33
+ width="100%"
34
+ height="100%"
35
+ filterUnits="objectBoundingBox"
36
+ >
37
+ <feTurbulence
38
+ type="fractalNoise"
39
+ baseFrequency="0.008 0.008"
40
+ numOctaves="2"
41
+ seed="5"
42
+ result="noise"
43
+ />
44
+ <feDisplacementMap
45
+ in="SourceGraphic"
46
+ in2="noise"
47
+ scale="80"
48
+ xChannelSelector="R"
49
+ yChannelSelector="G"
50
+ />
51
+ </filter>
52
+ </svg>
53
+ );
54
+ }
55
+
56
+ function Glass({ className = '', children }) {
57
+ return (
58
+ <div className={`velu-glass ${className}`.trim()}>
59
+ <div className="velu-glass__effect" aria-hidden="true" />
60
+ <div className="velu-glass__tint" aria-hidden="true" />
61
+ <div className="velu-glass__shine" aria-hidden="true" />
62
+ <div className="velu-glass__content">{children}</div>
63
+ </div>
64
+ );
65
+ }
66
+
67
+ function WindowChrome({ src, alt }) {
68
+ return (
69
+ <div className="velu-image__window">
70
+ <GlassFilterDefs />
71
+ <div className="velu-image__glow" aria-hidden="true" />
72
+ <div className="velu-image__noise" aria-hidden="true" />
73
+ <Glass className="velu-image__window-surface">
74
+ <div className="velu-image__window-inner">
75
+ <Glass className="velu-image__chrome">
76
+ <span className="velu-image__dots" aria-hidden="true">
77
+ <span className="velu-image__dot velu-image__dot--red" />
78
+ <span className="velu-image__dot velu-image__dot--yellow" />
79
+ <span className="velu-image__dot velu-image__dot--green" />
80
+ </span>
81
+ <span className="velu-image__urlbar" aria-hidden="true" />
82
+ </Glass>
83
+ <img
84
+ src={src}
85
+ alt={alt}
86
+ loading="lazy"
87
+ className="velu-image__img velu-image__img--flush"
88
+ />
89
+ </div>
90
+ </Glass>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ function DeviceFrame({ src, alt }) {
96
+ return (
97
+ <div className="velu-image__frame">
98
+ <GlassFilterDefs />
99
+ <div className="velu-image__glow" aria-hidden="true" />
100
+ <div className="velu-image__noise" aria-hidden="true" />
101
+ <Glass className="velu-image__frame-bezel">
102
+ <div className="velu-image__frame-screen">
103
+ <img
104
+ src={src}
105
+ alt={alt}
106
+ loading="lazy"
107
+ className="velu-image__img velu-image__img--flush"
108
+ />
109
+ </div>
110
+ </Glass>
111
+ </div>
112
+ );
113
+ }
114
+
115
+ export default function Image({
116
+ src,
117
+ alt = '',
118
+ caption,
119
+ chrome,
120
+ className = '',
121
+ ...rest
122
+ }) {
123
+ // Fall back to the caption for alt text when no alt is provided, so a
124
+ // captioned image stays accessible without forcing duplication.
125
+ // Only string captions are usable as alt — React-node captions are
126
+ // ignored here.
127
+ const effectiveAlt = alt || (typeof caption === 'string' ? caption : '');
128
+
129
+ let body;
130
+ let variantClass = '';
131
+ if (chrome === 'window') {
132
+ body = <WindowChrome src={src} alt={effectiveAlt} />;
133
+ variantClass = 'velu-image--chrome';
134
+ } else if (chrome === 'frame') {
135
+ body = <DeviceFrame src={src} alt={effectiveAlt} />;
136
+ variantClass = 'velu-image--chrome';
137
+ } else {
138
+ body = (
139
+ <img
140
+ src={src}
141
+ alt={effectiveAlt}
142
+ loading="lazy"
143
+ className="velu-image__img"
144
+ />
145
+ );
146
+ }
147
+
148
+ const cls = `velu-image ${variantClass} ${className}`.trim();
149
+
150
+ if (caption) {
151
+ return (
152
+ <figure className={cls} {...rest}>
153
+ {body}
154
+ <figcaption className="velu-image__caption">{caption}</figcaption>
155
+ </figure>
156
+ );
157
+ }
158
+ return (
159
+ <div className={cls} {...rest}>
160
+ {body}
161
+ </div>
162
+ );
163
+ }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+
3
+ /**
4
+ * MethodBadge — colored monospace pill showing an HTTP method.
5
+ *
6
+ * <MethodBadge method="POST" />
7
+ *
8
+ * Colors come from the per-method tokens in base.css:
9
+ * --post-pill-color / --post-pill-stroke-color (and post-cta-color)
10
+ * --get-* / --put-* / --delete-* / --patch-*
11
+ *
12
+ * Used by <ApiPath>, <TryItBar>, and <ApiClient>; also exportable
13
+ * standalone for inline endpoint references in prose.
14
+ */
15
+
16
+ const METHODS = ['get', 'post', 'put', 'patch', 'delete'];
17
+
18
+ export default function MethodBadge({
19
+ method = 'GET',
20
+ className = '',
21
+ ...rest
22
+ }) {
23
+ const key = String(method).toLowerCase();
24
+ const safe = METHODS.includes(key) ? key : 'get';
25
+ const cls = `velu-method-badge velu-method-badge--${safe} ${className}`.trim();
26
+ return (
27
+ <span className={cls} {...rest}>
28
+ {String(method).toUpperCase()}
29
+ </span>
30
+ );
31
+ }