@rimelight/ui 0.0.1
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/LICENSE +21 -0
- package/README.md +30 -0
- package/i18n-data.json +186 -0
- package/package.json +49 -0
- package/src/components/FormattedDate.astro +22 -0
- package/src/components/HeaderLink.astro +24 -0
- package/src/components/HttpObservatory.astro +103 -0
- package/src/components/LighthouseScores.astro +204 -0
- package/src/components/MissingTranslationBanner.astro +39 -0
- package/src/components/TableOfContents.astro +106 -0
- package/src/components/ThemeToggle.astro +71 -0
- package/src/components/accordion/Accordion.astro +257 -0
- package/src/components/accordion/AccordionContent.astro +34 -0
- package/src/components/accordion/AccordionItem.astro +29 -0
- package/src/components/accordion/AccordionTrigger.astro +33 -0
- package/src/components/alert/Alert.astro +34 -0
- package/src/components/alert/AlertDescription.astro +15 -0
- package/src/components/alert/AlertTitle.astro +17 -0
- package/src/components/alert-dialog/AlertDialog.astro +275 -0
- package/src/components/alert-dialog/AlertDialogAction.astro +46 -0
- package/src/components/alert-dialog/AlertDialogCancel.astro +46 -0
- package/src/components/alert-dialog/AlertDialogContent.astro +52 -0
- package/src/components/alert-dialog/AlertDialogDescription.astro +18 -0
- package/src/components/alert-dialog/AlertDialogFooter.astro +16 -0
- package/src/components/alert-dialog/AlertDialogHeader.astro +14 -0
- package/src/components/alert-dialog/AlertDialogTitle.astro +20 -0
- package/src/components/alert-dialog/AlertDialogTrigger.astro +47 -0
- package/src/components/aspect-ratio/AspectRatio.astro +32 -0
- package/src/components/avatar/Avatar.astro +29 -0
- package/src/components/avatar/AvatarFallback.astro +18 -0
- package/src/components/avatar/AvatarImage.astro +66 -0
- package/src/components/badge/Badge.astro +57 -0
- package/src/components/breadcrumb/Breadcrumb.astro +12 -0
- package/src/components/breadcrumb/BreadcrumbEllipsis.astro +29 -0
- package/src/components/breadcrumb/BreadcrumbItem.astro +15 -0
- package/src/components/breadcrumb/BreadcrumbLink.astro +24 -0
- package/src/components/breadcrumb/BreadcrumbList.astro +17 -0
- package/src/components/breadcrumb/BreadcrumbPage.astro +22 -0
- package/src/components/breadcrumb/BreadcrumbSeparator.astro +24 -0
- package/src/components/button/Button.astro +58 -0
- package/src/components/button-group/ButtonGroup.astro +64 -0
- package/src/components/button-group/ButtonGroupSeparator.astro +20 -0
- package/src/components/button-group/ButtonGroupText.astro +19 -0
- package/src/components/card/Card.astro +36 -0
- package/src/components/card/CardAction.astro +16 -0
- package/src/components/card/CardContent.astro +16 -0
- package/src/components/card/CardDescription.astro +16 -0
- package/src/components/card/CardFooter.astro +16 -0
- package/src/components/card/CardHeader.astro +19 -0
- package/src/components/card/CardTitle.astro +16 -0
- package/src/components/carousel/Carousel.astro +55 -0
- package/src/components/carousel/CarouselContent.astro +26 -0
- package/src/components/carousel/CarouselItem.astro +26 -0
- package/src/components/carousel/CarouselNext.astro +39 -0
- package/src/components/carousel/CarouselPrevious.astro +41 -0
- package/src/components/carousel/carousel-script.ts +188 -0
- package/src/components/carousel/index.ts +1 -0
- package/src/components/checkbox/Checkbox.astro +133 -0
- package/src/components/collapsible/Collapsible.astro +161 -0
- package/src/components/collapsible/CollapsibleContent.astro +22 -0
- package/src/components/collapsible/CollapsibleTrigger.astro +44 -0
- package/src/components/dialog/Dialog.astro +389 -0
- package/src/components/dialog/DialogClose.astro +35 -0
- package/src/components/dialog/DialogContent.astro +78 -0
- package/src/components/dialog/DialogDescription.astro +14 -0
- package/src/components/dialog/DialogFooter.astro +14 -0
- package/src/components/dialog/DialogHeader.astro +14 -0
- package/src/components/dialog/DialogTitle.astro +18 -0
- package/src/components/dialog/DialogTrigger.astro +47 -0
- package/src/components/dropdown/Dropdown.astro +604 -0
- package/src/components/dropdown/DropdownContent.astro +118 -0
- package/src/components/dropdown/DropdownItem.astro +48 -0
- package/src/components/dropdown/DropdownLabel.astro +29 -0
- package/src/components/dropdown/DropdownSeparator.astro +21 -0
- package/src/components/dropdown/DropdownShortcut.astro +17 -0
- package/src/components/dropdown/DropdownSub.astro +15 -0
- package/src/components/dropdown/DropdownSubContent.astro +39 -0
- package/src/components/dropdown/DropdownSubTrigger.astro +34 -0
- package/src/components/dropdown/DropdownTrigger.astro +52 -0
- package/src/components/dropzone/Dropzone.astro +236 -0
- package/src/components/dropzone/DropzoneFilesList.astro +26 -0
- package/src/components/dropzone/DropzoneLoadingIndicator.astro +10 -0
- package/src/components/dropzone/DropzoneUploadIndicator.astro +10 -0
- package/src/components/embeds/YoutubeEmbed.astro +94 -0
- package/src/components/hero/Hero.astro +166 -0
- package/src/components/icons/Flag.astro +62 -0
- package/src/components/image/ExtendedImage.astro +46 -0
- package/src/components/image/Image.astro +25 -0
- package/src/components/input/Input.astro +27 -0
- package/src/components/input-group/InputGroup.astro +28 -0
- package/src/components/input-group/InputGroupAddon.astro +76 -0
- package/src/components/input-group/InputGroupButton.astro +36 -0
- package/src/components/input-group/InputGroupInput.astro +18 -0
- package/src/components/input-group/InputGroupText.astro +17 -0
- package/src/components/input-group/InputGroupTextarea.astro +22 -0
- package/src/components/input-otp/InputOtp.astro +352 -0
- package/src/components/input-otp/InputOtpGroup.astro +16 -0
- package/src/components/input-otp/InputOtpSeparator.astro +25 -0
- package/src/components/input-otp/InputOtpSlot.astro +50 -0
- package/src/components/input-otp/InputOtpTypes.ts +6 -0
- package/src/components/item/Item.astro +52 -0
- package/src/components/item/ItemActions.astro +16 -0
- package/src/components/item/ItemContent.astro +16 -0
- package/src/components/item/ItemDescription.astro +19 -0
- package/src/components/item/ItemFooter.astro +16 -0
- package/src/components/item/ItemGroup.astro +16 -0
- package/src/components/item/ItemHeader.astro +16 -0
- package/src/components/item/ItemMedia.astro +40 -0
- package/src/components/item/ItemSeparator.astro +23 -0
- package/src/components/item/ItemTitle.astro +16 -0
- package/src/components/kbd/Kbd.astro +21 -0
- package/src/components/kbd/KbdGroup.astro +16 -0
- package/src/components/label/Label.astro +24 -0
- package/src/components/marquee/Marquee.astro +73 -0
- package/src/components/native-select/NativeSelect.astro +68 -0
- package/src/components/native-select/NativeSelectOptGroup.astro +15 -0
- package/src/components/native-select/NativeSelectOption.astro +15 -0
- package/src/components/pagination/Pagination.astro +20 -0
- package/src/components/pagination/PaginationContent.astro +16 -0
- package/src/components/pagination/PaginationEllipsis.astro +37 -0
- package/src/components/pagination/PaginationItem.astro +16 -0
- package/src/components/pagination/PaginationLink.astro +27 -0
- package/src/components/pagination/PaginationNext.astro +33 -0
- package/src/components/pagination/PaginationPrevious.astro +33 -0
- package/src/components/popover/Popover.astro +717 -0
- package/src/components/popover/PopoverContent.astro +102 -0
- package/src/components/popover/PopoverDescription.astro +14 -0
- package/src/components/popover/PopoverHeader.astro +14 -0
- package/src/components/popover/PopoverTitle.astro +14 -0
- package/src/components/popover/PopoverTrigger.astro +51 -0
- package/src/components/progress/Progress.astro +154 -0
- package/src/components/prose/Prose.astro +619 -0
- package/src/components/radio-group/RadioGroup.astro +162 -0
- package/src/components/radio-group/RadioGroupItem.astro +133 -0
- package/src/components/radio-group/RadioGroupTypes.ts +6 -0
- package/src/components/section/Section.astro +167 -0
- package/src/components/select/Select.astro +752 -0
- package/src/components/select/SelectContent.astro +94 -0
- package/src/components/select/SelectGroup.astro +9 -0
- package/src/components/select/SelectItem.astro +51 -0
- package/src/components/select/SelectLabel.astro +14 -0
- package/src/components/select/SelectSearch.astro +49 -0
- package/src/components/select/SelectSeparator.astro +12 -0
- package/src/components/select/SelectTrigger.astro +56 -0
- package/src/components/select/SelectTypes.ts +13 -0
- package/src/components/select/SelectValue.astro +19 -0
- package/src/components/separator/Separator.astro +36 -0
- package/src/components/sheet/Sheet.astro +15 -0
- package/src/components/sheet/SheetClose.astro +15 -0
- package/src/components/sheet/SheetContent.astro +89 -0
- package/src/components/sheet/SheetDescription.astro +16 -0
- package/src/components/sheet/SheetFooter.astro +16 -0
- package/src/components/sheet/SheetHeader.astro +16 -0
- package/src/components/sheet/SheetTitle.astro +16 -0
- package/src/components/sheet/SheetTrigger.astro +15 -0
- package/src/components/sidebar/Sidebar.astro +231 -0
- package/src/components/sidebar/SidebarContent.astro +25 -0
- package/src/components/sidebar/SidebarFooter.astro +22 -0
- package/src/components/sidebar/SidebarGroup.astro +22 -0
- package/src/components/sidebar/SidebarGroupContent.astro +22 -0
- package/src/components/sidebar/SidebarGroupLabel.astro +53 -0
- package/src/components/sidebar/SidebarHeader.astro +22 -0
- package/src/components/sidebar/SidebarInput.astro +24 -0
- package/src/components/sidebar/SidebarInset.astro +22 -0
- package/src/components/sidebar/SidebarMenu.astro +22 -0
- package/src/components/sidebar/SidebarMenuAction.astro +63 -0
- package/src/components/sidebar/SidebarMenuBadge.astro +31 -0
- package/src/components/sidebar/SidebarMenuButton.astro +124 -0
- package/src/components/sidebar/SidebarMenuItem.astro +22 -0
- package/src/components/sidebar/SidebarMenuSkeleton.astro +43 -0
- package/src/components/sidebar/SidebarMenuSub.astro +25 -0
- package/src/components/sidebar/SidebarMenuSubButton.astro +52 -0
- package/src/components/sidebar/SidebarMenuSubItem.astro +17 -0
- package/src/components/sidebar/SidebarProvider.astro +215 -0
- package/src/components/sidebar/SidebarRail.astro +72 -0
- package/src/components/sidebar/SidebarSeparator.astro +25 -0
- package/src/components/sidebar/SidebarTrigger.astro +69 -0
- package/src/components/skeleton/Skeleton.astro +14 -0
- package/src/components/slider/Slider.astro +425 -0
- package/src/components/spinner/Spinner.astro +23 -0
- package/src/components/switch/Switch.astro +192 -0
- package/src/components/switch/SwitchTypes.ts +6 -0
- package/src/components/table/Table.astro +20 -0
- package/src/components/table/TableBody.astro +18 -0
- package/src/components/table/TableCaption.astro +18 -0
- package/src/components/table/TableCell.astro +18 -0
- package/src/components/table/TableFoot.astro +18 -0
- package/src/components/table/TableHead.astro +18 -0
- package/src/components/table/TableHeader.astro +18 -0
- package/src/components/table/TableRow.astro +17 -0
- package/src/components/tabs/Tabs.astro +270 -0
- package/src/components/tabs/TabsContent.astro +28 -0
- package/src/components/tabs/TabsList.astro +23 -0
- package/src/components/tabs/TabsTrigger.astro +34 -0
- package/src/components/textarea/Textarea.astro +31 -0
- package/src/components/toast/ToastDescription.astro +22 -0
- package/src/components/toast/ToastItem.astro +56 -0
- package/src/components/toast/ToastTemplate.astro +27 -0
- package/src/components/toast/ToastTitle.astro +59 -0
- package/src/components/toast/Toaster.astro +981 -0
- package/src/components/toast/index.ts +1 -0
- package/src/components/toast/toast-manager.ts +234 -0
- package/src/components/toggle/Toggle.astro +174 -0
- package/src/components/toggle/ToggleTypes.ts +14 -0
- package/src/components/tooltip/Tooltip.astro +422 -0
- package/src/components/tooltip/TooltipContent.astro +83 -0
- package/src/components/tooltip/TooltipTrigger.astro +13 -0
- package/src/components/video/Video.astro +121 -0
- package/src/config/cookies.ts +5 -0
- package/src/config/index.ts +3 -0
- package/src/config/links.ts +4 -0
- package/src/config/site.config.ts +45 -0
- package/src/domain/cms/index.ts +1 -0
- package/src/domain/cms/types.ts +20 -0
- package/src/domain/i18n/constants.ts +21 -0
- package/src/domain/i18n/cookie-storage.ts +13 -0
- package/src/domain/i18n/country-to-locale-map.ts +67 -0
- package/src/domain/i18n/fallbacks.generated.ts +230 -0
- package/src/domain/i18n/fetcher.ts +268 -0
- package/src/domain/i18n/flags.ts +16 -0
- package/src/domain/i18n/format.ts +90 -0
- package/src/domain/i18n/index.ts +10 -0
- package/src/domain/i18n/middleware/i18n.ts +160 -0
- package/src/domain/i18n/resolve-locale.ts +55 -0
- package/src/domain/i18n/runtime-constants.ts +14 -0
- package/src/domain/i18n/schema.ts +29 -0
- package/src/domain/index.ts +4 -0
- package/src/domain/seo/constants.ts +20 -0
- package/src/domain/seo/index.ts +3 -0
- package/src/domain/seo/services/index.ts +3 -0
- package/src/domain/seo/services/llms.ts +53 -0
- package/src/domain/seo/services/robots.ts +12 -0
- package/src/domain/seo/services/sitemap.ts +56 -0
- package/src/domain/seo/utils.ts +37 -0
- package/src/domain/theme/constants.ts +6 -0
- package/src/domain/theme/index.ts +2 -0
- package/src/domain/theme/schema.ts +10 -0
- package/src/env.d.ts +49 -0
- package/src/i18n.generated.d.ts +202 -0
- package/src/lib/component-preview.ts +73 -0
- package/src/lib/index.ts +6 -0
- package/src/lib/remark/remark-modified-time.ts +13 -0
- package/src/lib/showcase-preview-elements.ts +408 -0
- package/src/lib/showcase-renderer.ts +218 -0
- package/src/lib/showcase-utils.ts +189 -0
- package/src/lib/turnstile.ts +35 -0
- package/src/lib/utils/starwind/positioning.ts +318 -0
- package/src/locales/de/blog.json +9 -0
- package/src/locales/de/common.json +19 -0
- package/src/locales/de/errors.json +6 -0
- package/src/locales/de/home.json +20 -0
- package/src/locales/de/messages.json +8 -0
- package/src/locales/de/nav.json +13 -0
- package/src/locales/de/projects.json +9 -0
- package/src/locales/de/services.json +43 -0
- package/src/locales/en/blog.json +9 -0
- package/src/locales/en/chat.json +29 -0
- package/src/locales/en/common.json +19 -0
- package/src/locales/en/cookie_notice.json +11 -0
- package/src/locales/en/editor.json +24 -0
- package/src/locales/en/errors.json +6 -0
- package/src/locales/en/home.json +20 -0
- package/src/locales/en/messages.json +8 -0
- package/src/locales/en/nav.json +13 -0
- package/src/locales/en/projects.json +9 -0
- package/src/locales/en/services.json +43 -0
- package/src/locales/es/blog.json +9 -0
- package/src/locales/es/common.json +19 -0
- package/src/locales/es/errors.json +6 -0
- package/src/locales/es/home.json +20 -0
- package/src/locales/es/messages.json +8 -0
- package/src/locales/es/nav.json +13 -0
- package/src/locales/es/projects.json +9 -0
- package/src/locales/es/services.json +43 -0
- package/src/locales/ja/blog.json +9 -0
- package/src/locales/ja/common.json +19 -0
- package/src/locales/ja/errors.json +6 -0
- package/src/locales/ja/home.json +20 -0
- package/src/locales/ja/messages.json +8 -0
- package/src/locales/ja/nav.json +13 -0
- package/src/locales/ja/projects.json +9 -0
- package/src/locales/ja/services.json +43 -0
- package/src/locales/pt/blog.json +9 -0
- package/src/locales/pt/chat.json +29 -0
- package/src/locales/pt/common.json +19 -0
- package/src/locales/pt/cookie_notice.json +11 -0
- package/src/locales/pt/editor.json +24 -0
- package/src/locales/pt/errors.json +6 -0
- package/src/locales/pt/home.json +20 -0
- package/src/locales/pt/messages.json +8 -0
- package/src/locales/pt/nav.json +13 -0
- package/src/locales/pt/projects.json +9 -0
- package/src/locales/pt/services.json +43 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/server/cookies.ts +98 -0
- package/src/utils/server/index.ts +1 -0
- package/src/utils/shared/deep-merge.ts +36 -0
- package/src/utils/shared/embed.ts +105 -0
- package/src/utils/shared/index.ts +3 -0
- package/src/utils/shared/parse-boolean.ts +14 -0
- package/worker-configuration.d.ts +14791 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"div"> & {
|
|
6
|
+
/**
|
|
7
|
+
* Side of the popover
|
|
8
|
+
* @default bottom
|
|
9
|
+
*/
|
|
10
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
11
|
+
/**
|
|
12
|
+
* Alignment of the popover
|
|
13
|
+
* @default center
|
|
14
|
+
*/
|
|
15
|
+
align?: "start" | "center" | "end";
|
|
16
|
+
/**
|
|
17
|
+
* Offset distance in pixels
|
|
18
|
+
* @default 4
|
|
19
|
+
*/
|
|
20
|
+
sideOffset?: number;
|
|
21
|
+
/**
|
|
22
|
+
* Open and close animation duration in milliseconds
|
|
23
|
+
* @default 150
|
|
24
|
+
*/
|
|
25
|
+
animationDuration?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Accessible name for the dialog when a PopoverTitle is not present.
|
|
28
|
+
* If neither aria-label nor aria-labelledby is provided, a fallback label is applied.
|
|
29
|
+
*/
|
|
30
|
+
"aria-label"?: string;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const popoverContent = cv({
|
|
34
|
+
base: [
|
|
35
|
+
"starwind-popover-content",
|
|
36
|
+
"bg-popover text-popover-foreground z-50 flex w-72 flex-col gap-2xl overflow-x-hidden overflow-y-auto rounded-lg b p-2xl shadow-md",
|
|
37
|
+
"data-[state=open]:animate-in fade-in zoom-in-95",
|
|
38
|
+
"data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out zoom-out-95",
|
|
39
|
+
"fixed isolate will-change-transform",
|
|
40
|
+
],
|
|
41
|
+
variants: {
|
|
42
|
+
side: {
|
|
43
|
+
bottom: "slide-in-from-top-2 slide-out-to-top-2",
|
|
44
|
+
top: "slide-in-from-bottom-2 slide-out-to-bottom-2",
|
|
45
|
+
right: "slide-in-from-left-2 slide-out-to-left-2",
|
|
46
|
+
left: "slide-in-from-right-2 slide-out-to-right-2",
|
|
47
|
+
},
|
|
48
|
+
align: {
|
|
49
|
+
start: "",
|
|
50
|
+
center: "",
|
|
51
|
+
end: "",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
compoundVariants: [
|
|
55
|
+
{
|
|
56
|
+
side: ["top", "bottom"],
|
|
57
|
+
align: "start",
|
|
58
|
+
className: "slide-in-from-left-1 slide-out-to-left-1",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
side: ["top", "bottom"],
|
|
62
|
+
align: "end",
|
|
63
|
+
className: "slide-in-from-right-1 slide-out-to-right-1",
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
defaultVariants: {
|
|
67
|
+
side: "bottom",
|
|
68
|
+
align: "center",
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const {
|
|
73
|
+
class: className,
|
|
74
|
+
side = "bottom",
|
|
75
|
+
align = "center",
|
|
76
|
+
sideOffset = 4,
|
|
77
|
+
animationDuration = 150,
|
|
78
|
+
"aria-label": ariaLabel,
|
|
79
|
+
"aria-labelledby": ariaLabelledBy,
|
|
80
|
+
...rest
|
|
81
|
+
} = Astro.props;
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
<div
|
|
85
|
+
class:list={[popoverContent({ side, align }), className]}
|
|
86
|
+
data-side={side}
|
|
87
|
+
data-align={align}
|
|
88
|
+
data-side-offset={sideOffset}
|
|
89
|
+
data-state="closed"
|
|
90
|
+
role="dialog"
|
|
91
|
+
aria-label={ariaLabel ?? (ariaLabelledBy ? undefined : "Popover dialog")}
|
|
92
|
+
aria-labelledby={ariaLabelledBy}
|
|
93
|
+
tabindex="-1"
|
|
94
|
+
style={{
|
|
95
|
+
display: "none",
|
|
96
|
+
animationDuration: `${animationDuration}ms`,
|
|
97
|
+
}}
|
|
98
|
+
{...rest}
|
|
99
|
+
data-slot="popover-content"
|
|
100
|
+
>
|
|
101
|
+
<slot />
|
|
102
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"p">;
|
|
6
|
+
|
|
7
|
+
export const popoverDescription = cv({ base: "text-muted-foreground" });
|
|
8
|
+
|
|
9
|
+
const { class: className, ...rest } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<p class:list={[popoverDescription(), className]} {...rest} data-slot="popover-description">
|
|
13
|
+
<slot />
|
|
14
|
+
</p>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"div">;
|
|
6
|
+
|
|
7
|
+
export const popoverHeader = cv({ base: "flex flex-col gap-2xs" });
|
|
8
|
+
|
|
9
|
+
const { class: className, ...rest } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<div class:list={[popoverHeader(), className]} {...rest} data-slot="popover-header">
|
|
13
|
+
<slot />
|
|
14
|
+
</div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"h3">;
|
|
6
|
+
|
|
7
|
+
export const popoverTitle = cv({ base: "font-medium" });
|
|
8
|
+
|
|
9
|
+
const { class: className, ...rest } = Astro.props;
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
<h3 class:list={[popoverTitle(), className]} {...rest} data-slot="popover-title">
|
|
13
|
+
<slot />
|
|
14
|
+
</h3>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = Omit<HTMLAttributes<"button">, "role" | "type"> & {
|
|
6
|
+
/**
|
|
7
|
+
* When true, the component will render its child element with a simple wrapper instead of a button component
|
|
8
|
+
*/
|
|
9
|
+
asChild?: boolean;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const popoverTrigger = cv({
|
|
13
|
+
base: [
|
|
14
|
+
"starwind-popover-trigger",
|
|
15
|
+
"inline-flex items-center justify-center",
|
|
16
|
+
"focus-visible:ring-outline/50 transition-[color,box-shadow] outline-none focus-visible:ring-3",
|
|
17
|
+
"disabled:pointer-events-none",
|
|
18
|
+
],
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const { class: className, asChild = false, ...rest } = Astro.props;
|
|
22
|
+
|
|
23
|
+
let hasChildren = false;
|
|
24
|
+
if (Astro.slots.has("default")) {
|
|
25
|
+
hasChildren = true;
|
|
26
|
+
}
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
{
|
|
30
|
+
asChild && hasChildren ? (
|
|
31
|
+
<div
|
|
32
|
+
class:list={["starwind-popover-trigger", className]}
|
|
33
|
+
data-slot="popover-trigger"
|
|
34
|
+
data-as-child
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
</div>
|
|
38
|
+
) : (
|
|
39
|
+
<button
|
|
40
|
+
class:list={[popoverTrigger(), className]}
|
|
41
|
+
type="button"
|
|
42
|
+
aria-haspopup="dialog"
|
|
43
|
+
aria-expanded="false"
|
|
44
|
+
data-state="closed"
|
|
45
|
+
{...rest}
|
|
46
|
+
data-slot="popover-trigger"
|
|
47
|
+
>
|
|
48
|
+
<slot />
|
|
49
|
+
</button>
|
|
50
|
+
)
|
|
51
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"div"> & {
|
|
6
|
+
/**
|
|
7
|
+
* Current value of the progress bar (omit for indeterminate state)
|
|
8
|
+
*/
|
|
9
|
+
value?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Maximum value for the progress bar (default: 100)
|
|
12
|
+
*/
|
|
13
|
+
max?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Color variant for the progress indicator (default: default)
|
|
16
|
+
*/
|
|
17
|
+
variant?: "default" | "primary" | "secondary" | "info" | "success" | "warning" | "error";
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const { class: className, value, max = 100, variant = "default", ...rest } = Astro.props;
|
|
21
|
+
|
|
22
|
+
const isIndeterminate = value == null;
|
|
23
|
+
const valuePercent = isIndeterminate ? undefined : Math.round((value / max) * 100);
|
|
24
|
+
const valueText = isIndeterminate ? undefined : `${valuePercent}%`;
|
|
25
|
+
|
|
26
|
+
export const progress = cv({
|
|
27
|
+
base: ["starwind-progress-bar", "bg-muted h-5xs w-full overflow-hidden rounded-full"],
|
|
28
|
+
variants: {
|
|
29
|
+
variant: {
|
|
30
|
+
indeterminate: "relative",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
export const progressIndicator = cv({
|
|
36
|
+
base: ["starwind-progress-indicator", "h-full w-full flex-1 transition-transform"],
|
|
37
|
+
variants: {
|
|
38
|
+
variant: {
|
|
39
|
+
indeterminate: "absolute inset-y-0 start-0 w-3/4",
|
|
40
|
+
},
|
|
41
|
+
color: {
|
|
42
|
+
primary: "bg-primary",
|
|
43
|
+
secondary: "bg-secondary",
|
|
44
|
+
default: "bg-foreground",
|
|
45
|
+
info: "bg-info",
|
|
46
|
+
success: "bg-success",
|
|
47
|
+
warning: "bg-warning",
|
|
48
|
+
error: "bg-error",
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
defaultVariants: {
|
|
52
|
+
color: "primary",
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const indicator = progressIndicator;
|
|
57
|
+
|
|
58
|
+
const progressClasses = progress({
|
|
59
|
+
variant: isIndeterminate ? "indeterminate" : undefined,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const indicatorClasses = indicator({
|
|
63
|
+
variant: isIndeterminate ? "indeterminate" : undefined,
|
|
64
|
+
color: variant,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const indicatorStyle = isIndeterminate
|
|
68
|
+
? ""
|
|
69
|
+
: `transform: translateX(-${100 - (valuePercent ?? 0)}%);`;
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
<div
|
|
73
|
+
role="progressbar"
|
|
74
|
+
aria-valuemin={0}
|
|
75
|
+
aria-valuemax={max}
|
|
76
|
+
aria-valuenow={isIndeterminate ? undefined : value}
|
|
77
|
+
aria-valuetext={valueText}
|
|
78
|
+
class:list={[progressClasses, className]}
|
|
79
|
+
data-value={value}
|
|
80
|
+
data-max={max}
|
|
81
|
+
data-indeterminate={isIndeterminate}
|
|
82
|
+
{...rest}
|
|
83
|
+
data-slot="progress"
|
|
84
|
+
>
|
|
85
|
+
<div class:list={[indicatorClasses]} style={indicatorStyle}></div>
|
|
86
|
+
</div>
|
|
87
|
+
|
|
88
|
+
<script>
|
|
89
|
+
class ProgressHandler {
|
|
90
|
+
private progressElement: HTMLElement;
|
|
91
|
+
private observer!: MutationObserver;
|
|
92
|
+
|
|
93
|
+
constructor(progressElement: HTMLElement) {
|
|
94
|
+
this.progressElement = progressElement;
|
|
95
|
+
this.setupMutationObserver();
|
|
96
|
+
this.updateProgress(); // Initial update
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
private setupMutationObserver(): void {
|
|
100
|
+
// Create a MutationObserver to watch for data-value attribute changes
|
|
101
|
+
this.observer = new MutationObserver((mutations) => {
|
|
102
|
+
mutations.forEach((mutation) => {
|
|
103
|
+
if (mutation.attributeName === "data-value" || mutation.attributeName === "data-max") {
|
|
104
|
+
this.updateProgress();
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Start observing
|
|
110
|
+
this.observer.observe(this.progressElement, { attributes: true });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
private updateProgress(): void {
|
|
114
|
+
const value = Number(this.progressElement.getAttribute("data-value"));
|
|
115
|
+
const max = Number(this.progressElement.getAttribute("data-max") || 100);
|
|
116
|
+
const isIndeterminate = this.progressElement.hasAttribute("data-indeterminate")
|
|
117
|
+
? this.progressElement.getAttribute("data-indeterminate") === "true"
|
|
118
|
+
: value == null;
|
|
119
|
+
|
|
120
|
+
// Update ARIA attributes
|
|
121
|
+
if (!isIndeterminate) {
|
|
122
|
+
const valuePercent = Math.round((value / max) * 100);
|
|
123
|
+
this.progressElement.setAttribute("aria-valuenow", String(value));
|
|
124
|
+
this.progressElement.setAttribute("aria-valuetext", `${valuePercent}%`);
|
|
125
|
+
|
|
126
|
+
// Update indicator position
|
|
127
|
+
const indicator = this.progressElement.querySelector("div");
|
|
128
|
+
if (indicator) {
|
|
129
|
+
indicator.style.transform = `translateX(-${100 - valuePercent}%)`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Clean up method to disconnect observer
|
|
135
|
+
public destroy(): void {
|
|
136
|
+
this.observer.disconnect();
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Store instances in a WeakMap to avoid memory leaks
|
|
141
|
+
const progressInstances = new WeakMap<HTMLElement, ProgressHandler>();
|
|
142
|
+
|
|
143
|
+
const setupProgressBars = () => {
|
|
144
|
+
document.querySelectorAll<HTMLElement>(".starwind-progress-bar").forEach((progressElement) => {
|
|
145
|
+
if (!progressInstances.has(progressElement)) {
|
|
146
|
+
progressInstances.set(progressElement, new ProgressHandler(progressElement));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
setupProgressBars();
|
|
152
|
+
document.addEventListener("astro:after-swap", setupProgressBars);
|
|
153
|
+
document.addEventListener("starwind:init", setupProgressBars);
|
|
154
|
+
</script>
|