@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
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dogsbay/ui",
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
|
+
"description": "Accessible UI components for Astro, inspired by Base UI and shadcn",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./*": "./src/*"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"tailwind-variants": "^0.3.0"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"astro": "^5.0.0 || ^6.0.0",
|
|
14
|
+
"@dogsbay/primitives": "0.2.0-beta.0",
|
|
15
|
+
"@dogsbay/elements": "0.2.0-beta.0",
|
|
16
|
+
"@dogsbay/icons": "0.2.0-beta.0"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"shiki": "^4.0.0",
|
|
20
|
+
"@shikijs/transformers": "^4.0.0",
|
|
21
|
+
"maplibre-gl": "^5.0.0",
|
|
22
|
+
"katex": "^0.16.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "https://github.com/dogsbay/dogsbay.git",
|
|
32
|
+
"directory": "packages/ui"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/dogsbay/dogsbay/tree/main/packages/ui",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/dogsbay/dogsbay/issues"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const accordion = tv({
|
|
5
|
+
base: "w-full",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
type?: "single" | "multiple";
|
|
10
|
+
defaultValue?: string | string[];
|
|
11
|
+
class?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const {
|
|
16
|
+
type = "single",
|
|
17
|
+
defaultValue,
|
|
18
|
+
class: className,
|
|
19
|
+
...rest
|
|
20
|
+
} = Astro.props;
|
|
21
|
+
|
|
22
|
+
const defaultStr = Array.isArray(defaultValue)
|
|
23
|
+
? defaultValue.join(",")
|
|
24
|
+
: defaultValue || "";
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<db-accordion
|
|
28
|
+
class={accordion({ class: className })}
|
|
29
|
+
type={type}
|
|
30
|
+
default-value={defaultStr}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
<slot />
|
|
34
|
+
</db-accordion>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
import "@dogsbay/elements/db-accordion";
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const accordionContent = tv({
|
|
5
|
+
base: "overflow-hidden text-sm transition-all",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
default?: boolean;
|
|
10
|
+
class?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const { default: isDefault = false, class: className, ...rest } = Astro.props;
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
<div
|
|
18
|
+
class={accordionContent({ class: className })}
|
|
19
|
+
data-part="content"
|
|
20
|
+
role="region"
|
|
21
|
+
hidden={!isDefault}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
<slot />
|
|
25
|
+
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const accordionItem = tv({
|
|
5
|
+
base: "border-b",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
value: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
class?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const { value, disabled = false, class: className, ...rest } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<div
|
|
19
|
+
class={accordionItem({ class: className })}
|
|
20
|
+
data-part="item"
|
|
21
|
+
data-value={value}
|
|
22
|
+
data-disabled={disabled || undefined}
|
|
23
|
+
{...rest}
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</div>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const accordionTrigger = tv({
|
|
5
|
+
base: "flex w-full items-center justify-between py-4 font-medium transition-all hover:underline [&[aria-expanded=true]>svg]:rotate-180 disabled:pointer-events-none disabled:opacity-50",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
class?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const { class: className, ...rest } = Astro.props;
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
<button
|
|
17
|
+
class={accordionTrigger({ class: className })}
|
|
18
|
+
data-part="trigger"
|
|
19
|
+
type="button"
|
|
20
|
+
{...rest}
|
|
21
|
+
>
|
|
22
|
+
<slot />
|
|
23
|
+
<svg
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
width="16"
|
|
26
|
+
height="16"
|
|
27
|
+
viewBox="0 0 24 24"
|
|
28
|
+
fill="none"
|
|
29
|
+
stroke="currentColor"
|
|
30
|
+
stroke-width="2"
|
|
31
|
+
stroke-linecap="round"
|
|
32
|
+
stroke-linejoin="round"
|
|
33
|
+
class="shrink-0 transition-transform duration-200"
|
|
34
|
+
aria-hidden="true"
|
|
35
|
+
>
|
|
36
|
+
<polyline points="6 9 12 15 18 9"></polyline>
|
|
37
|
+
</svg>
|
|
38
|
+
</button>
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { CompositeNavigation } from "@dogsbay/primitives/composite";
|
|
2
|
+
import { Collapsible } from "@dogsbay/primitives/collapsible";
|
|
3
|
+
|
|
4
|
+
interface AccordionItem {
|
|
5
|
+
el: HTMLElement;
|
|
6
|
+
value: string;
|
|
7
|
+
collapsible: Collapsible;
|
|
8
|
+
disabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface AccordionInstance {
|
|
12
|
+
root: HTMLElement;
|
|
13
|
+
type: "single" | "multiple";
|
|
14
|
+
items: AccordionItem[];
|
|
15
|
+
nav: CompositeNavigation;
|
|
16
|
+
openValues: Set<string>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const instances = new WeakMap<HTMLElement, AccordionInstance>();
|
|
20
|
+
|
|
21
|
+
function initAccordion(root: HTMLElement) {
|
|
22
|
+
if (instances.has(root)) return;
|
|
23
|
+
|
|
24
|
+
const type = (root.dataset.type as "single" | "multiple") || "single";
|
|
25
|
+
const defaultStr = root.dataset.defaultValue || "";
|
|
26
|
+
const defaultValues = defaultStr ? defaultStr.split(",") : [];
|
|
27
|
+
|
|
28
|
+
const itemEls = Array.from(
|
|
29
|
+
root.querySelectorAll("[data-part='item']"),
|
|
30
|
+
) as HTMLElement[];
|
|
31
|
+
|
|
32
|
+
const items = itemEls
|
|
33
|
+
.map((el) => {
|
|
34
|
+
const trigger = el.querySelector(
|
|
35
|
+
"[data-part='trigger']",
|
|
36
|
+
) as HTMLElement | null;
|
|
37
|
+
const content = el.querySelector(
|
|
38
|
+
"[data-part='content']",
|
|
39
|
+
) as HTMLElement | null;
|
|
40
|
+
if (!trigger || !content) return null;
|
|
41
|
+
|
|
42
|
+
const value = el.dataset.value || "";
|
|
43
|
+
const disabled = el.hasAttribute("data-disabled");
|
|
44
|
+
|
|
45
|
+
if (disabled) {
|
|
46
|
+
trigger.setAttribute("disabled", "");
|
|
47
|
+
trigger.setAttribute("aria-disabled", "true");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Create a Collapsible instance for each item
|
|
51
|
+
// We pass onToggle to coordinate single/multiple behavior
|
|
52
|
+
const collapsible = new Collapsible(trigger, content, {
|
|
53
|
+
onToggle: (open) => {
|
|
54
|
+
if (open) {
|
|
55
|
+
onItemExpanded(root, value);
|
|
56
|
+
} else {
|
|
57
|
+
onItemCollapsed(root, value);
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return { el, value, collapsible, disabled };
|
|
63
|
+
})
|
|
64
|
+
.filter(Boolean) as AccordionItem[];
|
|
65
|
+
|
|
66
|
+
// Keyboard navigation on triggers
|
|
67
|
+
const nav = new CompositeNavigation(root, "[data-part='trigger']", {
|
|
68
|
+
orientation: "vertical",
|
|
69
|
+
loop: true,
|
|
70
|
+
homeEnd: true,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const instance: AccordionInstance = {
|
|
74
|
+
root,
|
|
75
|
+
type,
|
|
76
|
+
items,
|
|
77
|
+
nav,
|
|
78
|
+
openValues: new Set(),
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
instances.set(root, instance);
|
|
82
|
+
|
|
83
|
+
// Activate keyboard nav
|
|
84
|
+
nav.activate();
|
|
85
|
+
|
|
86
|
+
// Set initial tabindex for roving
|
|
87
|
+
items.forEach((item, i) => {
|
|
88
|
+
item.collapsible.trigger.setAttribute("tabindex", i === 0 ? "0" : "-1");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Set initial open state
|
|
92
|
+
defaultValues.forEach((value) => {
|
|
93
|
+
const item = items.find((i) => i.value === value && !i.disabled);
|
|
94
|
+
if (item) {
|
|
95
|
+
item.collapsible.expand();
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function onItemExpanded(root: HTMLElement, value: string) {
|
|
101
|
+
const instance = instances.get(root);
|
|
102
|
+
if (!instance) return;
|
|
103
|
+
|
|
104
|
+
// In single mode, collapse all others
|
|
105
|
+
if (instance.type === "single") {
|
|
106
|
+
for (const openValue of instance.openValues) {
|
|
107
|
+
if (openValue !== value) {
|
|
108
|
+
const other = instance.items.find((i) => i.value === openValue);
|
|
109
|
+
if (other) {
|
|
110
|
+
other.collapsible.collapse();
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
instance.openValues.add(value);
|
|
117
|
+
const item = instance.items.find((i) => i.value === value);
|
|
118
|
+
if (item) {
|
|
119
|
+
item.el.setAttribute("data-state", "open");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
root.dispatchEvent(
|
|
123
|
+
new CustomEvent("base-accordion:change", {
|
|
124
|
+
detail: { value, open: true, openValues: [...instance.openValues] },
|
|
125
|
+
bubbles: true,
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function onItemCollapsed(root: HTMLElement, value: string) {
|
|
131
|
+
const instance = instances.get(root);
|
|
132
|
+
if (!instance) return;
|
|
133
|
+
|
|
134
|
+
instance.openValues.delete(value);
|
|
135
|
+
const item = instance.items.find((i) => i.value === value);
|
|
136
|
+
if (item) {
|
|
137
|
+
item.el.removeAttribute("data-state");
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
root.dispatchEvent(
|
|
141
|
+
new CustomEvent("base-accordion:change", {
|
|
142
|
+
detail: { value, open: false, openValues: [...instance.openValues] },
|
|
143
|
+
bubbles: true,
|
|
144
|
+
}),
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function toggleItem(root: HTMLElement, value: string) {
|
|
149
|
+
const instance = instances.get(root);
|
|
150
|
+
if (!instance) return;
|
|
151
|
+
const item = instance.items.find((i) => i.value === value);
|
|
152
|
+
if (item && !item.disabled) {
|
|
153
|
+
item.collapsible.toggle();
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function expandItem(root: HTMLElement, value: string) {
|
|
158
|
+
const instance = instances.get(root);
|
|
159
|
+
if (!instance) return;
|
|
160
|
+
const item = instance.items.find((i) => i.value === value);
|
|
161
|
+
if (item && !item.disabled) {
|
|
162
|
+
item.collapsible.expand();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function collapseItem(root: HTMLElement, value: string) {
|
|
167
|
+
const instance = instances.get(root);
|
|
168
|
+
if (!instance) return;
|
|
169
|
+
const item = instance.items.find((i) => i.value === value);
|
|
170
|
+
if (item) {
|
|
171
|
+
item.collapsible.collapse();
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Auto-initialize
|
|
176
|
+
function init() {
|
|
177
|
+
document.querySelectorAll("[data-component='accordion']").forEach((el) => {
|
|
178
|
+
initAccordion(el as HTMLElement);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (document.readyState === "loading") {
|
|
183
|
+
document.addEventListener("DOMContentLoaded", init);
|
|
184
|
+
} else {
|
|
185
|
+
init();
|
|
186
|
+
}
|
|
187
|
+
document.addEventListener("astro:page-load", init);
|
|
188
|
+
|
|
189
|
+
export { initAccordion, toggleItem, expandItem, collapseItem };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv, type VariantProps } from "tailwind-variants";
|
|
3
|
+
import { contentVariants, icons } from "./variants.js";
|
|
4
|
+
import { resolveIcon } from "./icon.js";
|
|
5
|
+
|
|
6
|
+
const alert = tv({
|
|
7
|
+
base: "relative w-full rounded-lg border p-4 [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:size-4 [&>svg~div]:pl-7",
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: "bg-background text-foreground",
|
|
11
|
+
destructive:
|
|
12
|
+
"border-destructive/50 text-destructive [&>*[data-part='title']]:text-destructive [&>svg]:text-destructive",
|
|
13
|
+
note: "border-note/50 bg-note/5 text-foreground [&>svg]:text-note",
|
|
14
|
+
abstract: "border-abstract/50 bg-abstract/5 text-foreground [&>svg]:text-abstract",
|
|
15
|
+
info: "border-info/50 bg-info/5 text-foreground [&>svg]:text-info",
|
|
16
|
+
tip: "border-tip/50 bg-tip/5 text-foreground [&>svg]:text-tip",
|
|
17
|
+
success: "border-success/50 bg-success/5 text-foreground [&>svg]:text-success",
|
|
18
|
+
question: "border-question/50 bg-question/5 text-foreground [&>svg]:text-question",
|
|
19
|
+
warning: "border-warning/50 bg-warning/5 text-foreground [&>svg]:text-warning",
|
|
20
|
+
failure: "border-failure/50 bg-failure/5 text-foreground [&>svg]:text-failure",
|
|
21
|
+
danger: "border-danger/50 bg-danger/5 text-foreground [&>svg]:text-danger",
|
|
22
|
+
bug: "border-bug/50 bg-bug/5 text-foreground [&>svg]:text-bug",
|
|
23
|
+
example: "border-example/50 bg-example/5 text-foreground [&>svg]:text-example",
|
|
24
|
+
quote: "border-quote/50 bg-quote/5 text-foreground [&>svg]:text-quote",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
variant: "default",
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
type AlertVariants = VariantProps<typeof alert>;
|
|
33
|
+
|
|
34
|
+
interface Props {
|
|
35
|
+
variant?: AlertVariants["variant"];
|
|
36
|
+
/**
|
|
37
|
+
* Optional icon shortcode to override the variant default.
|
|
38
|
+
* Format: `library:name` (e.g. "lucide:rocket", "material:check-circle",
|
|
39
|
+
* "simple:github") or a bare emoji shortcode (e.g. "rocket" → 🚀).
|
|
40
|
+
* Unknown icons fall back to the variant default.
|
|
41
|
+
*/
|
|
42
|
+
icon?: string;
|
|
43
|
+
class?: string;
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const { variant = "default", icon: iconShortcode, class: className, ...rest } = Astro.props;
|
|
48
|
+
|
|
49
|
+
const role = variant === "destructive"
|
|
50
|
+
? "alert"
|
|
51
|
+
: contentVariants.has(variant || "")
|
|
52
|
+
? "note"
|
|
53
|
+
: "status";
|
|
54
|
+
|
|
55
|
+
// Resolve icon: user-provided shortcode takes precedence; otherwise variant default
|
|
56
|
+
const customIcon = iconShortcode ? resolveIcon(iconShortcode) : null;
|
|
57
|
+
const variantIcon = contentVariants.has(variant || "") ? icons[variant!] : null;
|
|
58
|
+
const icon = customIcon ?? variantIcon;
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
<div
|
|
62
|
+
class={alert({ variant, class: className })}
|
|
63
|
+
data-variant={variant}
|
|
64
|
+
role={role}
|
|
65
|
+
{...rest}
|
|
66
|
+
>
|
|
67
|
+
{icon && <Fragment set:html={icon} />}
|
|
68
|
+
<slot />
|
|
69
|
+
</div>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const alertDescription = tv({
|
|
5
|
+
base: "text-sm [&_p]:leading-relaxed",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
class?: string;
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
const { class: className, ...rest } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<div class={alertDescription({ class: className })} {...rest}>
|
|
16
|
+
<slot />
|
|
17
|
+
</div>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { tv } from "tailwind-variants";
|
|
3
|
+
|
|
4
|
+
const alertTitle = tv({
|
|
5
|
+
base: "mb-1 text-sm font-semibold leading-none tracking-tight",
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
type Element = "p" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "div" | "span";
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
as?: Element;
|
|
12
|
+
class?: string;
|
|
13
|
+
[key: string]: unknown;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const { as: Tag = "div", class: className, ...rest } = Astro.props;
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<Tag class={alertTitle({ class: className })} data-part="title" {...rest}>
|
|
20
|
+
<slot />
|
|
21
|
+
</Tag>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* CollapsibleAlert — a <details>-based alert with two-tone backgrounds.
|
|
4
|
+
*
|
|
5
|
+
* Title bar gets a stronger variant tint, body gets a subtle tint.
|
|
6
|
+
* Composes with the same variant tokens as Alert.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* <CollapsibleAlert variant="warning" title="Warning" open>
|
|
10
|
+
* <p>Body content here.</p>
|
|
11
|
+
* </CollapsibleAlert>
|
|
12
|
+
*/
|
|
13
|
+
import { tv, type VariantProps } from "tailwind-variants";
|
|
14
|
+
import { contentVariants, icons, chevronSvg } from "./variants.js";
|
|
15
|
+
|
|
16
|
+
const wrapper = tv({
|
|
17
|
+
base: "relative w-full rounded-lg border overflow-hidden [&>summary]:list-none [&>summary::-webkit-details-marker]:hidden",
|
|
18
|
+
variants: {
|
|
19
|
+
variant: {
|
|
20
|
+
default: "border-border",
|
|
21
|
+
destructive: "border-destructive/50",
|
|
22
|
+
note: "border-note/50",
|
|
23
|
+
abstract: "border-abstract/50",
|
|
24
|
+
info: "border-info/50",
|
|
25
|
+
tip: "border-tip/50",
|
|
26
|
+
success: "border-success/50",
|
|
27
|
+
question: "border-question/50",
|
|
28
|
+
warning: "border-warning/50",
|
|
29
|
+
failure: "border-failure/50",
|
|
30
|
+
danger: "border-danger/50",
|
|
31
|
+
bug: "border-bug/50",
|
|
32
|
+
example: "border-example/50",
|
|
33
|
+
quote: "border-quote/50",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: { variant: "default" },
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
type Variant = VariantProps<typeof wrapper>["variant"];
|
|
40
|
+
|
|
41
|
+
/** Title bar: stronger tint (~10%) */
|
|
42
|
+
const titleBg: Record<string, string> = {
|
|
43
|
+
default: "bg-muted",
|
|
44
|
+
destructive: "bg-destructive/10 text-destructive",
|
|
45
|
+
note: "bg-note/10", abstract: "bg-abstract/10", info: "bg-info/10",
|
|
46
|
+
tip: "bg-tip/10", success: "bg-success/10", question: "bg-question/10",
|
|
47
|
+
warning: "bg-warning/10", failure: "bg-failure/10", danger: "bg-danger/10",
|
|
48
|
+
bug: "bg-bug/10", example: "bg-example/10", quote: "bg-quote/10",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** Body: subtle tint (~3%) */
|
|
52
|
+
const bodyBg: Record<string, string> = {
|
|
53
|
+
default: "bg-background",
|
|
54
|
+
destructive: "bg-destructive/3",
|
|
55
|
+
note: "bg-note/3", abstract: "bg-abstract/3", info: "bg-info/3",
|
|
56
|
+
tip: "bg-tip/3", success: "bg-success/3", question: "bg-question/3",
|
|
57
|
+
warning: "bg-warning/3", failure: "bg-failure/3", danger: "bg-danger/3",
|
|
58
|
+
bug: "bg-bug/3", example: "bg-example/3", quote: "bg-quote/3",
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Icon color per variant */
|
|
62
|
+
const iconColor: Record<string, string> = {
|
|
63
|
+
destructive: "text-destructive",
|
|
64
|
+
note: "text-note", abstract: "text-abstract", info: "text-info",
|
|
65
|
+
tip: "text-tip", success: "text-success", question: "text-question",
|
|
66
|
+
warning: "text-warning", failure: "text-failure", danger: "text-danger",
|
|
67
|
+
bug: "text-bug", example: "text-example", quote: "text-quote",
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
interface Props {
|
|
71
|
+
variant?: Variant;
|
|
72
|
+
/** Title text shown in the summary bar */
|
|
73
|
+
title?: string;
|
|
74
|
+
/** Whether the details starts open */
|
|
75
|
+
open?: boolean;
|
|
76
|
+
class?: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const { variant = "note", title, open = false, class: className } = Astro.props;
|
|
80
|
+
const v = variant || "note";
|
|
81
|
+
|
|
82
|
+
const role = contentVariants.has(v) ? "note" : "status";
|
|
83
|
+
const icon = contentVariants.has(v) ? icons[v] : null;
|
|
84
|
+
---
|
|
85
|
+
|
|
86
|
+
<details
|
|
87
|
+
class:list={[wrapper({ variant, class: className }), "group/collapsible"]}
|
|
88
|
+
data-variant={variant}
|
|
89
|
+
role={role}
|
|
90
|
+
open={open}
|
|
91
|
+
>
|
|
92
|
+
<summary class:list={[
|
|
93
|
+
"flex cursor-pointer items-center gap-2 px-4 py-3 text-sm font-semibold select-none",
|
|
94
|
+
titleBg[v],
|
|
95
|
+
]}>
|
|
96
|
+
{icon && <span class:list={["shrink-0 [&>svg]:size-4", iconColor[v]]} set:html={icon} />}
|
|
97
|
+
<span class="flex-1 text-foreground" data-part="title">{title || v.charAt(0).toUpperCase() + v.slice(1)}</span>
|
|
98
|
+
<span class="shrink-0 text-muted-foreground group-open/collapsible:rotate-180 transition-transform duration-200" set:html={chevronSvg} />
|
|
99
|
+
</summary>
|
|
100
|
+
<div class:list={["px-4 py-3 text-sm [&_p]:leading-relaxed", bodyBg[v]]}>
|
|
101
|
+
<slot />
|
|
102
|
+
</div>
|
|
103
|
+
</details>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve an icon shortcode for the Alert component.
|
|
3
|
+
*
|
|
4
|
+
* Accepts two formats:
|
|
5
|
+
* - `library:name` — e.g. "lucide:rocket", "material:check-circle", "simple:github"
|
|
6
|
+
* - bare shortcode — treated as emoji (e.g. "rocket" → 🚀)
|
|
7
|
+
*
|
|
8
|
+
* Returns an inline SVG string or a span with the emoji character. Returns
|
|
9
|
+
* null when the shortcode can't be resolved (caller should fall back to the
|
|
10
|
+
* variant's default icon).
|
|
11
|
+
*/
|
|
12
|
+
import { createIconRegistry } from "@dogsbay/icons";
|
|
13
|
+
|
|
14
|
+
const registry = createIconRegistry();
|
|
15
|
+
|
|
16
|
+
export function resolveIcon(shortcode: string): string | null {
|
|
17
|
+
const colonIdx = shortcode.indexOf(":");
|
|
18
|
+
const [library, name] = colonIdx >= 0
|
|
19
|
+
? [shortcode.slice(0, colonIdx), shortcode.slice(colonIdx + 1)]
|
|
20
|
+
: ["emoji", shortcode];
|
|
21
|
+
|
|
22
|
+
const resolved = registry.resolve(library, name);
|
|
23
|
+
if (!resolved) return null;
|
|
24
|
+
|
|
25
|
+
// Emoji resolve to Unicode characters; wrap for consistent sizing/positioning
|
|
26
|
+
// with the SVG icons in the Alert layout.
|
|
27
|
+
if (library === "emoji") {
|
|
28
|
+
return `<span aria-hidden="true" style="font-size:1em;line-height:1;display:inline-block;width:1em;text-align:center;">${resolved}</span>`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return resolved;
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** Shared variant metadata for Alert and CollapsibleAlert */
|
|
2
|
+
|
|
3
|
+
export type AlertVariant =
|
|
4
|
+
| "default" | "destructive"
|
|
5
|
+
| "note" | "abstract" | "info" | "tip" | "success" | "question"
|
|
6
|
+
| "warning" | "failure" | "danger" | "bug" | "example" | "quote";
|
|
7
|
+
|
|
8
|
+
export const contentVariants = new Set<AlertVariant>([
|
|
9
|
+
"note", "abstract", "info", "tip", "success", "question",
|
|
10
|
+
"warning", "failure", "danger", "bug", "example", "quote",
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
/** Default icon SVGs per content variant (MkDocs Material icon set) */
|
|
14
|
+
export const icons: Partial<Record<AlertVariant, string>> = {
|
|
15
|
+
note: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m3.1 5.07c.14 0 .28.05.4.16l1.27 1.27c.23.22.23.57 0 .78l-1 1-2.05-2.05 1-1c.1-.11.24-.16.38-.16m-1.97 1.74 2.06 2.06-6.06 6.06H7.07v-2.06z"/></svg>',
|
|
16
|
+
abstract: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M17 9H7V7h10m0 6H7v-2h10m-3 6H7v-2h7M12 3a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1m7 0h-4.18C14.4 1.84 13.3 1 12 1s-2.4.84-2.82 2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2"/></svg>',
|
|
17
|
+
info: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M13 9h-2V7h2m0 10h-2v-6h2m-1-9A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2"/></svg>',
|
|
18
|
+
tip: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M17.66 11.2c-.23-.3-.51-.56-.77-.82-.67-.6-1.43-1.03-2.07-1.66C13.33 7.26 13 4.85 13.95 3c-.95.23-1.78.75-2.49 1.32-2.59 2.08-3.61 5.75-2.39 8.9.04.1.08.2.08.33 0 .22-.15.42-.35.5-.23.1-.47.04-.66-.12a.6.6 0 0 1-.14-.17c-1.13-1.43-1.31-3.48-.55-5.12C5.78 10 4.87 12.3 5 14.47c.06.5.12 1 .29 1.5.14.6.41 1.2.71 1.73 1.08 1.73 2.95 2.97 4.96 3.22 2.14.27 4.43-.12 6.07-1.6 1.83-1.66 2.47-4.32 1.53-6.6l-.13-.26c-.21-.46-.77-1.26-.77-1.26m-3.16 6.3c-.28.24-.74.5-1.1.6-1.12.4-2.24-.16-2.9-.82 1.19-.28 1.9-1.16 2.11-2.05.17-.8-.15-1.46-.28-2.23-.12-.74-.1-1.37.17-2.06.19.38.39.76.63 1.06.77 1 1.98 1.44 2.24 2.8.04.14.06.28.06.43.03.82-.33 1.72-.93 2.27"/></svg>',
|
|
19
|
+
success: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M21 7 9 19l-5.5-5.5 1.41-1.41L9 16.17 19.59 5.59z"/></svg>',
|
|
20
|
+
question: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m15.07 11.25-.9.92C13.45 12.89 13 13.5 13 15h-2v-.5c0-1.11.45-2.11 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41a2 2 0 0 0-2-2 2 2 0 0 0-2 2H8a4 4 0 0 1 4-4 4 4 0 0 1 4 4 3.2 3.2 0 0 1-.93 2.25M13 19h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10c0-5.53-4.5-10-10-10"/></svg>',
|
|
21
|
+
warning: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M13 14h-2V9h2m0 9h-2v-2h2M1 21h22L12 2z"/></svg>',
|
|
22
|
+
failure: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>',
|
|
23
|
+
danger: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m11.5 20 4.86-9.73H13V4l-5 9.73h3.5zM12 2c2.75 0 5.1 1 7.05 2.95S22 9.25 22 12s-1 5.1-2.95 7.05S14.75 22 12 22s-5.1-1-7.05-2.95S2 14.75 2 12s1-5.1 2.95-7.05S9.25 2 12 2"/></svg>',
|
|
24
|
+
bug: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="m11 13h2v1h-2zm10-8v6c0 5.5-3.8 10.7-9 12-5.2-1.3-9-6.5-9-12V5l9-4zm-4 5h-2.2c-.2-.6-.6-1.1-1.1-1.5l1.2-1.2-.7-.7L12.8 8H12c-.2 0-.5 0-.7.1L9.9 6.6l-.8.8 1.2 1.2c-.5.3-.9.8-1.1 1.4H7v1h2v1H7v1h2v1H7v1h2.2c.4 1.2 1.5 2 2.8 2s2.4-.8 2.8-2H17v-1h-2v-1h2v-1h-2v-1h2zm-6 2h2v-1h-2z"/></svg>',
|
|
25
|
+
example: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M7 2v2h1v14a4 4 0 0 0 4 4 4 4 0 0 0 4-4V4h1V2zm4 14c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1m2-4c-.6 0-1-.4-1-1s.4-1 1-1 1 .4 1 1-.4 1-1 1m1-5h-4V4h4z"/></svg>',
|
|
26
|
+
quote: '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="currentColor"><path d="M14 17h3l2-4V7h-6v6h3M6 17h3l2-4V7H5v6h3z"/></svg>',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const chevronSvg = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>';
|