@dogsbay/ui 0.2.0-beta.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/package.json +38 -0
- package/src/accordion/Accordion.astro +38 -0
- package/src/accordion/AccordionContent.astro +25 -0
- package/src/accordion/AccordionItem.astro +26 -0
- package/src/accordion/AccordionTrigger.astro +38 -0
- package/src/accordion/accordion.ts +189 -0
- package/src/accordion/index.ts +4 -0
- package/src/alert/Alert.astro +69 -0
- package/src/alert/AlertDescription.astro +17 -0
- package/src/alert/AlertTitle.astro +21 -0
- package/src/alert/CollapsibleAlert.astro +103 -0
- package/src/alert/icon.ts +32 -0
- package/src/alert/index.ts +4 -0
- package/src/alert/variants.ts +29 -0
- package/src/alert-dialog/AlertDialog.astro +16 -0
- package/src/alert-dialog/AlertDialogAction.astro +23 -0
- package/src/alert-dialog/AlertDialogCancel.astro +23 -0
- package/src/alert-dialog/AlertDialogContent.astro +37 -0
- package/src/alert-dialog/AlertDialogDescription.astro +18 -0
- package/src/alert-dialog/AlertDialogFooter.astro +18 -0
- package/src/alert-dialog/AlertDialogHeader.astro +18 -0
- package/src/alert-dialog/AlertDialogTitle.astro +18 -0
- package/src/alert-dialog/AlertDialogTrigger.astro +24 -0
- package/src/alert-dialog/alert-dialog.ts +154 -0
- package/src/alert-dialog/index.ts +9 -0
- package/src/api-doc/ApiDoc.astro +52 -0
- package/src/api-doc/index.ts +1 -0
- package/src/api-layout/ApiCodePanel.astro +21 -0
- package/src/api-layout/ApiLayout.astro +29 -0
- package/src/api-layout/ExampleBlock.astro +63 -0
- package/src/api-params/ApiParams.astro +96 -0
- package/src/api-params/index.ts +1 -0
- package/src/api-source/ApiSource.astro +20 -0
- package/src/api-source/api-source.css +32 -0
- package/src/api-source/index.ts +1 -0
- package/src/api-symbol/ApiSymbol.astro +48 -0
- package/src/api-symbol/api-symbol.css +89 -0
- package/src/api-symbol/index.ts +1 -0
- package/src/api-url-bar/ApiUrlBar.astro +63 -0
- package/src/avatar/Avatar.astro +57 -0
- package/src/avatar/index.ts +1 -0
- package/src/badge/Badge.astro +37 -0
- package/src/badge/index.ts +1 -0
- package/src/breadcrumb/Breadcrumb.astro +32 -0
- package/src/breadcrumb/BreadcrumbEllipsis.astro +32 -0
- package/src/breadcrumb/BreadcrumbItem.astro +41 -0
- package/src/breadcrumb/BreadcrumbSeparator.astro +33 -0
- package/src/breadcrumb/index.ts +4 -0
- package/src/button/Button.astro +70 -0
- package/src/button/index.ts +1 -0
- package/src/card/Card.astro +17 -0
- package/src/card/CardContent.astro +17 -0
- package/src/card/CardDescription.astro +17 -0
- package/src/card/CardFooter.astro +17 -0
- package/src/card/CardHeader.astro +17 -0
- package/src/card/CardTitle.astro +17 -0
- package/src/card/index.ts +6 -0
- package/src/checkbox/Checkbox.astro +70 -0
- package/src/checkbox/index.ts +1 -0
- package/src/checkbox-group/CheckboxGroup.astro +38 -0
- package/src/checkbox-group/checkbox-group.ts +53 -0
- package/src/checkbox-group/index.ts +1 -0
- package/src/code-block/CodeBlock.astro +160 -0
- package/src/code-rich/CodeRich.astro +267 -0
- package/src/code-rich/code-rich.css +68 -0
- package/src/code-rich/index.ts +1 -0
- package/src/code-samples/CodeSamples.astro +59 -0
- package/src/collapsible/Collapsible.astro +35 -0
- package/src/collapsible/CollapsibleContent.astro +24 -0
- package/src/collapsible/CollapsibleTrigger.astro +23 -0
- package/src/collapsible/collapsible.ts +42 -0
- package/src/collapsible/index.ts +3 -0
- package/src/combobox/Combobox.astro +53 -0
- package/src/combobox/ComboboxEmpty.astro +18 -0
- package/src/combobox/ComboboxItem.astro +28 -0
- package/src/combobox/combobox.ts +179 -0
- package/src/combobox/index.ts +3 -0
- package/src/command/Command.astro +22 -0
- package/src/command/CommandEmpty.astro +18 -0
- package/src/command/CommandGroup.astro +24 -0
- package/src/command/CommandInput.astro +49 -0
- package/src/command/CommandItem.astro +26 -0
- package/src/command/CommandList.astro +19 -0
- package/src/command/CommandSeparator.astro +16 -0
- package/src/command/CommandShortcut.astro +18 -0
- package/src/command/command.ts +212 -0
- package/src/command/index.ts +8 -0
- package/src/content-renderer/ContentRenderer.astro +410 -0
- package/src/content-renderer/InlineRenderer.astro +149 -0
- package/src/context-menu/ContextMenu.astro +22 -0
- package/src/context-menu/ContextMenuContent.astro +24 -0
- package/src/context-menu/ContextMenuItem.astro +49 -0
- package/src/context-menu/ContextMenuSeparator.astro +14 -0
- package/src/context-menu/ContextMenuShortcut.astro +14 -0
- package/src/context-menu/ContextMenuTrigger.astro +22 -0
- package/src/context-menu/context-menu.ts +238 -0
- package/src/context-menu/index.ts +6 -0
- package/src/copy-button/CopyButton.astro +88 -0
- package/src/copy-button/index.ts +1 -0
- package/src/diagram/Diagram.astro +15 -0
- package/src/diagram/index.ts +1 -0
- package/src/dialog/Dialog.astro +22 -0
- package/src/dialog/DialogClose.astro +32 -0
- package/src/dialog/DialogContent.astro +37 -0
- package/src/dialog/DialogDescription.astro +22 -0
- package/src/dialog/DialogFooter.astro +18 -0
- package/src/dialog/DialogHeader.astro +18 -0
- package/src/dialog/DialogTitle.astro +18 -0
- package/src/dialog/DialogTrigger.astro +33 -0
- package/src/dialog/dialog.ts +291 -0
- package/src/dialog/index.ts +8 -0
- package/src/docs-footer/DocsFooter.astro +50 -0
- package/src/docs-header/DocsHeader.astro +32 -0
- package/src/docs-layout/DocsLayout.astro +187 -0
- package/src/docs-layout/index.ts +1 -0
- package/src/drawer/Drawer.astro +12 -0
- package/src/drawer/DrawerClose.astro +12 -0
- package/src/drawer/DrawerContent.astro +46 -0
- package/src/drawer/DrawerDescription.astro +10 -0
- package/src/drawer/DrawerFooter.astro +10 -0
- package/src/drawer/DrawerHandle.astro +16 -0
- package/src/drawer/DrawerHeader.astro +10 -0
- package/src/drawer/DrawerTitle.astro +10 -0
- package/src/drawer/DrawerTrigger.astro +25 -0
- package/src/drawer/drawer.ts +262 -0
- package/src/drawer/index.ts +9 -0
- package/src/dropdown-menu/DropdownMenu.astro +22 -0
- package/src/dropdown-menu/DropdownMenuContent.astro +33 -0
- package/src/dropdown-menu/DropdownMenuGroup.astro +17 -0
- package/src/dropdown-menu/DropdownMenuItem.astro +48 -0
- package/src/dropdown-menu/DropdownMenuLabel.astro +28 -0
- package/src/dropdown-menu/DropdownMenuSeparator.astro +21 -0
- package/src/dropdown-menu/DropdownMenuShortcut.astro +18 -0
- package/src/dropdown-menu/DropdownMenuTrigger.astro +34 -0
- package/src/dropdown-menu/dropdown-menu.ts +348 -0
- package/src/dropdown-menu/index.ts +8 -0
- package/src/endpoint-card/EndpointCard.astro +60 -0
- package/src/endpoint-card/EndpointCardSection.astro +22 -0
- package/src/endpoint-card/EndpointSection.astro +35 -0
- package/src/field/Field.astro +31 -0
- package/src/field/FieldDescription.astro +22 -0
- package/src/field/FieldLabel.astro +24 -0
- package/src/field/field.ts +61 -0
- package/src/field/index.ts +3 -0
- package/src/fieldset/Fieldset.astro +24 -0
- package/src/fieldset/FieldsetLegend.astro +18 -0
- package/src/fieldset/index.ts +2 -0
- package/src/footnote/Footnote.astro +37 -0
- package/src/footnote/footnote.ts +79 -0
- package/src/footnote/index.ts +1 -0
- package/src/form/Form.astro +27 -0
- package/src/form/form.ts +160 -0
- package/src/form/index.ts +1 -0
- package/src/grid/Grid.astro +117 -0
- package/src/grid/GridItem.astro +95 -0
- package/src/grid/index.ts +2 -0
- package/src/image/Image.astro +115 -0
- package/src/image/index.ts +1 -0
- package/src/input/Input.astro +34 -0
- package/src/input/index.ts +1 -0
- package/src/kbd/Kbd.astro +17 -0
- package/src/kbd/index.ts +1 -0
- package/src/label/Label.astro +17 -0
- package/src/label/index.ts +1 -0
- package/src/link-card/LinkCard.astro +47 -0
- package/src/link-card/index.ts +1 -0
- package/src/map-view/MapView.astro +88 -0
- package/src/map-view/index.ts +1 -0
- package/src/map-view/map-view.ts +194 -0
- package/src/markdown-example/MarkdownExample.astro +138 -0
- package/src/markdown-example/index.ts +1 -0
- package/src/math/MathKatex.astro +35 -0
- package/src/math/index.ts +1 -0
- package/src/menubar/Menubar.astro +25 -0
- package/src/menubar/MenubarContent.astro +24 -0
- package/src/menubar/MenubarItem.astro +26 -0
- package/src/menubar/MenubarMenu.astro +12 -0
- package/src/menubar/MenubarSeparator.astro +11 -0
- package/src/menubar/MenubarShortcut.astro +11 -0
- package/src/menubar/MenubarTrigger.astro +27 -0
- package/src/menubar/index.ts +7 -0
- package/src/menubar/menubar.ts +258 -0
- package/src/meter/Meter.astro +75 -0
- package/src/meter/index.ts +1 -0
- package/src/method-badge/MethodBadge.astro +32 -0
- package/src/navigation-menu/NavigationMenu.astro +24 -0
- package/src/navigation-menu/NavigationMenuContent.astro +24 -0
- package/src/navigation-menu/NavigationMenuItem.astro +22 -0
- package/src/navigation-menu/NavigationMenuLink.astro +26 -0
- package/src/navigation-menu/NavigationMenuList.astro +22 -0
- package/src/navigation-menu/NavigationMenuTrigger.astro +40 -0
- package/src/navigation-menu/index.ts +6 -0
- package/src/navigation-menu/navigation-menu.ts +192 -0
- package/src/number-field/NumberField.astro +84 -0
- package/src/number-field/index.ts +1 -0
- package/src/number-field/number-field.ts +68 -0
- package/src/pagination/Pagination.astro +59 -0
- package/src/pagination/index.ts +1 -0
- package/src/parameter-table/ParameterTable.astro +75 -0
- package/src/popover/Popover.astro +21 -0
- package/src/popover/PopoverContent.astro +31 -0
- package/src/popover/PopoverTrigger.astro +31 -0
- package/src/popover/index.ts +3 -0
- package/src/popover/popover.ts +144 -0
- package/src/preview-card/PreviewCard.astro +24 -0
- package/src/preview-card/PreviewCardContent.astro +24 -0
- package/src/preview-card/PreviewCardTrigger.astro +23 -0
- package/src/preview-card/index.ts +3 -0
- package/src/preview-card/preview-card.ts +91 -0
- package/src/progress/Progress.astro +61 -0
- package/src/progress/index.ts +1 -0
- package/src/property-item/PropertyItem.astro +183 -0
- package/src/property-list/PropertyList.astro +68 -0
- package/src/radio-group/RadioGroup.astro +41 -0
- package/src/radio-group/RadioGroupItem.astro +36 -0
- package/src/radio-group/index.ts +2 -0
- package/src/radio-group/radio-group.ts +126 -0
- package/src/response-tabs/ResponseTabs.astro +60 -0
- package/src/schema-viewer/SchemaViewer.astro +42 -0
- package/src/scroll-area/ScrollArea.astro +44 -0
- package/src/scroll-area/index.ts +1 -0
- package/src/scroll-area/scroll-area.ts +176 -0
- package/src/select/Select.astro +34 -0
- package/src/select/SelectContent.astro +24 -0
- package/src/select/SelectGroup.astro +23 -0
- package/src/select/SelectItem.astro +28 -0
- package/src/select/SelectLabel.astro +18 -0
- package/src/select/SelectSeparator.astro +22 -0
- package/src/select/SelectTrigger.astro +28 -0
- package/src/select/SelectValue.astro +18 -0
- package/src/select/index.ts +8 -0
- package/src/select/select.ts +381 -0
- package/src/separator/Separator.astro +35 -0
- package/src/separator/index.ts +1 -0
- package/src/sheet/Sheet.astro +12 -0
- package/src/sheet/SheetClose.astro +35 -0
- package/src/sheet/SheetContent.astro +52 -0
- package/src/sheet/SheetDescription.astro +18 -0
- package/src/sheet/SheetFooter.astro +18 -0
- package/src/sheet/SheetHeader.astro +18 -0
- package/src/sheet/SheetTitle.astro +18 -0
- package/src/sheet/SheetTrigger.astro +32 -0
- package/src/sheet/index.ts +8 -0
- package/src/sheet/sheet.ts +173 -0
- package/src/sidebar/Sidebar.astro +113 -0
- package/src/sidebar/SidebarContent.astro +18 -0
- package/src/sidebar/SidebarFooter.astro +18 -0
- package/src/sidebar/SidebarGroup.astro +18 -0
- package/src/sidebar/SidebarGroupContent.astro +18 -0
- package/src/sidebar/SidebarGroupLabel.astro +18 -0
- package/src/sidebar/SidebarHeader.astro +18 -0
- package/src/sidebar/SidebarInset.astro +18 -0
- package/src/sidebar/SidebarMenu.astro +18 -0
- package/src/sidebar/SidebarMenuBadge.astro +18 -0
- package/src/sidebar/SidebarMenuButton.astro +71 -0
- package/src/sidebar/SidebarMenuItem.astro +18 -0
- package/src/sidebar/SidebarMenuSub.astro +18 -0
- package/src/sidebar/SidebarMenuSubButton.astro +45 -0
- package/src/sidebar/SidebarMenuSubItem.astro +12 -0
- package/src/sidebar/SidebarNavTree.astro +106 -0
- package/src/sidebar/SidebarProvider.astro +23 -0
- package/src/sidebar/SidebarRail.astro +25 -0
- package/src/sidebar/SidebarSeparator.astro +21 -0
- package/src/sidebar/SidebarTrigger.astro +40 -0
- package/src/sidebar/index.ts +19 -0
- package/src/sidebar/sidebar.ts +265 -0
- package/src/skeleton/Skeleton.astro +16 -0
- package/src/skeleton/index.ts +1 -0
- package/src/skip-link/SkipLink.astro +24 -0
- package/src/slider/Slider.astro +61 -0
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.ts +111 -0
- package/src/spinner/Spinner.astro +54 -0
- package/src/spinner/index.ts +1 -0
- package/src/steps/Step.astro +16 -0
- package/src/steps/Steps.astro +122 -0
- package/src/steps/SubSteps.astro +73 -0
- package/src/switch/Switch.astro +52 -0
- package/src/switch/index.ts +1 -0
- package/src/switch/switch.ts +109 -0
- package/src/table/Table.astro +24 -0
- package/src/table/TableBody.astro +18 -0
- package/src/table/TableCaption.astro +18 -0
- package/src/table/TableCell.astro +18 -0
- package/src/table/TableFooter.astro +18 -0
- package/src/table/TableHead.astro +18 -0
- package/src/table/TableHeader.astro +18 -0
- package/src/table/TableRow.astro +18 -0
- package/src/table/index.ts +8 -0
- package/src/tabs/Tabs.astro +37 -0
- package/src/tabs/TabsContent.astro +32 -0
- package/src/tabs/TabsList.astro +23 -0
- package/src/tabs/TabsTrigger.astro +29 -0
- package/src/tabs/index.ts +4 -0
- package/src/tabs/tabs.ts +220 -0
- package/src/textarea/Textarea.astro +25 -0
- package/src/textarea/index.ts +1 -0
- package/src/theme-toggle/ThemeToggle.astro +67 -0
- package/src/theme-toggle/index.ts +1 -0
- package/src/toast/Toaster.astro +39 -0
- package/src/toast/index.ts +3 -0
- package/src/toast/toast.ts +104 -0
- package/src/toc/TableOfContents.astro +225 -0
- package/src/toggle/Toggle.astro +56 -0
- package/src/toggle/index.ts +1 -0
- package/src/toggle/toggle.ts +38 -0
- package/src/toggle-group/ToggleGroup.astro +39 -0
- package/src/toggle-group/ToggleGroupItem.astro +56 -0
- package/src/toggle-group/index.ts +2 -0
- package/src/toggle-group/toggle-group.ts +121 -0
- package/src/toolbar/Toolbar.astro +26 -0
- package/src/toolbar/ToolbarButton.astro +29 -0
- package/src/toolbar/ToolbarSeparator.astro +14 -0
- package/src/toolbar/index.ts +3 -0
- package/src/toolbar/toolbar.ts +65 -0
- package/src/tooltip/Tooltip.astro +21 -0
- package/src/tooltip/TooltipContent.astro +25 -0
- package/src/tooltip/TooltipTrigger.astro +31 -0
- package/src/tooltip/index.ts +3 -0
- package/src/tooltip/tooltip.ts +156 -0
- package/src/youtube/YouTube.astro +119 -0
- package/src/youtube/index.ts +1 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* InlineRenderer — renders structured InlineNode[] to HTML elements.
|
|
4
|
+
*/
|
|
5
|
+
import MathKatex from "../math/MathKatex.astro";
|
|
6
|
+
|
|
7
|
+
interface InlineNode {
|
|
8
|
+
type: string;
|
|
9
|
+
text?: string;
|
|
10
|
+
bold?: boolean;
|
|
11
|
+
italic?: boolean;
|
|
12
|
+
strikethrough?: boolean;
|
|
13
|
+
href?: string;
|
|
14
|
+
title?: string;
|
|
15
|
+
src?: string;
|
|
16
|
+
alt?: string;
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
label?: string;
|
|
20
|
+
content?: string;
|
|
21
|
+
keys?: string[];
|
|
22
|
+
html?: string;
|
|
23
|
+
latex?: string;
|
|
24
|
+
name?: string;
|
|
25
|
+
library?: string;
|
|
26
|
+
variant?: string;
|
|
27
|
+
size?: string;
|
|
28
|
+
attrs?: Record<string, string>;
|
|
29
|
+
children?: InlineNode[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
node: InlineNode;
|
|
34
|
+
icons?: any;
|
|
35
|
+
images?: Record<string, ImageMetadata>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { node, icons, images = {} } = Astro.props;
|
|
39
|
+
|
|
40
|
+
// Resolve inline image to optimized version if available
|
|
41
|
+
function resolveImage(src: string): ImageMetadata | undefined {
|
|
42
|
+
if (!src || src.startsWith("http")) return undefined;
|
|
43
|
+
const normalized = "/" + src.replace(/^(?:\.\.\/)+/, "").replace(/^\/+/, "");
|
|
44
|
+
const clean = normalized.replace(/#.*$/, "");
|
|
45
|
+
return images[clean];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const resolvedImg = node.type === "image" ? resolveImage(node.src as string || "") : undefined;
|
|
49
|
+
|
|
50
|
+
// Icon resolution
|
|
51
|
+
const iconSvg = node.type === "icon" && icons
|
|
52
|
+
? icons.resolve(node.library || "emoji", node.name, node.variant, node.size) as string | null
|
|
53
|
+
: null;
|
|
54
|
+
const isEmojiIcon = node.type === "icon" && (node.library === "emoji" || (iconSvg && iconSvg.length <= 4 && !iconSvg.startsWith("<")));
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
{node.type === "text" && (() => {
|
|
58
|
+
const cls: string[] = [];
|
|
59
|
+
if (node.bold) cls.push("font-semibold");
|
|
60
|
+
if (node.italic) cls.push("italic");
|
|
61
|
+
if (node.strikethrough) cls.push("line-through");
|
|
62
|
+
if (cls.length > 0) {
|
|
63
|
+
return <span class={cls.join(" ")}>{node.text}</span>;
|
|
64
|
+
}
|
|
65
|
+
return <Fragment>{node.text}</Fragment>;
|
|
66
|
+
})()}
|
|
67
|
+
|
|
68
|
+
{node.type === "highlight" && (
|
|
69
|
+
<mark class="rounded-sm bg-yellow-200/60 px-0.5 dark:bg-yellow-500/30">
|
|
70
|
+
{(node.children || []).map(child => <Astro.self node={child} icons={icons} images={images} />)}
|
|
71
|
+
</mark>
|
|
72
|
+
)}
|
|
73
|
+
|
|
74
|
+
{node.type === "link" && (
|
|
75
|
+
<a href={node.href} title={node.title}>
|
|
76
|
+
{(node.children || []).map(child => <Astro.self node={child} icons={icons} images={images} />)}
|
|
77
|
+
</a>
|
|
78
|
+
)}
|
|
79
|
+
|
|
80
|
+
{node.type === "image" && resolvedImg && (
|
|
81
|
+
<img
|
|
82
|
+
src={resolvedImg.src}
|
|
83
|
+
alt={node.alt || ""}
|
|
84
|
+
title={node.title}
|
|
85
|
+
width={node.width || resolvedImg.width}
|
|
86
|
+
height={node.height || resolvedImg.height}
|
|
87
|
+
loading="lazy"
|
|
88
|
+
decoding="async"
|
|
89
|
+
/>
|
|
90
|
+
)}
|
|
91
|
+
{node.type === "image" && !resolvedImg && (
|
|
92
|
+
<img
|
|
93
|
+
src={node.src}
|
|
94
|
+
alt={node.alt || ""}
|
|
95
|
+
title={node.title}
|
|
96
|
+
width={node.width}
|
|
97
|
+
height={node.height}
|
|
98
|
+
loading="lazy"
|
|
99
|
+
decoding="async"
|
|
100
|
+
/>
|
|
101
|
+
)}
|
|
102
|
+
|
|
103
|
+
{node.type === "code" && (
|
|
104
|
+
<code class="rounded border border-border bg-muted px-1.5 py-0.5 font-mono text-sm text-foreground">{node.text}</code>
|
|
105
|
+
)}
|
|
106
|
+
|
|
107
|
+
{node.type === "footnote-ref" && (
|
|
108
|
+
<a
|
|
109
|
+
data-footnote
|
|
110
|
+
data-label={node.label}
|
|
111
|
+
data-content={node.content || ""}
|
|
112
|
+
href={`#fn-${node.label}`}
|
|
113
|
+
id={`fnref-${node.label}`}
|
|
114
|
+
class="no-underline"
|
|
115
|
+
>
|
|
116
|
+
<sup class="cursor-pointer text-primary hover:underline">[{node.label}]</sup>
|
|
117
|
+
</a>
|
|
118
|
+
)}
|
|
119
|
+
|
|
120
|
+
{node.type === "kbd" && (
|
|
121
|
+
<span class="inline-flex items-center gap-0.5">
|
|
122
|
+
{(node.keys || []).map((key, i) => (
|
|
123
|
+
<Fragment>
|
|
124
|
+
{i > 0 && <span class="text-muted-foreground text-xs">+</span>}
|
|
125
|
+
<kbd class="rounded border border-border bg-muted px-1.5 py-0.5 text-xs font-mono font-medium shadow-sm">{key}</kbd>
|
|
126
|
+
</Fragment>
|
|
127
|
+
))}
|
|
128
|
+
</span>
|
|
129
|
+
)}
|
|
130
|
+
|
|
131
|
+
{node.type === "math" && (
|
|
132
|
+
<MathKatex latex={node.latex as string || ""} />
|
|
133
|
+
)}
|
|
134
|
+
|
|
135
|
+
{node.type === "icon" && !iconSvg && (
|
|
136
|
+
<span>:{node.name as string}:</span>
|
|
137
|
+
)}
|
|
138
|
+
{node.type === "icon" && iconSvg && isEmojiIcon && (
|
|
139
|
+
<span>{iconSvg}</span>
|
|
140
|
+
)}
|
|
141
|
+
{node.type === "icon" && iconSvg && !isEmojiIcon && (
|
|
142
|
+
<span class:list={["inline-flex items-baseline [&>svg]:h-[1em] [&>svg]:w-[1em]", (node.attrs as Record<string, string>)?.class]} set:html={iconSvg} />
|
|
143
|
+
)}
|
|
144
|
+
|
|
145
|
+
{node.type === "html-inline" && (
|
|
146
|
+
<Fragment set:html={node.html} />
|
|
147
|
+
)}
|
|
148
|
+
|
|
149
|
+
{node.type === "break" && <br />}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const contextMenu = tv({
|
|
5
|
+
base: "relative",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
class?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { class: className, ...rest } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class={contextMenu({ class: className })}
|
|
18
|
+
data-component="context-menu"
|
|
19
|
+
{...rest}
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const contextMenuContent = tv({
|
|
5
|
+
base: "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
class?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { class: className, ...rest } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class={contextMenuContent({ class: className })}
|
|
18
|
+
data-part="content"
|
|
19
|
+
role="menu"
|
|
20
|
+
hidden
|
|
21
|
+
{...rest}
|
|
22
|
+
>
|
|
23
|
+
<slot />
|
|
24
|
+
</div>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv, type VariantProps } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const contextMenuItem = tv({
|
|
5
|
+
base: "relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0",
|
|
6
|
+
variants: {
|
|
7
|
+
variant: {
|
|
8
|
+
default: "",
|
|
9
|
+
destructive:
|
|
10
|
+
"text-destructive focus:bg-destructive focus:text-destructive-foreground",
|
|
11
|
+
},
|
|
12
|
+
inset: {
|
|
13
|
+
true: "pl-8",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
defaultVariants: {
|
|
17
|
+
variant: "default",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
type Variants = VariantProps<typeof contextMenuItem>;
|
|
22
|
+
|
|
23
|
+
interface Props {
|
|
24
|
+
variant?: Variants["variant"];
|
|
25
|
+
inset?: boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
class?: string;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
variant = "default",
|
|
33
|
+
inset = false,
|
|
34
|
+
disabled = false,
|
|
35
|
+
class: className,
|
|
36
|
+
...rest
|
|
37
|
+
} = Astro.props;
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
class={contextMenuItem({ variant, inset: inset || undefined, class: className })}
|
|
42
|
+
data-part="item"
|
|
43
|
+
role="menuitem"
|
|
44
|
+
tabindex="-1"
|
|
45
|
+
data-disabled={disabled ? "true" : undefined}
|
|
46
|
+
{...rest}
|
|
47
|
+
>
|
|
48
|
+
<slot />
|
|
49
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const sep = tv({ base: "-mx-1 my-1 h-px bg-muted" });
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { class: className, ...rest } = Astro.props;
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<div class={sep({ class: className })} role="separator" {...rest}></div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const shortcut = tv({ base: "ml-auto text-xs tracking-widest text-muted-foreground" });
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
class?: string;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const { class: className, ...rest } = Astro.props;
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<span class={shortcut({ class: className })} {...rest}><slot /></span>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const contextMenuTrigger = tv({
|
|
5
|
+
base: "",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
class?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { class: className, ...rest } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class={contextMenuTrigger({ class: className })}
|
|
18
|
+
data-part="trigger"
|
|
19
|
+
{...rest}
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import { DismissController } from "@dogsbay/primitives/dismiss";
|
|
2
|
+
import { createPortal } from "@dogsbay/primitives/portal";
|
|
3
|
+
import { Typeahead } from "@dogsbay/primitives/typeahead";
|
|
4
|
+
|
|
5
|
+
interface ContextMenuInstance {
|
|
6
|
+
root: HTMLElement;
|
|
7
|
+
trigger: HTMLElement;
|
|
8
|
+
content: HTMLElement;
|
|
9
|
+
items: HTMLElement[];
|
|
10
|
+
dismiss: DismissController;
|
|
11
|
+
typeahead: Typeahead;
|
|
12
|
+
cleanupPortal: (() => void) | null;
|
|
13
|
+
open: boolean;
|
|
14
|
+
highlightedIndex: number;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const instances = new WeakMap<HTMLElement, ContextMenuInstance>();
|
|
18
|
+
|
|
19
|
+
let idCounter = 0;
|
|
20
|
+
function uniqueId(prefix: string) {
|
|
21
|
+
return `${prefix}-${++idCounter}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function getEnabledItems(items: HTMLElement[]): HTMLElement[] {
|
|
25
|
+
return items.filter((item) => item.getAttribute("data-disabled") !== "true");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function init(root: HTMLElement) {
|
|
29
|
+
if (root.hasAttribute("data-initialized")) return;
|
|
30
|
+
root.setAttribute("data-initialized", "");
|
|
31
|
+
|
|
32
|
+
const trigger = root.querySelector<HTMLElement>("[data-part='trigger']");
|
|
33
|
+
const content = root.querySelector<HTMLElement>("[data-part='content']");
|
|
34
|
+
if (!trigger || !content) return;
|
|
35
|
+
|
|
36
|
+
const items = Array.from(
|
|
37
|
+
content.querySelectorAll<HTMLElement>("[data-part='item']"),
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const menuId = uniqueId("base-context-menu");
|
|
41
|
+
content.id = content.id || `${menuId}-menu`;
|
|
42
|
+
|
|
43
|
+
items.forEach((item, i) => {
|
|
44
|
+
item.id = item.id || `${menuId}-item-${i}`;
|
|
45
|
+
item.setAttribute("tabindex", "-1");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const typeahead = new Typeahead({
|
|
49
|
+
onMatch: (index) => {
|
|
50
|
+
const enabled = getEnabledItems(items);
|
|
51
|
+
if (index < enabled.length) {
|
|
52
|
+
highlightItem(instance, items.indexOf(enabled[index]));
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
getItemText: (i) => getEnabledItems(items)[i]?.textContent?.trim() || "",
|
|
56
|
+
getItemCount: () => getEnabledItems(items).length,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const instance: ContextMenuInstance = {
|
|
60
|
+
root,
|
|
61
|
+
trigger,
|
|
62
|
+
content,
|
|
63
|
+
items,
|
|
64
|
+
dismiss: new DismissController(content, {
|
|
65
|
+
onDismiss: () => close(instance),
|
|
66
|
+
}),
|
|
67
|
+
typeahead,
|
|
68
|
+
cleanupPortal: null,
|
|
69
|
+
open: false,
|
|
70
|
+
highlightedIndex: -1,
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
instances.set(root, instance);
|
|
74
|
+
|
|
75
|
+
// Right-click opens context menu
|
|
76
|
+
trigger.addEventListener("contextmenu", (e) => {
|
|
77
|
+
e.preventDefault();
|
|
78
|
+
open(instance, e.clientX, e.clientY);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// Keyboard navigation inside menu
|
|
82
|
+
content.addEventListener("keydown", (e) => {
|
|
83
|
+
if (!instance.open) return;
|
|
84
|
+
|
|
85
|
+
const enabled = getEnabledItems(items);
|
|
86
|
+
if (enabled.length === 0) return;
|
|
87
|
+
|
|
88
|
+
const current = instance.highlightedIndex >= 0 ? items[instance.highlightedIndex] : null;
|
|
89
|
+
const currentEnabled = current ? enabled.indexOf(current) : -1;
|
|
90
|
+
|
|
91
|
+
switch (e.key) {
|
|
92
|
+
case "ArrowDown": {
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
const next = currentEnabled < enabled.length - 1 ? currentEnabled + 1 : 0;
|
|
95
|
+
highlightItem(instance, items.indexOf(enabled[next]));
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case "ArrowUp": {
|
|
99
|
+
e.preventDefault();
|
|
100
|
+
const prev = currentEnabled > 0 ? currentEnabled - 1 : enabled.length - 1;
|
|
101
|
+
highlightItem(instance, items.indexOf(enabled[prev]));
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
case "Home":
|
|
105
|
+
e.preventDefault();
|
|
106
|
+
highlightItem(instance, items.indexOf(enabled[0]));
|
|
107
|
+
break;
|
|
108
|
+
case "End":
|
|
109
|
+
e.preventDefault();
|
|
110
|
+
highlightItem(instance, items.indexOf(enabled[enabled.length - 1]));
|
|
111
|
+
break;
|
|
112
|
+
case "Enter":
|
|
113
|
+
case " ":
|
|
114
|
+
e.preventDefault();
|
|
115
|
+
if (instance.highlightedIndex >= 0) {
|
|
116
|
+
items[instance.highlightedIndex].click();
|
|
117
|
+
}
|
|
118
|
+
close(instance);
|
|
119
|
+
break;
|
|
120
|
+
case "Tab":
|
|
121
|
+
close(instance);
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
if (e.key.length === 1) typeahead.handle(e.key);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
// Item interactions
|
|
129
|
+
items.forEach((item) => {
|
|
130
|
+
item.addEventListener("click", () => {
|
|
131
|
+
if (item.getAttribute("data-disabled") === "true") return;
|
|
132
|
+
close(instance);
|
|
133
|
+
});
|
|
134
|
+
item.addEventListener("pointerenter", () => {
|
|
135
|
+
if (item.getAttribute("data-disabled") === "true") return;
|
|
136
|
+
highlightItem(instance, items.indexOf(item));
|
|
137
|
+
});
|
|
138
|
+
item.addEventListener("pointerleave", () => {
|
|
139
|
+
clearHighlight(instance);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function open(instance: ContextMenuInstance, x: number, y: number) {
|
|
145
|
+
if (instance.open) close(instance);
|
|
146
|
+
instance.open = true;
|
|
147
|
+
|
|
148
|
+
// Portal to body
|
|
149
|
+
instance.cleanupPortal = createPortal(instance.content, instance.content.id);
|
|
150
|
+
|
|
151
|
+
// Show and position at cursor
|
|
152
|
+
instance.content.hidden = false;
|
|
153
|
+
instance.content.setAttribute("data-state", "open");
|
|
154
|
+
instance.content.style.position = "fixed";
|
|
155
|
+
instance.content.style.left = `${x}px`;
|
|
156
|
+
instance.content.style.top = `${y}px`;
|
|
157
|
+
|
|
158
|
+
// Clamp to viewport
|
|
159
|
+
requestAnimationFrame(() => {
|
|
160
|
+
const rect = instance.content.getBoundingClientRect();
|
|
161
|
+
const vw = window.innerWidth;
|
|
162
|
+
const vh = window.innerHeight;
|
|
163
|
+
|
|
164
|
+
if (rect.right > vw) {
|
|
165
|
+
instance.content.style.left = `${vw - rect.width - 4}px`;
|
|
166
|
+
}
|
|
167
|
+
if (rect.bottom > vh) {
|
|
168
|
+
instance.content.style.top = `${vh - rect.height - 4}px`;
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Focus first enabled item
|
|
173
|
+
const enabled = getEnabledItems(instance.items);
|
|
174
|
+
if (enabled.length > 0) {
|
|
175
|
+
highlightItem(instance, instance.items.indexOf(enabled[0]));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
instance.dismiss.activate();
|
|
179
|
+
instance.typeahead.reset();
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function close(instance: ContextMenuInstance) {
|
|
183
|
+
if (!instance.open) return;
|
|
184
|
+
instance.open = false;
|
|
185
|
+
|
|
186
|
+
instance.dismiss.deactivate();
|
|
187
|
+
instance.content.setAttribute("data-state", "closed");
|
|
188
|
+
instance.content.hidden = true;
|
|
189
|
+
instance.content.style.position = "";
|
|
190
|
+
instance.content.style.left = "";
|
|
191
|
+
instance.content.style.top = "";
|
|
192
|
+
|
|
193
|
+
clearHighlight(instance);
|
|
194
|
+
|
|
195
|
+
if (instance.cleanupPortal) {
|
|
196
|
+
instance.cleanupPortal();
|
|
197
|
+
instance.cleanupPortal = null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
instance.typeahead.reset();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function highlightItem(instance: ContextMenuInstance, index: number) {
|
|
204
|
+
if (index < 0 || index >= instance.items.length) return;
|
|
205
|
+
|
|
206
|
+
if (instance.highlightedIndex >= 0) {
|
|
207
|
+
const prev = instance.items[instance.highlightedIndex];
|
|
208
|
+
prev.removeAttribute("data-highlighted");
|
|
209
|
+
prev.setAttribute("tabindex", "-1");
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
instance.highlightedIndex = index;
|
|
213
|
+
const item = instance.items[index];
|
|
214
|
+
item.setAttribute("data-highlighted", "");
|
|
215
|
+
item.setAttribute("tabindex", "0");
|
|
216
|
+
item.focus();
|
|
217
|
+
item.scrollIntoView({ block: "nearest" });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function clearHighlight(instance: ContextMenuInstance) {
|
|
221
|
+
if (instance.highlightedIndex >= 0) {
|
|
222
|
+
const prev = instance.items[instance.highlightedIndex];
|
|
223
|
+
prev.removeAttribute("data-highlighted");
|
|
224
|
+
prev.setAttribute("tabindex", "-1");
|
|
225
|
+
}
|
|
226
|
+
instance.highlightedIndex = -1;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
function initAll() {
|
|
230
|
+
document.querySelectorAll<HTMLElement>("[data-component='context-menu']").forEach(init);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (document.readyState === "loading") {
|
|
234
|
+
document.addEventListener("DOMContentLoaded", initAll);
|
|
235
|
+
} else {
|
|
236
|
+
initAll();
|
|
237
|
+
}
|
|
238
|
+
document.addEventListener("astro:page-load", initAll);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as ContextMenu } from "./ContextMenu.astro";
|
|
2
|
+
export { default as ContextMenuTrigger } from "./ContextMenuTrigger.astro";
|
|
3
|
+
export { default as ContextMenuContent } from "./ContextMenuContent.astro";
|
|
4
|
+
export { default as ContextMenuItem } from "./ContextMenuItem.astro";
|
|
5
|
+
export { default as ContextMenuSeparator } from "./ContextMenuSeparator.astro";
|
|
6
|
+
export { default as ContextMenuShortcut } from "./ContextMenuShortcut.astro";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const copyButton = tv({
|
|
5
|
+
base: "inline-flex h-8 w-8 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
text: string;
|
|
10
|
+
class?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { text, class: className, ...rest } = Astro.props;
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<button
|
|
18
|
+
class={copyButton({ class: className })}
|
|
19
|
+
data-component="copy-button"
|
|
20
|
+
data-copy-text={text}
|
|
21
|
+
type="button"
|
|
22
|
+
aria-label="Copy to clipboard"
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<svg
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
width="14"
|
|
28
|
+
height="14"
|
|
29
|
+
viewBox="0 0 24 24"
|
|
30
|
+
fill="none"
|
|
31
|
+
stroke="currentColor"
|
|
32
|
+
stroke-width="2"
|
|
33
|
+
stroke-linecap="round"
|
|
34
|
+
stroke-linejoin="round"
|
|
35
|
+
data-copy-icon
|
|
36
|
+
aria-hidden="true"
|
|
37
|
+
>
|
|
38
|
+
<rect width="14" height="14" x="8" y="8" rx="2" ry="2"></rect>
|
|
39
|
+
<path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"></path>
|
|
40
|
+
</svg>
|
|
41
|
+
<svg
|
|
42
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
+
width="14"
|
|
44
|
+
height="14"
|
|
45
|
+
viewBox="0 0 24 24"
|
|
46
|
+
fill="none"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
stroke-width="2"
|
|
49
|
+
stroke-linecap="round"
|
|
50
|
+
stroke-linejoin="round"
|
|
51
|
+
data-check-icon
|
|
52
|
+
class="hidden"
|
|
53
|
+
aria-hidden="true"
|
|
54
|
+
>
|
|
55
|
+
<polyline points="20 6 9 17 4 12"></polyline>
|
|
56
|
+
</svg>
|
|
57
|
+
</button>
|
|
58
|
+
|
|
59
|
+
<script>
|
|
60
|
+
function setupCopyButtons() {
|
|
61
|
+
document.querySelectorAll("[data-component='copy-button']").forEach((btn) => {
|
|
62
|
+
if ((btn as any).__copyBound) return;
|
|
63
|
+
(btn as any).__copyBound = true;
|
|
64
|
+
|
|
65
|
+
btn.addEventListener("click", async () => {
|
|
66
|
+
const text = btn.getAttribute("data-copy-text") || "";
|
|
67
|
+
try {
|
|
68
|
+
await navigator.clipboard.writeText(text);
|
|
69
|
+
const copyIcon = btn.querySelector("[data-copy-icon]") as HTMLElement;
|
|
70
|
+
const checkIcon = btn.querySelector("[data-check-icon]") as HTMLElement;
|
|
71
|
+
if (copyIcon && checkIcon) {
|
|
72
|
+
copyIcon.classList.add("hidden");
|
|
73
|
+
checkIcon.classList.remove("hidden");
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
copyIcon.classList.remove("hidden");
|
|
76
|
+
checkIcon.classList.add("hidden");
|
|
77
|
+
}, 2000);
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// Fallback: do nothing
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
setupCopyButtons();
|
|
87
|
+
document.addEventListener("astro:after-swap", setupCopyButtons);
|
|
88
|
+
</script>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as CopyButton } from "./CopyButton.astro";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
---
|
|
2
|
+
interface Props {
|
|
3
|
+
lang: string;
|
|
4
|
+
code: string;
|
|
5
|
+
svg: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const { lang, svg, title } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<figure class="diagram not-prose" data-lang={lang}>
|
|
13
|
+
{title && <figcaption class="text-sm text-muted-foreground mb-2">{title}</figcaption>}
|
|
14
|
+
<div class="diagram-content overflow-x-auto [&>svg]:mx-auto [&>svg]:max-w-full dark:invert dark:[&>svg]:hue-rotate-180" set:html={svg} />
|
|
15
|
+
</figure>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Diagram } from "./Diagram.astro";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const dialog = tv({
|
|
5
|
+
base: "relative",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
class?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { class: className, ...rest } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<div
|
|
17
|
+
class={dialog({ class: className })}
|
|
18
|
+
data-component="dialog"
|
|
19
|
+
{...rest}
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|