radiant-docs 0.1.47 → 0.1.48
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/package.json +1 -1
- package/template/src/components/OpenApiPage.astro +121 -64
- package/template/src/components/PagePagination.astro +1 -1
- package/template/src/components/SidebarSubgroup.astro +1 -1
- package/template/src/components/endpoint/RequestSnippets.astro +175 -16
- package/template/src/components/endpoint/ResponseDisplay.astro +21 -16
- package/template/src/components/endpoint/ResponseSnippets.astro +175 -16
- package/template/src/components/ui/CodeTabEdge.astro +11 -60
- package/template/src/components/user/Callout.astro +1 -1
- package/template/src/components/user/CodeBlock.astro +31 -20
- package/template/src/components/user/CodeGroup.astro +46 -36
- package/template/src/lib/code/code-block.ts +89 -10
- package/template/src/lib/code/shiki-theme-config.ts +16 -0
- package/template/src/lib/validation.ts +137 -0
- package/template/src/styles/global.css +51 -3
|
@@ -244,14 +244,37 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
244
244
|
pillLeft: 0,
|
|
245
245
|
pillWidth: 0,
|
|
246
246
|
pillVisible: false,
|
|
247
|
+
previousSelected: null,
|
|
248
|
+
isTransitioning: false,
|
|
249
|
+
isManagedSlot: false,
|
|
250
|
+
transitionDirection: 1,
|
|
251
|
+
transitionDurationMs: 360,
|
|
252
|
+
transitionEasing: "cubic-bezier(0.22, 1, 0.36, 1)",
|
|
247
253
|
tabSyncHandler: null,
|
|
254
|
+
transitionTimeoutId: null,
|
|
248
255
|
copyTimeoutId: null,
|
|
249
256
|
init() {
|
|
250
|
-
|
|
251
|
-
|
|
257
|
+
this.isManagedSlot = !!this.$root?.closest("[data-snippet-slot]");
|
|
258
|
+
if (
|
|
259
|
+
typeof window.matchMedia === "function" &&
|
|
260
|
+
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
261
|
+
) {
|
|
262
|
+
this.transitionDurationMs = 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const sync = () => {
|
|
266
|
+
this.syncPill();
|
|
267
|
+
this.syncSnippetHeight();
|
|
268
|
+
};
|
|
252
269
|
this.tabSyncHandler = sync;
|
|
253
270
|
this.$nextTick(() => {
|
|
271
|
+
if (this.$refs.snippetPanels) {
|
|
272
|
+
this.$refs.snippetPanels.style.transitionDuration =
|
|
273
|
+
this.transitionDurationMs + "ms";
|
|
274
|
+
}
|
|
254
275
|
this.syncPill();
|
|
276
|
+
this.syncSnippetHeight();
|
|
277
|
+
if (!this.hasMultiple) return;
|
|
255
278
|
this.$refs.tabList?.addEventListener("scroll", sync, {
|
|
256
279
|
passive: true,
|
|
257
280
|
});
|
|
@@ -275,13 +298,96 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
275
298
|
this.pillWidth = activeRect.width;
|
|
276
299
|
this.pillVisible = true;
|
|
277
300
|
},
|
|
301
|
+
getPanelHeight(panel) {
|
|
302
|
+
if (!panel) return 0;
|
|
303
|
+
const child = panel.firstElementChild;
|
|
304
|
+
const childHeight =
|
|
305
|
+
child instanceof HTMLElement ? child.scrollHeight : 0;
|
|
306
|
+
return Math.ceil(
|
|
307
|
+
Math.max(panel.scrollHeight, childHeight, panel.getBoundingClientRect().height),
|
|
308
|
+
);
|
|
309
|
+
},
|
|
310
|
+
syncSnippetHeight() {
|
|
311
|
+
const panels = this.$refs.snippetPanels;
|
|
312
|
+
if (!panels) return;
|
|
313
|
+
if (this.isManagedSlot) {
|
|
314
|
+
panels.style.height = "";
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
const activePanel = panels.querySelector(
|
|
318
|
+
'[data-snippet-index="' + this.selected + '"]',
|
|
319
|
+
);
|
|
320
|
+
const activeHeight = this.getPanelHeight(activePanel);
|
|
321
|
+
if (activeHeight > 0) {
|
|
322
|
+
panels.style.height = activeHeight + "px";
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
finishTransition() {
|
|
326
|
+
this.isTransitioning = false;
|
|
327
|
+
this.previousSelected = null;
|
|
328
|
+
this.transitionTimeoutId = null;
|
|
329
|
+
this.$nextTick(() => {
|
|
330
|
+
this.syncSnippetHeight();
|
|
331
|
+
window.dispatchEvent(new CustomEvent("rd:snippet-content-change"));
|
|
332
|
+
});
|
|
333
|
+
},
|
|
278
334
|
select(index) {
|
|
335
|
+
if (index === this.selected) return;
|
|
336
|
+
|
|
337
|
+
if (this.transitionTimeoutId) {
|
|
338
|
+
window.clearTimeout(this.transitionTimeoutId);
|
|
339
|
+
this.transitionTimeoutId = null;
|
|
340
|
+
this.isTransitioning = false;
|
|
341
|
+
this.previousSelected = null;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
const previousIndex = this.selected;
|
|
345
|
+
this.previousSelected = previousIndex;
|
|
346
|
+
this.transitionDirection = index > previousIndex ? 1 : -1;
|
|
279
347
|
this.selected = index;
|
|
348
|
+
this.isTransitioning = true;
|
|
280
349
|
this.$nextTick(() => {
|
|
281
350
|
this.syncPill();
|
|
351
|
+
this.syncSnippetHeight();
|
|
282
352
|
window.dispatchEvent(new CustomEvent("rd:snippet-content-change"));
|
|
353
|
+
|
|
354
|
+
if (this.transitionDurationMs === 0) {
|
|
355
|
+
this.finishTransition();
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
this.transitionTimeoutId = window.setTimeout(() => {
|
|
360
|
+
this.finishTransition();
|
|
361
|
+
}, this.transitionDurationMs);
|
|
283
362
|
});
|
|
284
363
|
},
|
|
364
|
+
getPanelStyle(index) {
|
|
365
|
+
const base = "position: absolute; top: 0; right: 0; left: 0;";
|
|
366
|
+
const isActive = index === this.selected;
|
|
367
|
+
const isPrevious = this.isTransitioning && index === this.previousSelected;
|
|
368
|
+
|
|
369
|
+
if (!isActive && !isPrevious) {
|
|
370
|
+
return "display: none; opacity: 0; pointer-events: none; visibility: hidden; z-index: 0;";
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (!this.isTransitioning) {
|
|
374
|
+
return "position: relative; transform: translateX(0); opacity: 1; pointer-events: auto; visibility: visible; z-index: 1;";
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
if (isActive) {
|
|
378
|
+
const animationName =
|
|
379
|
+
this.transitionDirection === 1
|
|
380
|
+
? "rd-snippet-slide-in-from-right"
|
|
381
|
+
: "rd-snippet-slide-in-from-left";
|
|
382
|
+
return "position: relative; opacity: 1; pointer-events: auto; visibility: visible; z-index: 2; animation: " + animationName + " " + this.transitionDurationMs + "ms " + this.transitionEasing + " both;";
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
const animationName =
|
|
386
|
+
this.transitionDirection === 1
|
|
387
|
+
? "rd-snippet-slide-out-to-left"
|
|
388
|
+
: "rd-snippet-slide-out-to-right";
|
|
389
|
+
return base + " opacity: 1; pointer-events: none; visibility: visible; z-index: 1; animation: " + animationName + " " + this.transitionDurationMs + "ms " + this.transitionEasing + " both;";
|
|
390
|
+
},
|
|
285
391
|
async copySelected() {
|
|
286
392
|
const snippet = this.snippets[this.selected];
|
|
287
393
|
if (!snippet) return;
|
|
@@ -306,10 +412,10 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
306
412
|
>
|
|
307
413
|
<div class="group/prose-code not-prose relative h-full min-h-0 w-full max-w-full min-w-0">
|
|
308
414
|
<div
|
|
309
|
-
class="flex h-full min-h-0 w-full max-w-full min-w-0 flex-col
|
|
415
|
+
class="flex h-full min-h-0 w-full max-w-full min-w-0 flex-col rounded-xl"
|
|
310
416
|
>
|
|
311
417
|
<div
|
|
312
|
-
class="flex items-center justify-between gap-2
|
|
418
|
+
class="flex items-center justify-between gap-2 bg-(--rd-code-header-surface)"
|
|
313
419
|
>
|
|
314
420
|
{
|
|
315
421
|
hasMultipleResponses ? (
|
|
@@ -320,7 +426,7 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
320
426
|
>
|
|
321
427
|
<div
|
|
322
428
|
aria-hidden="true"
|
|
323
|
-
class="pointer-events-none absolute top-1/2 z-0 h-[28px] -translate-y-1/2 rounded-
|
|
429
|
+
class="pointer-events-none absolute top-1/2 z-0 h-[28px] -translate-y-1/2 rounded-[9px] border-[0.5px] border-(--rd-code-tab-edge-border) bg-(--rd-code-surface) transition-[left,width,opacity] duration-200 ease-out"
|
|
324
430
|
x-bind:class="pillVisible ? 'opacity-100' : 'opacity-0'"
|
|
325
431
|
x-bind:style="'left:' + pillLeft + 'px;width:' + pillWidth + 'px;'"
|
|
326
432
|
/>
|
|
@@ -346,13 +452,13 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
346
452
|
</div>
|
|
347
453
|
) : (
|
|
348
454
|
<div class="min-w-0 flex-1">
|
|
349
|
-
<div class="relative h-9 w-fit max-w-full rounded-tl-xl bg-
|
|
350
|
-
<div class="absolute inset-x-0 -bottom-px h-px bg-
|
|
455
|
+
<div class="relative h-9 w-fit max-w-full rounded-tl-xl bg-(--rd-code-surface)">
|
|
456
|
+
<div class="absolute inset-x-0 -bottom-px h-px bg-(--rd-code-surface)"></div>
|
|
351
457
|
<CodeTabEdge
|
|
352
|
-
className="pointer-events-none absolute -top-
|
|
458
|
+
className="pointer-events-none absolute -top-[0.5px] left-full z-10 h-[calc(100%+1.5px)]"
|
|
353
459
|
/>
|
|
354
460
|
|
|
355
|
-
<div class="relative z-20 inline-flex h-9 max-w-full items-center gap-2 pl-5 pr-3 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300">
|
|
461
|
+
<div class="relative z-20 inline-flex h-9 max-w-full items-center gap-2 rounded-tl-xl border-t-[0.5px] border-l-[0.5px] border-(--rd-code-tab-edge-border) pl-5 pr-3 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300">
|
|
356
462
|
<span
|
|
357
463
|
class="size-[7px] shrink-0 rounded-full"
|
|
358
464
|
class:list={[firstResponse.dotClass]}></span>
|
|
@@ -363,8 +469,8 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
363
469
|
)
|
|
364
470
|
}
|
|
365
471
|
|
|
366
|
-
<div class="relative h-9 w-5 shrink-0 rounded-tr-xl bg-
|
|
367
|
-
<div class="absolute inset-x-0 -bottom-px h-px bg-
|
|
472
|
+
<div class="relative h-9 w-5 shrink-0 rounded-tr-xl bg-(--rd-code-surface) border-t-[0.5px] border-r-[0.5px] border-(--rd-code-tab-edge-border)">
|
|
473
|
+
<div class="absolute inset-x-0 -bottom-px h-px bg-(--rd-code-surface)"></div>
|
|
368
474
|
<CodeTabEdge
|
|
369
475
|
className="pointer-events-none absolute -top-px right-full z-10 h-[calc(100%+2px)] rotate-y-180"
|
|
370
476
|
/>
|
|
@@ -390,14 +496,21 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
390
496
|
</div>
|
|
391
497
|
</div>
|
|
392
498
|
|
|
393
|
-
<div class="relative min-h-0 min-w-0 flex-1 overflow-hidden rounded-b-xl">
|
|
394
|
-
<div
|
|
395
|
-
|
|
499
|
+
<div class="relative min-h-0 min-w-0 flex-1 overflow-hidden rounded-b-xl rounded-tl-xl border-[0.5px] border-(--rd-code-tab-edge-border) bg-(--rd-code-surface)">
|
|
500
|
+
<div
|
|
501
|
+
x-ref="snippetPanels"
|
|
502
|
+
class="relative h-full overflow-auto transition-[height] duration-[360ms] ease-[cubic-bezier(0.22,1,0.36,1)] [scrollbar-width:thin] [scrollbar-color:var(--color-neutral-300)_transparent] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-neutral-300/70 hover:[&::-webkit-scrollbar-thumb]:bg-neutral-300/90 dark:[scrollbar-color:var(--color-neutral-700)_transparent] dark:[&::-webkit-scrollbar-thumb]:bg-neutral-700/70 dark:hover:[&::-webkit-scrollbar-thumb]:bg-neutral-700/90"
|
|
503
|
+
>
|
|
396
504
|
{
|
|
397
505
|
responseSnippetItems.map((snippet, index) => (
|
|
398
506
|
<pre
|
|
399
|
-
class="relative m-0 min-w-full
|
|
400
|
-
x-
|
|
507
|
+
class="relative m-0 min-w-full p-0 text-[13px] leading-6"
|
|
508
|
+
x-bind:style={`getPanelStyle(${index})`}
|
|
509
|
+
style={
|
|
510
|
+
index === 0
|
|
511
|
+
? "position: relative;"
|
|
512
|
+
: "display: none; position: absolute; top: 0; right: 0; left: 0; opacity: 0; visibility: hidden; pointer-events: none;"
|
|
513
|
+
}
|
|
401
514
|
{...(index !== 0 ? { "x-cloak": true } : {})}
|
|
402
515
|
data-snippet-index={index}
|
|
403
516
|
><code data-rd-code-theme class="block min-w-full py-2.5 font-mono text-neutral-800 dark:text-neutral-200"><Fragment set:html={snippet.renderedCodeLinesHtml} /></code></pre>
|
|
@@ -408,3 +521,49 @@ const hasMultipleResponses = responseSnippetItems.length > 1;
|
|
|
408
521
|
</div>
|
|
409
522
|
</div>
|
|
410
523
|
</div>
|
|
524
|
+
|
|
525
|
+
<style>
|
|
526
|
+
@keyframes rd-snippet-slide-in-from-right {
|
|
527
|
+
from {
|
|
528
|
+
transform: translateX(100%);
|
|
529
|
+
opacity: 0;
|
|
530
|
+
}
|
|
531
|
+
to {
|
|
532
|
+
transform: translateX(0);
|
|
533
|
+
opacity: 1;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
@keyframes rd-snippet-slide-in-from-left {
|
|
538
|
+
from {
|
|
539
|
+
transform: translateX(-100%);
|
|
540
|
+
opacity: 0;
|
|
541
|
+
}
|
|
542
|
+
to {
|
|
543
|
+
transform: translateX(0);
|
|
544
|
+
opacity: 1;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
@keyframes rd-snippet-slide-out-to-left {
|
|
549
|
+
from {
|
|
550
|
+
transform: translateX(0);
|
|
551
|
+
opacity: 1;
|
|
552
|
+
}
|
|
553
|
+
to {
|
|
554
|
+
transform: translateX(-100%);
|
|
555
|
+
opacity: 0;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
@keyframes rd-snippet-slide-out-to-right {
|
|
560
|
+
from {
|
|
561
|
+
transform: translateX(0);
|
|
562
|
+
opacity: 1;
|
|
563
|
+
}
|
|
564
|
+
to {
|
|
565
|
+
transform: translateX(100%);
|
|
566
|
+
opacity: 0;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
</style>
|
|
@@ -5,18 +5,14 @@ interface Props {
|
|
|
5
5
|
|
|
6
6
|
const { className = "" } = Astro.props;
|
|
7
7
|
|
|
8
|
-
const idPrefix = `code_group_tab_edge_${Math.random().toString(36).slice(2, 9)}`;
|
|
9
|
-
const mask0Id = `code_group_tab_edge_mask0_${idPrefix}`;
|
|
10
|
-
const path1OutsideMaskId = `code_group_tab_edge_path_1_outside_1_${idPrefix}`;
|
|
11
|
-
const path3OutsideMaskId = `code_group_tab_edge_path_3_outside_2_${idPrefix}`;
|
|
12
8
|
const edgeBackgroundColor = "var(--rd-code-tab-edge-bg, #ffffff)";
|
|
13
9
|
const edgeBorderColor = "var(--rd-code-tab-edge-border, #e5e5e5)";
|
|
14
10
|
---
|
|
15
11
|
|
|
16
12
|
<svg
|
|
17
13
|
width="60"
|
|
18
|
-
height="
|
|
19
|
-
viewBox="0 0 60
|
|
14
|
+
height="38"
|
|
15
|
+
viewBox="0 0 60 38"
|
|
20
16
|
fill="none"
|
|
21
17
|
xmlns="http://www.w3.org/2000/svg"
|
|
22
18
|
class:list={["block", className]}
|
|
@@ -24,58 +20,13 @@ const edgeBorderColor = "var(--rd-code-tab-edge-border, #e5e5e5)";
|
|
|
24
20
|
aria-hidden="true"
|
|
25
21
|
data-pagefind-ignore
|
|
26
22
|
>
|
|
27
|
-
<
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
<mask
|
|
37
|
-
id={path1OutsideMaskId}
|
|
38
|
-
maskUnits="userSpaceOnUse"
|
|
39
|
-
x="0"
|
|
40
|
-
y="-1"
|
|
41
|
-
width="60"
|
|
42
|
-
height="43"
|
|
43
|
-
fill="black"
|
|
44
|
-
>
|
|
45
|
-
<rect fill="white" y="-1" width="60" height="43"></rect>
|
|
46
|
-
<path
|
|
47
|
-
d="M1 0L8.0783 0C15.772 0 22.7836 4.41324 26.111 11.3501L34.8889 29.6498C38.2164 36.5868 45.228 41 52.9217 41H60H1L1 0Z"
|
|
48
|
-
></path>
|
|
49
|
-
</mask>
|
|
50
|
-
<path
|
|
51
|
-
d="M1 0L8.0783 0C15.772 0 22.7836 4.41324 26.111 11.3501L34.8889 29.6498C38.2164 36.5868 45.228 41 52.9217 41H60H1L1 0Z"
|
|
52
|
-
fill={edgeBackgroundColor}></path>
|
|
53
|
-
<path
|
|
54
|
-
d="M1 0V-1H0V0L1 0ZM1 41H0V42H1V41ZM34.8889 29.6498L33.9873 30.0823L34.8889 29.6498ZM26.111 11.3501L27.0127 10.9177L26.111 11.3501ZM1 1H8.0783V-1H1V1ZM60 40H1V42H60V40ZM2 41V0L0 0L0 41H2ZM25.2094 11.7826L33.9873 30.0823L35.7906 29.2174L27.0127 10.9177L25.2094 11.7826ZM52.9217 42H60V40H52.9217V42ZM33.9873 30.0823C37.4811 37.3661 44.8433 42 52.9217 42V40C45.6127 40 38.9517 35.8074 35.7906 29.2174L33.9873 30.0823ZM8.0783 1C15.3873 1 22.0483 5.19257 25.2094 11.7826L27.0127 10.9177C23.5188 3.6339 16.1567 -1 8.0783 -1V1Z"
|
|
55
|
-
fill={edgeBorderColor}
|
|
56
|
-
mask={`url(#${path1OutsideMaskId})`}></path>
|
|
57
|
-
</mask>
|
|
58
|
-
<g mask={`url(#${mask0Id})`}>
|
|
59
|
-
<mask
|
|
60
|
-
id={path3OutsideMaskId}
|
|
61
|
-
maskUnits="userSpaceOnUse"
|
|
62
|
-
x="-1"
|
|
63
|
-
y="0.0244141"
|
|
64
|
-
width="60"
|
|
65
|
-
height="43"
|
|
66
|
-
fill="black"
|
|
67
|
-
>
|
|
68
|
-
<rect fill="white" x="-1" y="0.0244141" width="60" height="43"></rect>
|
|
69
|
-
<path
|
|
70
|
-
d="M0 1.02441H7.0783C14.772 1.02441 21.7836 5.43765 25.111 12.3746L33.8889 30.6743C37.2164 37.6112 44.228 42.0244 51.9217 42.0244H59H0L0 1.02441Z"
|
|
71
|
-
></path>
|
|
72
|
-
</mask>
|
|
73
|
-
<path
|
|
74
|
-
d="M0 1.02441H7.0783C14.772 1.02441 21.7836 5.43765 25.111 12.3746L33.8889 30.6743C37.2164 37.6112 44.228 42.0244 51.9217 42.0244H59H0L0 1.02441Z"
|
|
75
|
-
fill={edgeBackgroundColor}></path>
|
|
76
|
-
<path
|
|
77
|
-
d="M0 1.02441L0 0.0244141H-1V1.02441H0ZM0 42.0244H-1V43.0244H0L0 42.0244ZM33.8889 30.6743L32.9873 31.1068L33.8889 30.6743ZM25.111 12.3746L26.0127 11.9421L25.111 12.3746ZM0 2.02441H7.0783V0.0244141H0L0 2.02441ZM59 41.0244H0L0 43.0244H59V41.0244ZM1 42.0244L1 1.02441H-1L-1 42.0244H1ZM24.2094 12.8071L32.9873 31.1068L34.7906 30.2418L26.0127 11.9421L24.2094 12.8071ZM51.9217 43.0244H59V41.0244H51.9217V43.0244ZM32.9873 31.1068C36.4811 38.3905 43.8433 43.0244 51.9217 43.0244V41.0244C44.6127 41.0244 37.9517 36.8318 34.7906 30.2418L32.9873 31.1068ZM7.0783 2.02441C14.3873 2.02441 21.0483 6.21699 24.2094 12.8071L26.0127 11.9421C22.5188 4.65831 15.1567 0.0244141 7.0783 0.0244141V2.02441Z"
|
|
78
|
-
fill={edgeBorderColor}
|
|
79
|
-
mask={`url(#${path3OutsideMaskId})`}></path>
|
|
80
|
-
</g>
|
|
23
|
+
<path
|
|
24
|
+
d="M0 0.75H7.0783C14.772 0.75 21.7836 4.571 25.111 10.578L33.8889 27.422C37.2164 33.429 44.228 37.25 51.9217 37.25H60V38H0V0.75Z"
|
|
25
|
+
fill={edgeBackgroundColor}></path>
|
|
26
|
+
<path
|
|
27
|
+
d="M0 0.75H7.0783C14.772 0.75 21.7836 4.571 25.111 10.578L33.8889 27.422C37.2164 33.429 44.228 37.25 51.9217 37.25H60"
|
|
28
|
+
fill="none"
|
|
29
|
+
stroke={edgeBorderColor}
|
|
30
|
+
stroke-width="0.5"
|
|
31
|
+
vector-effect="non-scaling-stroke"></path>
|
|
81
32
|
</svg>
|
|
@@ -92,7 +92,7 @@ const hasTitle = typeof resolvedTitle === "string" && resolvedTitle.length > 0;
|
|
|
92
92
|
|
|
93
93
|
<aside
|
|
94
94
|
class:list={[
|
|
95
|
-
"rd-prose-block relative space-y-1 rounded-xl border-[0.5px] bg-neutral-50/70 border-neutral-900/8 px-4 py-3.5 dark:
|
|
95
|
+
"rd-prose-block relative space-y-1 rounded-xl border-[0.5px] bg-neutral-50/70 border-neutral-900/8 dark:border-white/6 px-4 py-3.5 dark:bg-(--rd-code-surface) shadow-[0_.5px_1px_rgba(0,0,0,0.15),0_5px_12px_-6px_rgba(0,0,0,0.08)] dark:shadow-[0_-.5px_1px_rgba(255,255,255,0.15),0_5px_12px_-6px_rgba(0,0,0,0.2)]",
|
|
96
96
|
accent ? "pl-6" : "pl-4",
|
|
97
97
|
]}
|
|
98
98
|
role="note"
|
|
@@ -199,10 +199,14 @@ const displayFilename =
|
|
|
199
199
|
? trimmedFilename
|
|
200
200
|
: buildDefaultCodeFileName(normalizedLanguage);
|
|
201
201
|
|
|
202
|
-
const { lines: tokenLines } = await getCodeLineTokens({
|
|
202
|
+
const { lines: tokenLines, themeColors } = await getCodeLineTokens({
|
|
203
203
|
code: raw,
|
|
204
204
|
language: normalizedLanguage,
|
|
205
205
|
});
|
|
206
|
+
const codeThemeStyle = [
|
|
207
|
+
`--rd-code-line-highlight-theme-bg-light:${themeColors.lineHighlightBackground.light}`,
|
|
208
|
+
`--rd-code-line-highlight-theme-bg-dark:${themeColors.lineHighlightBackground.dark}`,
|
|
209
|
+
].join(";");
|
|
206
210
|
|
|
207
211
|
const rawLines = raw.split("\n");
|
|
208
212
|
const normalizedRawLines = rawLines.length > 0 ? rawLines : [""];
|
|
@@ -244,12 +248,14 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
244
248
|
|
|
245
249
|
const lineContentClass = parsedShowLineNumbers
|
|
246
250
|
? "flex-1 whitespace-pre pr-4"
|
|
247
|
-
:
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
+
: !parsedInCodeGroup && !parsedShowFilename
|
|
252
|
+
? "flex-1 whitespace-pre pl-4 pr-8.5"
|
|
253
|
+
: "flex-1 whitespace-pre pl-4 pr-4";
|
|
254
|
+
const lineHighlightAttribute = isHighlighted
|
|
255
|
+
? ' data-rd-code-line-highlighted="true"'
|
|
256
|
+
: "";
|
|
251
257
|
|
|
252
|
-
return `<span class="${
|
|
258
|
+
return `<span class="flex min-w-full"${lineHighlightAttribute}>${lineNumberHtml}<span class="${lineContentClass}">${tokenHtml}</span></span>`;
|
|
253
259
|
})
|
|
254
260
|
.join("");
|
|
255
261
|
---
|
|
@@ -257,7 +263,7 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
257
263
|
<div
|
|
258
264
|
class:list={[
|
|
259
265
|
"group/prose-code not-prose relative w-full max-w-full min-w-0 rounded-xl",
|
|
260
|
-
parsedInCodeGroup ? "my-0" : "rd-prose-block
|
|
266
|
+
parsedInCodeGroup ? "my-0" : "rd-prose-block",
|
|
261
267
|
]}
|
|
262
268
|
data-rd-code-block-root="true"
|
|
263
269
|
data-rd-collapsed-lines={collapsedLinesValue}
|
|
@@ -268,21 +274,22 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
268
274
|
data-rd-tab-hide-icon={parsedInCodeGroup && parsedHideLanguageIcon
|
|
269
275
|
? "true"
|
|
270
276
|
: undefined}
|
|
277
|
+
style={codeThemeStyle}
|
|
271
278
|
>
|
|
272
279
|
<div
|
|
273
280
|
class:list={[
|
|
274
|
-
"w-full max-w-full min-w-0
|
|
275
|
-
parsedInCodeGroup ? "rounded-
|
|
281
|
+
"w-full max-w-full min-w-0 bg-(--rd-code-surface)",
|
|
282
|
+
parsedInCodeGroup ? "rounded-tr-none rounded-xl" : "rounded-xl",
|
|
276
283
|
]}
|
|
277
284
|
>
|
|
278
285
|
{
|
|
279
286
|
!parsedInCodeGroup && parsedShowFilename ? (
|
|
280
|
-
<div class="flex items-center justify-between gap-2 border-b border-
|
|
287
|
+
<div class="flex items-center justify-between gap-2 border-b-[0.5px] border-(--rd-code-tab-edge-border) bg-(--rd-code-header-surface)">
|
|
281
288
|
<div class="min-w-0 flex-1">
|
|
282
|
-
<div class="relative h-9 w-fit max-w-full rounded-tl-xl bg-
|
|
283
|
-
<div class="absolute inset-x-0 -bottom-px h-px bg-
|
|
284
|
-
<CodeTabEdge className="pointer-events-none absolute -top-
|
|
285
|
-
<div class="relative z-20 inline-flex h-9 max-w-full items-center gap-2 pl-5 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300">
|
|
289
|
+
<div class="relative h-9 w-fit max-w-full rounded-tl-xl bg-(--rd-code-surface)">
|
|
290
|
+
<div class="absolute inset-x-0 -bottom-px h-px bg-(--rd-code-surface)" />
|
|
291
|
+
<CodeTabEdge className="pointer-events-none absolute -top-[0.5px] left-full z-10 h-[calc(100%+1.5px)]" />
|
|
292
|
+
<div class="relative z-20 inline-flex h-9 max-w-full items-center gap-2 pl-5 py-1.5 text-xs font-medium text-neutral-700 dark:text-neutral-300 rounded-tl-xl border-t-[0.5px] border-l-[0.5px] border-(--rd-code-tab-edge-border)">
|
|
286
293
|
{shouldRenderLanguageIcon ? (
|
|
287
294
|
<CodeLanguageIcon
|
|
288
295
|
language={normalizedLanguage}
|
|
@@ -294,8 +301,8 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
294
301
|
</div>
|
|
295
302
|
</div>
|
|
296
303
|
</div>
|
|
297
|
-
<div class="relative h-9 w-5 shrink-0 rounded-tr-xl bg-
|
|
298
|
-
<div class="absolute inset-x-0 -bottom-px h-px bg-
|
|
304
|
+
<div class="relative h-9 w-5 shrink-0 rounded-tr-xl bg-(--rd-code-surface) border-t-[0.5px] border-r-[0.5px] border-(--rd-code-tab-edge-border)">
|
|
305
|
+
<div class="absolute inset-x-0 -bottom-px h-px bg-(--rd-code-surface)" />
|
|
299
306
|
<CodeTabEdge className="pointer-events-none absolute -top-px right-full z-10 h-[calc(100%+2px)] rotate-y-180" />
|
|
300
307
|
<button
|
|
301
308
|
type="button"
|
|
@@ -323,7 +330,11 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
<div
|
|
326
|
-
class=
|
|
333
|
+
class:list={[
|
|
334
|
+
"relative min-w-0 border-[0.5px] rounded-xl overflow-hidden border-(--rd-code-tab-edge-border)",
|
|
335
|
+
parsedShowFilename && "border-t-0 rounded-t-none",
|
|
336
|
+
parsedInCodeGroup && "rounded-tl-xl border-0!",
|
|
337
|
+
]}
|
|
327
338
|
data-rd-code-group-panel={parsedInCodeGroup ? "true" : undefined}
|
|
328
339
|
>
|
|
329
340
|
{
|
|
@@ -331,7 +342,7 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
331
342
|
<div class="pointer-events-none absolute right-2 top-2 z-20">
|
|
332
343
|
<button
|
|
333
344
|
type="button"
|
|
334
|
-
class="pointer-events-
|
|
345
|
+
class="pointer-events-none inline-flex size-7 appearance-none items-center justify-center rounded-md bg-(--rd-code-surface)/40 backdrop-blur-sm text-neutral-500/80 outline-none ring-0 transition-colors duration-150 hover:text-neutral-700 focus:outline-none focus-visible:outline-none focus:ring-0 focus-visible:ring-0 cursor-pointer group-hover/prose-code:pointer-events-auto group-focus-within/prose-code:pointer-events-auto dark:text-neutral-400 dark:hover:text-neutral-200 relative before:absolute before:inset-1 hover:before:inset-0 before:rounded-md hover:before:bg-neutral-900/4 dark:hover:before:bg-white/4 before:duration-150"
|
|
335
346
|
data-rd-copy-trigger="true"
|
|
336
347
|
data-rd-copy-content={encodedRaw}
|
|
337
348
|
aria-label="Copy code"
|
|
@@ -344,7 +355,7 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
344
355
|
/>
|
|
345
356
|
<Icon
|
|
346
357
|
name="lucide:check"
|
|
347
|
-
class="absolute size-3.5 stroke-3 origin-center scale-25 rotate-6 opacity-0 text-green-
|
|
358
|
+
class="absolute size-3.5 stroke-3 origin-center scale-25 rotate-6 opacity-0 text-green-800/70 transition-all duration-250 ease-[cubic-bezier(0.22,1,0.36,1)] will-change-transform motion-reduce:transition-none dark:text-green-400/90"
|
|
348
359
|
data-rd-copy-check
|
|
349
360
|
aria-hidden="true"
|
|
350
361
|
/>
|
|
@@ -372,7 +383,7 @@ const renderedCodeLinesHtml = normalizedTokenLines
|
|
|
372
383
|
class="relative overflow-x-auto [scrollbar-width:thin] [scrollbar-color:var(--color-neutral-300)_transparent] [&::-webkit-scrollbar]:h-1.5 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-neutral-300/70 hover:[&::-webkit-scrollbar-thumb]:bg-neutral-300/90 dark:[scrollbar-color:var(--color-neutral-700)_transparent] dark:[&::-webkit-scrollbar-thumb]:bg-neutral-700/70 dark:hover:[&::-webkit-scrollbar-thumb]:bg-neutral-700/90"
|
|
373
384
|
>
|
|
374
385
|
<pre
|
|
375
|
-
class="relative m-0 min-w-full bg-
|
|
386
|
+
class="relative m-0 min-w-full bg-(--rd-code-surface) p-0 text-[13px] leading-6"><code data-rd-code-theme class="block min-w-full py-2.5 font-mono text-neutral-800 dark:text-neutral-200"><Fragment set:html={renderedCodeLinesHtml} /></code></pre>
|
|
376
387
|
</div>
|
|
377
388
|
</div>
|
|
378
389
|
</div>
|