@rimelight/ui 0.0.5 → 0.0.7
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 -21
- package/package.json +22 -14
- package/src/components/BlogPost.astro +195 -0
- package/src/components/DynamicShowcase.astro +681 -0
- package/src/components/ExtendedCarousel.astro +107 -0
- package/src/components/FormattedDate.astro +6 -2
- package/src/components/Head.astro +153 -0
- package/src/components/ProjectPost.astro +197 -0
- package/src/components/RLHead.astro +3 -0
- package/src/components/ThemeToggle.astro +30 -42
- package/src/components/astro/RLAButton.astro +32 -42
- package/src/components/astro/RLAHeader.astro +75 -0
- package/src/components/nuxt/index.ts +1 -0
- package/src/components/vue/RLVButton.vue +50 -37
- package/src/components/vue/RLVHeader.vue +78 -0
- package/src/composables/index.ts +1 -1
- package/src/composables/{useComponentUI.ts → useUi.ts} +3 -3
- package/src/config/index.ts +0 -2
- package/src/config/site.config.ts +1 -1
- package/src/env.d.ts +13 -16
- package/src/integrations/ui.ts +106 -81
- package/src/integrations/vue-entrypoint.ts +6 -0
- package/src/middleware/sri.ts +2 -2
- package/src/styles/index.css +2 -0
- package/src/themes/button.theme.ts +350 -34
- package/src/themes/header.theme.ts +33 -0
- package/src/themes/index.ts +3 -1
- package/src/utils/index.ts +1 -2
- package/i18n-data.json +0 -186
- package/src/components/MissingTranslationBanner.astro +0 -39
- package/src/components/accordion/Accordion.astro +0 -257
- package/src/components/accordion/AccordionContent.astro +0 -34
- package/src/components/accordion/AccordionItem.astro +0 -29
- package/src/components/accordion/AccordionTrigger.astro +0 -33
- package/src/components/alert/Alert.astro +0 -34
- package/src/components/alert/AlertDescription.astro +0 -15
- package/src/components/alert/AlertTitle.astro +0 -17
- package/src/components/alert-dialog/AlertDialog.astro +0 -275
- package/src/components/alert-dialog/AlertDialogAction.astro +0 -46
- package/src/components/alert-dialog/AlertDialogCancel.astro +0 -46
- package/src/components/alert-dialog/AlertDialogContent.astro +0 -52
- package/src/components/alert-dialog/AlertDialogDescription.astro +0 -18
- package/src/components/alert-dialog/AlertDialogFooter.astro +0 -16
- package/src/components/alert-dialog/AlertDialogHeader.astro +0 -14
- package/src/components/alert-dialog/AlertDialogTitle.astro +0 -20
- package/src/components/alert-dialog/AlertDialogTrigger.astro +0 -47
- package/src/components/aspect-ratio/AspectRatio.astro +0 -32
- package/src/components/avatar/Avatar.astro +0 -29
- package/src/components/avatar/AvatarFallback.astro +0 -18
- package/src/components/avatar/AvatarImage.astro +0 -66
- package/src/components/badge/Badge.astro +0 -57
- package/src/components/breadcrumb/Breadcrumb.astro +0 -12
- package/src/components/breadcrumb/BreadcrumbEllipsis.astro +0 -29
- package/src/components/breadcrumb/BreadcrumbItem.astro +0 -15
- package/src/components/breadcrumb/BreadcrumbLink.astro +0 -24
- package/src/components/breadcrumb/BreadcrumbList.astro +0 -17
- package/src/components/breadcrumb/BreadcrumbPage.astro +0 -22
- package/src/components/breadcrumb/BreadcrumbSeparator.astro +0 -24
- package/src/components/button/Button.astro +0 -58
- package/src/components/button-group/ButtonGroup.astro +0 -64
- package/src/components/button-group/ButtonGroupSeparator.astro +0 -20
- package/src/components/button-group/ButtonGroupText.astro +0 -19
- package/src/components/card/Card.astro +0 -36
- package/src/components/card/CardAction.astro +0 -16
- package/src/components/card/CardContent.astro +0 -16
- package/src/components/card/CardDescription.astro +0 -16
- package/src/components/card/CardFooter.astro +0 -16
- package/src/components/card/CardHeader.astro +0 -19
- package/src/components/card/CardTitle.astro +0 -16
- package/src/components/carousel/Carousel.astro +0 -55
- package/src/components/carousel/CarouselContent.astro +0 -26
- package/src/components/carousel/CarouselItem.astro +0 -26
- package/src/components/carousel/CarouselNext.astro +0 -39
- package/src/components/carousel/CarouselPrevious.astro +0 -41
- package/src/components/carousel/carousel-script.ts +0 -188
- package/src/components/carousel/index.ts +0 -1
- package/src/components/checkbox/Checkbox.astro +0 -133
- package/src/components/collapsible/Collapsible.astro +0 -161
- package/src/components/collapsible/CollapsibleContent.astro +0 -22
- package/src/components/collapsible/CollapsibleTrigger.astro +0 -44
- package/src/components/dialog/Dialog.astro +0 -389
- package/src/components/dialog/DialogClose.astro +0 -35
- package/src/components/dialog/DialogContent.astro +0 -78
- package/src/components/dialog/DialogDescription.astro +0 -14
- package/src/components/dialog/DialogFooter.astro +0 -14
- package/src/components/dialog/DialogHeader.astro +0 -14
- package/src/components/dialog/DialogTitle.astro +0 -18
- package/src/components/dialog/DialogTrigger.astro +0 -47
- package/src/components/dropdown/Dropdown.astro +0 -604
- package/src/components/dropdown/DropdownContent.astro +0 -118
- package/src/components/dropdown/DropdownItem.astro +0 -48
- package/src/components/dropdown/DropdownLabel.astro +0 -29
- package/src/components/dropdown/DropdownSeparator.astro +0 -21
- package/src/components/dropdown/DropdownShortcut.astro +0 -17
- package/src/components/dropdown/DropdownSub.astro +0 -15
- package/src/components/dropdown/DropdownSubContent.astro +0 -39
- package/src/components/dropdown/DropdownSubTrigger.astro +0 -34
- package/src/components/dropdown/DropdownTrigger.astro +0 -52
- package/src/components/dropzone/Dropzone.astro +0 -236
- package/src/components/dropzone/DropzoneFilesList.astro +0 -26
- package/src/components/dropzone/DropzoneLoadingIndicator.astro +0 -10
- package/src/components/dropzone/DropzoneUploadIndicator.astro +0 -10
- package/src/components/embeds/YoutubeEmbed.astro +0 -94
- package/src/components/hero/Hero.astro +0 -166
- package/src/components/icons/Flag.astro +0 -62
- package/src/components/image/ExtendedImage.astro +0 -46
- package/src/components/image/Image.astro +0 -25
- package/src/components/input/Input.astro +0 -27
- package/src/components/input-group/InputGroup.astro +0 -28
- package/src/components/input-group/InputGroupAddon.astro +0 -76
- package/src/components/input-group/InputGroupButton.astro +0 -36
- package/src/components/input-group/InputGroupInput.astro +0 -18
- package/src/components/input-group/InputGroupText.astro +0 -17
- package/src/components/input-group/InputGroupTextarea.astro +0 -22
- package/src/components/input-otp/InputOtp.astro +0 -352
- package/src/components/input-otp/InputOtpGroup.astro +0 -16
- package/src/components/input-otp/InputOtpSeparator.astro +0 -25
- package/src/components/input-otp/InputOtpSlot.astro +0 -50
- package/src/components/input-otp/InputOtpTypes.ts +0 -6
- package/src/components/item/Item.astro +0 -52
- package/src/components/item/ItemActions.astro +0 -16
- package/src/components/item/ItemContent.astro +0 -16
- package/src/components/item/ItemDescription.astro +0 -19
- package/src/components/item/ItemFooter.astro +0 -16
- package/src/components/item/ItemGroup.astro +0 -16
- package/src/components/item/ItemHeader.astro +0 -16
- package/src/components/item/ItemMedia.astro +0 -40
- package/src/components/item/ItemSeparator.astro +0 -23
- package/src/components/item/ItemTitle.astro +0 -16
- package/src/components/kbd/Kbd.astro +0 -21
- package/src/components/kbd/KbdGroup.astro +0 -16
- package/src/components/label/Label.astro +0 -24
- package/src/components/marquee/Marquee.astro +0 -73
- package/src/components/native-select/NativeSelect.astro +0 -68
- package/src/components/native-select/NativeSelectOptGroup.astro +0 -15
- package/src/components/native-select/NativeSelectOption.astro +0 -15
- package/src/components/pagination/Pagination.astro +0 -20
- package/src/components/pagination/PaginationContent.astro +0 -16
- package/src/components/pagination/PaginationEllipsis.astro +0 -37
- package/src/components/pagination/PaginationItem.astro +0 -16
- package/src/components/pagination/PaginationLink.astro +0 -27
- package/src/components/pagination/PaginationNext.astro +0 -33
- package/src/components/pagination/PaginationPrevious.astro +0 -33
- package/src/components/popover/Popover.astro +0 -717
- package/src/components/popover/PopoverContent.astro +0 -102
- package/src/components/popover/PopoverDescription.astro +0 -14
- package/src/components/popover/PopoverHeader.astro +0 -14
- package/src/components/popover/PopoverTitle.astro +0 -14
- package/src/components/popover/PopoverTrigger.astro +0 -51
- package/src/components/progress/Progress.astro +0 -154
- package/src/components/prose/Prose.astro +0 -619
- package/src/components/radio-group/RadioGroup.astro +0 -162
- package/src/components/radio-group/RadioGroupItem.astro +0 -133
- package/src/components/radio-group/RadioGroupTypes.ts +0 -6
- package/src/components/section/Section.astro +0 -167
- package/src/components/select/Select.astro +0 -752
- package/src/components/select/SelectContent.astro +0 -94
- package/src/components/select/SelectGroup.astro +0 -9
- package/src/components/select/SelectItem.astro +0 -51
- package/src/components/select/SelectLabel.astro +0 -14
- package/src/components/select/SelectSearch.astro +0 -49
- package/src/components/select/SelectSeparator.astro +0 -12
- package/src/components/select/SelectTrigger.astro +0 -56
- package/src/components/select/SelectTypes.ts +0 -13
- package/src/components/select/SelectValue.astro +0 -19
- package/src/components/separator/Separator.astro +0 -36
- package/src/components/sheet/Sheet.astro +0 -15
- package/src/components/sheet/SheetClose.astro +0 -15
- package/src/components/sheet/SheetContent.astro +0 -89
- package/src/components/sheet/SheetDescription.astro +0 -16
- package/src/components/sheet/SheetFooter.astro +0 -16
- package/src/components/sheet/SheetHeader.astro +0 -16
- package/src/components/sheet/SheetTitle.astro +0 -16
- package/src/components/sheet/SheetTrigger.astro +0 -15
- package/src/components/sidebar/Sidebar.astro +0 -231
- package/src/components/sidebar/SidebarContent.astro +0 -25
- package/src/components/sidebar/SidebarFooter.astro +0 -22
- package/src/components/sidebar/SidebarGroup.astro +0 -22
- package/src/components/sidebar/SidebarGroupContent.astro +0 -22
- package/src/components/sidebar/SidebarGroupLabel.astro +0 -53
- package/src/components/sidebar/SidebarHeader.astro +0 -22
- package/src/components/sidebar/SidebarInput.astro +0 -24
- package/src/components/sidebar/SidebarInset.astro +0 -22
- package/src/components/sidebar/SidebarMenu.astro +0 -22
- package/src/components/sidebar/SidebarMenuAction.astro +0 -63
- package/src/components/sidebar/SidebarMenuBadge.astro +0 -31
- package/src/components/sidebar/SidebarMenuButton.astro +0 -124
- package/src/components/sidebar/SidebarMenuItem.astro +0 -22
- package/src/components/sidebar/SidebarMenuSkeleton.astro +0 -43
- package/src/components/sidebar/SidebarMenuSub.astro +0 -25
- package/src/components/sidebar/SidebarMenuSubButton.astro +0 -52
- package/src/components/sidebar/SidebarMenuSubItem.astro +0 -17
- package/src/components/sidebar/SidebarProvider.astro +0 -215
- package/src/components/sidebar/SidebarRail.astro +0 -72
- package/src/components/sidebar/SidebarSeparator.astro +0 -25
- package/src/components/sidebar/SidebarTrigger.astro +0 -69
- package/src/components/skeleton/Skeleton.astro +0 -14
- package/src/components/slider/Slider.astro +0 -425
- package/src/components/spinner/Spinner.astro +0 -23
- package/src/components/switch/Switch.astro +0 -192
- package/src/components/switch/SwitchTypes.ts +0 -6
- package/src/components/table/Table.astro +0 -20
- package/src/components/table/TableBody.astro +0 -18
- package/src/components/table/TableCaption.astro +0 -18
- package/src/components/table/TableCell.astro +0 -18
- package/src/components/table/TableFoot.astro +0 -18
- package/src/components/table/TableHead.astro +0 -18
- package/src/components/table/TableHeader.astro +0 -18
- package/src/components/table/TableRow.astro +0 -17
- package/src/components/tabs/Tabs.astro +0 -270
- package/src/components/tabs/TabsContent.astro +0 -28
- package/src/components/tabs/TabsList.astro +0 -23
- package/src/components/tabs/TabsTrigger.astro +0 -34
- package/src/components/textarea/Textarea.astro +0 -31
- package/src/components/toast/ToastDescription.astro +0 -22
- package/src/components/toast/ToastItem.astro +0 -56
- package/src/components/toast/ToastTemplate.astro +0 -27
- package/src/components/toast/ToastTitle.astro +0 -59
- package/src/components/toast/Toaster.astro +0 -981
- package/src/components/toast/index.ts +0 -1
- package/src/components/toast/toast-manager.ts +0 -234
- package/src/components/toggle/Toggle.astro +0 -174
- package/src/components/toggle/ToggleTypes.ts +0 -14
- package/src/components/tooltip/Tooltip.astro +0 -422
- package/src/components/tooltip/TooltipContent.astro +0 -83
- package/src/components/tooltip/TooltipTrigger.astro +0 -13
- package/src/components/video/Video.astro +0 -121
- package/src/config/cookies.ts +0 -5
- package/src/config/links.ts +0 -4
- package/src/domain/cms/index.ts +0 -1
- package/src/domain/cms/types.ts +0 -20
- package/src/domain/i18n/constants.ts +0 -21
- package/src/domain/i18n/cookie-storage.ts +0 -13
- package/src/domain/i18n/country-to-locale-map.ts +0 -67
- package/src/domain/i18n/fallbacks.generated.ts +0 -230
- package/src/domain/i18n/fetcher.ts +0 -278
- package/src/domain/i18n/flags.ts +0 -16
- package/src/domain/i18n/format.ts +0 -90
- package/src/domain/i18n/index.ts +0 -10
- package/src/domain/i18n/middleware/i18n.ts +0 -161
- package/src/domain/i18n/resolve-locale.ts +0 -55
- package/src/domain/i18n/runtime-constants.ts +0 -14
- package/src/domain/i18n/schema.ts +0 -29
- package/src/domain/index.ts +0 -4
- package/src/domain/seo/constants.ts +0 -6
- package/src/domain/seo/index.ts +0 -3
- package/src/domain/seo/services/index.ts +0 -3
- package/src/domain/seo/services/llms.ts +0 -56
- package/src/domain/seo/services/robots.ts +0 -12
- package/src/domain/seo/services/sitemap.ts +0 -56
- package/src/domain/seo/utils.ts +0 -36
- package/src/domain/theme/constants.ts +0 -6
- package/src/domain/theme/index.ts +0 -2
- package/src/domain/theme/schema.ts +0 -10
- package/src/i18n.generated.d.ts +0 -202
- package/src/lib/component-preview.ts +0 -73
- package/src/lib/index.ts +0 -6
- package/src/lib/remark/remark-modified-time.ts +0 -13
- package/src/lib/showcase-preview-elements.ts +0 -408
- package/src/lib/showcase-renderer.ts +0 -218
- package/src/lib/showcase-utils.ts +0 -189
- package/src/lib/turnstile.ts +0 -35
- package/src/lib/utils/starwind/positioning.ts +0 -318
- package/src/locales/de/blog.json +0 -9
- package/src/locales/de/common.json +0 -19
- package/src/locales/de/errors.json +0 -6
- package/src/locales/de/home.json +0 -20
- package/src/locales/de/messages.json +0 -8
- package/src/locales/de/nav.json +0 -13
- package/src/locales/de/projects.json +0 -9
- package/src/locales/de/services.json +0 -43
- package/src/locales/en/blog.json +0 -9
- package/src/locales/en/chat.json +0 -29
- package/src/locales/en/common.json +0 -19
- package/src/locales/en/cookie_notice.json +0 -11
- package/src/locales/en/editor.json +0 -24
- package/src/locales/en/errors.json +0 -6
- package/src/locales/en/home.json +0 -20
- package/src/locales/en/messages.json +0 -8
- package/src/locales/en/nav.json +0 -13
- package/src/locales/en/projects.json +0 -9
- package/src/locales/en/services.json +0 -43
- package/src/locales/es/blog.json +0 -9
- package/src/locales/es/common.json +0 -19
- package/src/locales/es/errors.json +0 -6
- package/src/locales/es/home.json +0 -20
- package/src/locales/es/messages.json +0 -8
- package/src/locales/es/nav.json +0 -13
- package/src/locales/es/projects.json +0 -9
- package/src/locales/es/services.json +0 -43
- package/src/locales/ja/blog.json +0 -9
- package/src/locales/ja/common.json +0 -19
- package/src/locales/ja/errors.json +0 -6
- package/src/locales/ja/home.json +0 -20
- package/src/locales/ja/messages.json +0 -8
- package/src/locales/ja/nav.json +0 -13
- package/src/locales/ja/projects.json +0 -9
- package/src/locales/ja/services.json +0 -43
- package/src/locales/pt/blog.json +0 -9
- package/src/locales/pt/chat.json +0 -29
- package/src/locales/pt/common.json +0 -19
- package/src/locales/pt/cookie_notice.json +0 -11
- package/src/locales/pt/editor.json +0 -24
- package/src/locales/pt/errors.json +0 -6
- package/src/locales/pt/home.json +0 -20
- package/src/locales/pt/messages.json +0 -8
- package/src/locales/pt/nav.json +0 -13
- package/src/locales/pt/projects.json +0 -9
- package/src/locales/pt/services.json +0 -43
- package/src/utils/server/cookies.ts +0 -98
- package/src/utils/server/index.ts +0 -1
- package/src/utils/shared/deep-merge.ts +0 -36
- package/src/utils/shared/index.ts +0 -3
- package/src/utils/shared/parse-boolean.ts +0 -14
- /package/src/utils/{shared/embed.ts → embed.ts} +0 -0
|
@@ -1,422 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
export interface TooltipProps extends HTMLAttributes<"div"> {
|
|
6
|
-
/**
|
|
7
|
-
* Time in milliseconds to wait before showing the tooltip
|
|
8
|
-
*/
|
|
9
|
-
openDelay?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Time in milliseconds to wait before hiding the tooltip
|
|
12
|
-
*/
|
|
13
|
-
closeDelay?: number;
|
|
14
|
-
/**
|
|
15
|
-
* When true, prevents the tooltip from staying open when hovering over its content
|
|
16
|
-
*/
|
|
17
|
-
disableHoverableContent?: boolean;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type Props = TooltipProps;
|
|
21
|
-
|
|
22
|
-
export const tooltip = cv({ base: "starwind-tooltip relative i-block" });
|
|
23
|
-
|
|
24
|
-
const {
|
|
25
|
-
openDelay = 200,
|
|
26
|
-
closeDelay = 200,
|
|
27
|
-
disableHoverableContent = false,
|
|
28
|
-
class: className,
|
|
29
|
-
} = Astro.props;
|
|
30
|
-
---
|
|
31
|
-
|
|
32
|
-
<div
|
|
33
|
-
class:list={[tooltip(), className]}
|
|
34
|
-
data-state="closed"
|
|
35
|
-
data-open-delay={openDelay}
|
|
36
|
-
data-close-delay={closeDelay}
|
|
37
|
-
{...!disableHoverableContent && { "data-content-hoverable": "" }}
|
|
38
|
-
data-slot="tooltip"
|
|
39
|
-
>
|
|
40
|
-
<slot />
|
|
41
|
-
</div>
|
|
42
|
-
|
|
43
|
-
<script>
|
|
44
|
-
import {
|
|
45
|
-
type FloatingAlign,
|
|
46
|
-
type FloatingSide,
|
|
47
|
-
getTransformOrigin,
|
|
48
|
-
resolvePlacement,
|
|
49
|
-
} from "../../lib/utils/starwind/positioning";
|
|
50
|
-
|
|
51
|
-
class TooltipHandler {
|
|
52
|
-
private tooltip: HTMLElement;
|
|
53
|
-
private trigger: HTMLElement | null;
|
|
54
|
-
private content: HTMLElement | null;
|
|
55
|
-
private openTimerRef: number | null = null;
|
|
56
|
-
private closeTimerRef: number | null = null;
|
|
57
|
-
private hideAnimationTimerRef: number | null = null;
|
|
58
|
-
private contentId: string;
|
|
59
|
-
private animationDuration = 150;
|
|
60
|
-
private side: FloatingSide = "top";
|
|
61
|
-
private align: FloatingAlign = "center";
|
|
62
|
-
private sideOffset = 8;
|
|
63
|
-
private avoidCollisions = true;
|
|
64
|
-
private isOpen = false;
|
|
65
|
-
private contentPlaceholder: Comment | null = null;
|
|
66
|
-
private cleanupAutoUpdate: (() => void) | null = null;
|
|
67
|
-
private abortController: AbortController;
|
|
68
|
-
|
|
69
|
-
constructor(tooltip: HTMLElement, idx: number) {
|
|
70
|
-
this.contentId = `starwind-tooltip${idx}`;
|
|
71
|
-
this.tooltip = tooltip;
|
|
72
|
-
this.abortController = new AbortController();
|
|
73
|
-
this.content = tooltip.querySelector(".starwind-tooltip-content");
|
|
74
|
-
|
|
75
|
-
// if tooltip.firstElementChild is this.content, then get the next element
|
|
76
|
-
this.trigger = tooltip.firstElementChild as HTMLElement;
|
|
77
|
-
if (this.trigger === this.content) {
|
|
78
|
-
this.trigger = this.trigger.nextElementSibling as HTMLElement;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (!this.trigger || !this.content) return;
|
|
82
|
-
|
|
83
|
-
this.trigger.classList.add("starwind-tooltip-trigger");
|
|
84
|
-
|
|
85
|
-
// animationDuration is set with inline styles through passed prop to TooltipContent
|
|
86
|
-
const animationDurationString = this.content.style.animationDuration;
|
|
87
|
-
if (animationDurationString.endsWith("ms")) {
|
|
88
|
-
this.animationDuration = parseFloat(animationDurationString);
|
|
89
|
-
} else if (animationDurationString.endsWith("s")) {
|
|
90
|
-
// using something like @playform/compress might optimize to use "s" instead of "ms"
|
|
91
|
-
this.animationDuration = parseFloat(animationDurationString) * 1000;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const contentSide = this.content.getAttribute("data-side");
|
|
95
|
-
if (
|
|
96
|
-
contentSide === "top" ||
|
|
97
|
-
contentSide === "bottom" ||
|
|
98
|
-
contentSide === "left" ||
|
|
99
|
-
contentSide === "right"
|
|
100
|
-
) {
|
|
101
|
-
this.side = contentSide;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const contentAlign = this.content.getAttribute("data-align");
|
|
105
|
-
if (contentAlign === "start" || contentAlign === "center" || contentAlign === "end") {
|
|
106
|
-
this.align = contentAlign;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
const contentSideOffset = parseFloat(this.content.getAttribute("data-side-offset") || "8");
|
|
110
|
-
if (Number.isFinite(contentSideOffset)) {
|
|
111
|
-
this.sideOffset = contentSideOffset;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
this.avoidCollisions = this.content.hasAttribute("data-avoid-collisions");
|
|
115
|
-
this.isOpen = this.tooltip.getAttribute("data-state") === "open";
|
|
116
|
-
|
|
117
|
-
this.init();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
private init() {
|
|
121
|
-
this.setupAccessibility();
|
|
122
|
-
this.setupEvents();
|
|
123
|
-
this.setInitialState();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private setupAccessibility() {
|
|
127
|
-
if (!this.trigger || !this.content) return;
|
|
128
|
-
this.trigger.setAttribute("aria-describedby", this.contentId);
|
|
129
|
-
this.content.id = this.contentId;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
private setInitialState() {
|
|
133
|
-
if (!this.content || !this.trigger) return;
|
|
134
|
-
|
|
135
|
-
if (this.isOpen) {
|
|
136
|
-
this.tooltip.setAttribute("data-state", "open");
|
|
137
|
-
this.trigger.setAttribute("data-state", "open");
|
|
138
|
-
this.content.setAttribute("data-state", "open");
|
|
139
|
-
this.content.classList.remove("hidden");
|
|
140
|
-
this.portalContent();
|
|
141
|
-
this.positionTooltip();
|
|
142
|
-
requestAnimationFrame(() => this.positionTooltip());
|
|
143
|
-
} else {
|
|
144
|
-
this.tooltip.setAttribute("data-state", "closed");
|
|
145
|
-
this.trigger.setAttribute("data-state", "closed");
|
|
146
|
-
this.content.setAttribute("data-state", "closed");
|
|
147
|
-
this.content.classList.add("hidden");
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
private setupEvents() {
|
|
152
|
-
if (!this.trigger || !this.content) return;
|
|
153
|
-
|
|
154
|
-
// Trigger events
|
|
155
|
-
this.trigger.addEventListener("mouseenter", () => this.show(), {
|
|
156
|
-
signal: this.abortController.signal,
|
|
157
|
-
});
|
|
158
|
-
this.trigger.addEventListener("mouseleave", () => this.hide(), {
|
|
159
|
-
signal: this.abortController.signal,
|
|
160
|
-
});
|
|
161
|
-
this.trigger.addEventListener("focus", () => this.show(true), {
|
|
162
|
-
signal: this.abortController.signal,
|
|
163
|
-
});
|
|
164
|
-
this.trigger.addEventListener("blur", () => this.hide(true), {
|
|
165
|
-
signal: this.abortController.signal,
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
// Content events
|
|
169
|
-
if (this.tooltip.hasAttribute("data-content-hoverable")) {
|
|
170
|
-
this.content.addEventListener("mouseenter", () => this.show(), {
|
|
171
|
-
signal: this.abortController.signal,
|
|
172
|
-
});
|
|
173
|
-
this.content.addEventListener("mouseleave", () => this.hide(), {
|
|
174
|
-
signal: this.abortController.signal,
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// Document events
|
|
179
|
-
document.addEventListener(
|
|
180
|
-
"keydown",
|
|
181
|
-
(e) => {
|
|
182
|
-
if (e.key === "Escape" && this.isOpen) {
|
|
183
|
-
this.hide(true);
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
{ signal: this.abortController.signal },
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
document.addEventListener(
|
|
190
|
-
"pointerdown",
|
|
191
|
-
(e) => {
|
|
192
|
-
if (
|
|
193
|
-
this.isOpen &&
|
|
194
|
-
!this.tooltip.contains(e.target as Node) &&
|
|
195
|
-
!this.content?.contains(e.target as Node)
|
|
196
|
-
) {
|
|
197
|
-
this.hide(true);
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
{ signal: this.abortController.signal },
|
|
201
|
-
);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
private portalContent() {
|
|
205
|
-
if (!this.content) return;
|
|
206
|
-
if (this.contentPlaceholder || this.content.parentElement === document.body) return;
|
|
207
|
-
|
|
208
|
-
this.contentPlaceholder = document.createComment("tooltip-content-placeholder");
|
|
209
|
-
this.content.parentNode?.insertBefore(this.contentPlaceholder, this.content);
|
|
210
|
-
|
|
211
|
-
document.body.appendChild(this.content);
|
|
212
|
-
|
|
213
|
-
this.content.style.position = "fixed";
|
|
214
|
-
this.content.style.zIndex = "50";
|
|
215
|
-
|
|
216
|
-
const updatePosition = () => this.positionTooltip();
|
|
217
|
-
window.addEventListener("scroll", updatePosition, true);
|
|
218
|
-
window.addEventListener("resize", updatePosition);
|
|
219
|
-
|
|
220
|
-
const resizeObserver = new ResizeObserver(() => this.positionTooltip());
|
|
221
|
-
resizeObserver.observe(this.content);
|
|
222
|
-
if (this.trigger) {
|
|
223
|
-
resizeObserver.observe(this.trigger);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
this.cleanupAutoUpdate = () => {
|
|
227
|
-
window.removeEventListener("scroll", updatePosition, true);
|
|
228
|
-
window.removeEventListener("resize", updatePosition);
|
|
229
|
-
resizeObserver.disconnect();
|
|
230
|
-
};
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private unportalContent() {
|
|
234
|
-
if (!this.content) return;
|
|
235
|
-
|
|
236
|
-
this.cleanupAutoUpdate?.();
|
|
237
|
-
this.cleanupAutoUpdate = null;
|
|
238
|
-
|
|
239
|
-
if (this.contentPlaceholder) {
|
|
240
|
-
this.contentPlaceholder.parentNode?.insertBefore(this.content, this.contentPlaceholder);
|
|
241
|
-
this.contentPlaceholder.remove();
|
|
242
|
-
this.contentPlaceholder = null;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
this.content.style.removeProperty("position");
|
|
246
|
-
this.content.style.removeProperty("z-index");
|
|
247
|
-
this.content.style.removeProperty("top");
|
|
248
|
-
this.content.style.removeProperty("left");
|
|
249
|
-
this.content.style.removeProperty("transform-origin");
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
private openNow() {
|
|
253
|
-
if (!this.content || !this.trigger) return;
|
|
254
|
-
if (this.abortController.signal.aborted) return;
|
|
255
|
-
|
|
256
|
-
this.clearHideAnimationTimer();
|
|
257
|
-
this.isOpen = true;
|
|
258
|
-
this.tooltip.setAttribute("data-state", "open");
|
|
259
|
-
this.trigger.setAttribute("data-state", "open");
|
|
260
|
-
this.content.setAttribute("data-state", "open");
|
|
261
|
-
this.content.classList.remove("hidden");
|
|
262
|
-
this.portalContent();
|
|
263
|
-
this.positionTooltip();
|
|
264
|
-
requestAnimationFrame(() => this.positionTooltip());
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
private show(immediate: boolean = false) {
|
|
268
|
-
if (!this.content || !this.trigger) return;
|
|
269
|
-
|
|
270
|
-
this.clearCloseTimer();
|
|
271
|
-
this.clearHideAnimationTimer();
|
|
272
|
-
this.clearOpenTimer();
|
|
273
|
-
|
|
274
|
-
if (immediate) {
|
|
275
|
-
this.openNow();
|
|
276
|
-
this.clearOpenTimer();
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const delay = parseInt(this.tooltip.getAttribute("data-open-delay") || "200");
|
|
281
|
-
this.openTimerRef = window.setTimeout(() => {
|
|
282
|
-
if (this.abortController.signal.aborted) return;
|
|
283
|
-
this.openNow();
|
|
284
|
-
this.openTimerRef = null;
|
|
285
|
-
}, delay);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
private positionTooltip() {
|
|
289
|
-
if (!this.content || !this.trigger || !this.isOpen) return;
|
|
290
|
-
|
|
291
|
-
const triggerRect = this.trigger.getBoundingClientRect();
|
|
292
|
-
const contentWidth = this.content.offsetWidth;
|
|
293
|
-
const contentHeight = this.content.offsetHeight;
|
|
294
|
-
if (contentWidth === 0 || contentHeight === 0) return;
|
|
295
|
-
|
|
296
|
-
const resolvedPlacement = resolvePlacement({
|
|
297
|
-
side: this.side,
|
|
298
|
-
align: this.align,
|
|
299
|
-
sideOffset: this.sideOffset,
|
|
300
|
-
triggerRect,
|
|
301
|
-
contentWidth,
|
|
302
|
-
contentHeight,
|
|
303
|
-
viewportWidth: window.innerWidth,
|
|
304
|
-
viewportHeight: window.innerHeight,
|
|
305
|
-
viewportPadding: 8,
|
|
306
|
-
avoidCollisions: this.avoidCollisions,
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
this.content.style.left = `${Math.round(resolvedPlacement.left)}px`;
|
|
310
|
-
this.content.style.top = `${Math.round(resolvedPlacement.top)}px`;
|
|
311
|
-
this.content.style.transformOrigin = getTransformOrigin(
|
|
312
|
-
resolvedPlacement.side,
|
|
313
|
-
resolvedPlacement.align,
|
|
314
|
-
);
|
|
315
|
-
this.content.setAttribute("data-side", resolvedPlacement.side);
|
|
316
|
-
this.content.setAttribute("data-align", resolvedPlacement.align);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
private closeNow() {
|
|
320
|
-
if (!this.content || !this.trigger) return;
|
|
321
|
-
this.isOpen = false;
|
|
322
|
-
this.tooltip.setAttribute("data-state", "closed");
|
|
323
|
-
this.trigger.setAttribute("data-state", "closed");
|
|
324
|
-
this.content.setAttribute("data-state", "closed");
|
|
325
|
-
|
|
326
|
-
this.clearHideAnimationTimer();
|
|
327
|
-
this.hideAnimationTimerRef = window.setTimeout(() => {
|
|
328
|
-
if (this.abortController.signal.aborted) return;
|
|
329
|
-
if (!this.content) return;
|
|
330
|
-
this.content.classList.add("hidden");
|
|
331
|
-
this.unportalContent();
|
|
332
|
-
}, this.animationDuration);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
private hide(immediate: boolean = false) {
|
|
336
|
-
if (!this.content || !this.trigger) return;
|
|
337
|
-
this.clearOpenTimer();
|
|
338
|
-
this.clearCloseTimer();
|
|
339
|
-
|
|
340
|
-
if (immediate) {
|
|
341
|
-
this.closeNow();
|
|
342
|
-
return;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
this.closeTimerRef = window.setTimeout(
|
|
346
|
-
() => {
|
|
347
|
-
if (this.abortController.signal.aborted) return;
|
|
348
|
-
this.closeNow();
|
|
349
|
-
this.closeTimerRef = null;
|
|
350
|
-
},
|
|
351
|
-
parseInt(this.tooltip.getAttribute("data-close-delay") || "200"),
|
|
352
|
-
);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
destroy() {
|
|
356
|
-
if (this.abortController.signal.aborted) return;
|
|
357
|
-
|
|
358
|
-
this.abortController.abort();
|
|
359
|
-
this.clearOpenTimer();
|
|
360
|
-
this.clearCloseTimer();
|
|
361
|
-
this.clearHideAnimationTimer();
|
|
362
|
-
this.unportalContent();
|
|
363
|
-
this.isOpen = false;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
private clearOpenTimer() {
|
|
367
|
-
if (this.openTimerRef) {
|
|
368
|
-
window.clearTimeout(this.openTimerRef);
|
|
369
|
-
this.openTimerRef = null;
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
private clearCloseTimer() {
|
|
374
|
-
if (this.closeTimerRef) {
|
|
375
|
-
window.clearTimeout(this.closeTimerRef);
|
|
376
|
-
this.closeTimerRef = null;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
private clearHideAnimationTimer() {
|
|
381
|
-
if (this.hideAnimationTimerRef) {
|
|
382
|
-
window.clearTimeout(this.hideAnimationTimerRef);
|
|
383
|
-
this.hideAnimationTimerRef = null;
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
const tooltipInstances = new Map<HTMLElement, TooltipHandler>();
|
|
389
|
-
let tooltipCounter = 0;
|
|
390
|
-
|
|
391
|
-
const cleanupStaleTooltips = () => {
|
|
392
|
-
for (const [tooltipEl, tooltipHandler] of tooltipInstances.entries()) {
|
|
393
|
-
if (!document.contains(tooltipEl)) {
|
|
394
|
-
tooltipHandler.destroy();
|
|
395
|
-
tooltipInstances.delete(tooltipEl);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
|
|
400
|
-
const destroyAllTooltips = () => {
|
|
401
|
-
for (const tooltipHandler of tooltipInstances.values()) {
|
|
402
|
-
tooltipHandler.destroy();
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
tooltipInstances.clear();
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
const setupTooltips = () => {
|
|
409
|
-
cleanupStaleTooltips();
|
|
410
|
-
|
|
411
|
-
document.querySelectorAll<HTMLElement>(".starwind-tooltip").forEach((tooltip) => {
|
|
412
|
-
if (!tooltipInstances.has(tooltip)) {
|
|
413
|
-
tooltipInstances.set(tooltip, new TooltipHandler(tooltip, tooltipCounter++));
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
};
|
|
417
|
-
|
|
418
|
-
setupTooltips();
|
|
419
|
-
document.addEventListener("astro:before-swap", destroyAllTooltips);
|
|
420
|
-
document.addEventListener("astro:after-swap", setupTooltips);
|
|
421
|
-
document.addEventListener("starwind:init", setupTooltips);
|
|
422
|
-
</script>
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
import IconCaretUp from "~icons/lucide/caret-up";
|
|
5
|
-
|
|
6
|
-
export interface TooltipContentProps extends HTMLAttributes<"div"> {
|
|
7
|
-
/**
|
|
8
|
-
* Side of the tooltip
|
|
9
|
-
* @default top
|
|
10
|
-
*/
|
|
11
|
-
side?: "top" | "right" | "bottom" | "left";
|
|
12
|
-
/**
|
|
13
|
-
* Alignment of the tooltip
|
|
14
|
-
* @default center
|
|
15
|
-
*/
|
|
16
|
-
align?: "start" | "center" | "end";
|
|
17
|
-
/**
|
|
18
|
-
* Offset distance in pixels
|
|
19
|
-
* @default 8
|
|
20
|
-
*/
|
|
21
|
-
sideOffset?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Prevent the tooltip from colliding with other elements
|
|
24
|
-
* @default true
|
|
25
|
-
*/
|
|
26
|
-
avoidCollisions?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Open and close animation duration in milliseconds
|
|
29
|
-
* @default 150
|
|
30
|
-
*/
|
|
31
|
-
animationDuration?: number;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
type Props = TooltipContentProps;
|
|
35
|
-
|
|
36
|
-
export const tooltipContent = cv({
|
|
37
|
-
base: [
|
|
38
|
-
"starwind-tooltip-content",
|
|
39
|
-
"group fixed z-50 hidden w-fit px-xs py-5xs",
|
|
40
|
-
"bg-foreground text-background rounded-md",
|
|
41
|
-
"animate-in fade-in zoom-in-95",
|
|
42
|
-
"data-[state=closed]:animate-out data-[state=closed]:fill-mode-forwards fade-out zoom-out-95",
|
|
43
|
-
"data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2",
|
|
44
|
-
"data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2",
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
export const tooltipCaret = cv({
|
|
49
|
-
base: [
|
|
50
|
-
"text-foreground absolute z-50 size-4",
|
|
51
|
-
"group-data-[side=top]:bottom-0 group-data-[side=top]:left-1/2 group-data-[side=top]:-translate-x-1/2 group-data-[side=top]:translate-y-[calc(50%+1px)] group-data-[side=top]:rotate-180",
|
|
52
|
-
"group-data-[side=bottom]:top-0 group-data-[side=bottom]:left-1/2 group-data-[side=bottom]:-translate-x-1/2 group-data-[side=bottom]:-translate-y-[calc(50%+1px)]",
|
|
53
|
-
"group-data-[side=left]:top-1/2 group-data-[side=left]:right-0 group-data-[side=left]:translate-x-[calc(50%+1px)] group-data-[side=left]:-translate-y-1/2 group-data-[side=left]:rotate-90",
|
|
54
|
-
"group-data-[side=right]:top-1/2 group-data-[side=right]:left-0 group-data-[side=right]:-translate-x-[calc(50%+1px)] group-data-[side=right]:-translate-y-1/2 group-data-[side=right]:-rotate-90",
|
|
55
|
-
],
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const {
|
|
59
|
-
side = "top",
|
|
60
|
-
align = "center",
|
|
61
|
-
sideOffset = 8,
|
|
62
|
-
avoidCollisions = true,
|
|
63
|
-
animationDuration = 150,
|
|
64
|
-
class: className,
|
|
65
|
-
} = Astro.props;
|
|
66
|
-
---
|
|
67
|
-
|
|
68
|
-
<div
|
|
69
|
-
class:list={[tooltipContent(), className]}
|
|
70
|
-
data-state="closed"
|
|
71
|
-
data-side={side}
|
|
72
|
-
data-align={align}
|
|
73
|
-
data-side-offset={sideOffset}
|
|
74
|
-
{...avoidCollisions && { "data-avoid-collisions": "" }}
|
|
75
|
-
role="tooltip"
|
|
76
|
-
style={{ animationDuration: `${animationDuration}ms` }}
|
|
77
|
-
data-slot="tooltip-content"
|
|
78
|
-
>
|
|
79
|
-
<slot> My tooltip! </slot>
|
|
80
|
-
<span class={tooltipCaret()}>
|
|
81
|
-
<IconCaretUp />
|
|
82
|
-
</span>
|
|
83
|
-
</div>
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
import type { HTMLAttributes } from "astro/types";
|
|
3
|
-
import { cv } from "css-variants";
|
|
4
|
-
|
|
5
|
-
export const video = cv({
|
|
6
|
-
base: "starwind-video aspect-video h-auto w-full",
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
export interface VideoProps extends HTMLAttributes<"video">, HTMLAttributes<"iframe"> {
|
|
10
|
-
src: string;
|
|
11
|
-
title?: string;
|
|
12
|
-
autoplay?: boolean;
|
|
13
|
-
muted?: boolean;
|
|
14
|
-
loop?: boolean;
|
|
15
|
-
controls?: boolean;
|
|
16
|
-
poster?: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
type Props = VideoProps;
|
|
20
|
-
|
|
21
|
-
const {
|
|
22
|
-
class: className,
|
|
23
|
-
src,
|
|
24
|
-
title = "Video",
|
|
25
|
-
autoplay = false,
|
|
26
|
-
muted = false,
|
|
27
|
-
loop = false,
|
|
28
|
-
controls = true,
|
|
29
|
-
poster,
|
|
30
|
-
...rest
|
|
31
|
-
} = Astro.props;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Detects the video type from the src URL
|
|
35
|
-
*/
|
|
36
|
-
function getVideoType(url: string): "youtube" | "youtube-shorts" | "native" {
|
|
37
|
-
if (url.includes("youtube.com/shorts/") || url.includes("youtu.be/shorts/")) {
|
|
38
|
-
return "youtube-shorts";
|
|
39
|
-
}
|
|
40
|
-
if (
|
|
41
|
-
url.includes("youtube.com") ||
|
|
42
|
-
url.includes("youtu.be") ||
|
|
43
|
-
url.includes("youtube-nocookie.com")
|
|
44
|
-
) {
|
|
45
|
-
return "youtube";
|
|
46
|
-
}
|
|
47
|
-
return "native";
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Extracts YouTube video ID from various URL formats
|
|
52
|
-
*/
|
|
53
|
-
function getYouTubeId(url: string): string | null {
|
|
54
|
-
const patterns = [
|
|
55
|
-
/youtube\.com\/shorts\/([^?&]+)/,
|
|
56
|
-
/youtube\.com\/watch\?v=([^&]+)/,
|
|
57
|
-
/youtube\.com\/embed\/([^?&]+)/,
|
|
58
|
-
/youtu\.be\/([^?&]+)/,
|
|
59
|
-
/youtube-nocookie\.com\/embed\/([^?&]+)/,
|
|
60
|
-
];
|
|
61
|
-
|
|
62
|
-
for (const pattern of patterns) {
|
|
63
|
-
const match = url.match(pattern);
|
|
64
|
-
if (match) return match[1] || null;
|
|
65
|
-
}
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Builds YouTube embed URL with parameters
|
|
71
|
-
*/
|
|
72
|
-
function buildYouTubeEmbedUrl(videoId: string, _isShort: boolean): string {
|
|
73
|
-
const params = new URLSearchParams();
|
|
74
|
-
if (autoplay) params.set("autoplay", "1");
|
|
75
|
-
if (muted) params.set("mute", "1");
|
|
76
|
-
if (loop) {
|
|
77
|
-
params.set("loop", "1");
|
|
78
|
-
params.set("playlist", videoId);
|
|
79
|
-
}
|
|
80
|
-
if (!controls) params.set("controls", "0");
|
|
81
|
-
|
|
82
|
-
const baseUrl = `https://www.youtube-nocookie.com/embed/${videoId}`;
|
|
83
|
-
const queryString = params.toString();
|
|
84
|
-
return queryString ? `${baseUrl}?${queryString}` : baseUrl;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const videoType = getVideoType(src);
|
|
88
|
-
const youtubeId = videoType !== "native" ? getYouTubeId(src) : null;
|
|
89
|
-
const isShort = videoType === "youtube-shorts";
|
|
90
|
-
const embedUrl = youtubeId ? buildYouTubeEmbedUrl(youtubeId, isShort) : null;
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
{
|
|
94
|
-
videoType === "native" || !embedUrl ? (
|
|
95
|
-
<video
|
|
96
|
-
class:list={[video(), className]}
|
|
97
|
-
src={src}
|
|
98
|
-
autoplay={autoplay}
|
|
99
|
-
muted={muted}
|
|
100
|
-
loop={loop}
|
|
101
|
-
controls={controls}
|
|
102
|
-
poster={poster}
|
|
103
|
-
{...rest}
|
|
104
|
-
data-slot="video"
|
|
105
|
-
>
|
|
106
|
-
<track kind="captions" />
|
|
107
|
-
</video>
|
|
108
|
-
) : (
|
|
109
|
-
<iframe
|
|
110
|
-
class:list={[video(), className]}
|
|
111
|
-
src={embedUrl}
|
|
112
|
-
title={title}
|
|
113
|
-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
|
|
114
|
-
referrerpolicy="strict-origin-when-cross-origin"
|
|
115
|
-
allowfullscreen
|
|
116
|
-
data-video-type={isShort ? "youtube-shorts" : "youtube"}
|
|
117
|
-
{...rest}
|
|
118
|
-
data-slot="video"
|
|
119
|
-
/>
|
|
120
|
-
)
|
|
121
|
-
}
|
package/src/config/cookies.ts
DELETED
package/src/config/links.ts
DELETED
package/src/domain/cms/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./types"
|
package/src/domain/cms/types.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Minimal shape of an Astro Content Collection entry. Explicitly allowing undefined for all common
|
|
3
|
-
* SEO fields to resolve monorepo type clashes.
|
|
4
|
-
*/
|
|
5
|
-
export interface BaseCMSContentEntry {
|
|
6
|
-
id: string
|
|
7
|
-
data: {
|
|
8
|
-
title?: string | undefined | null
|
|
9
|
-
description?: string | undefined | null
|
|
10
|
-
publishedDate?: Date | undefined | null
|
|
11
|
-
[key: string]: unknown
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Type guard to safely identify a content entry that satisfies the base library requirements.
|
|
17
|
-
*/
|
|
18
|
-
export function isBaseCMSContentEntry(entry: unknown): entry is BaseCMSContentEntry {
|
|
19
|
-
return !!entry && typeof entry === "object" && entry !== null && "id" in entry && "data" in entry
|
|
20
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Locales Configuration
|
|
2
|
-
export const SUPPORTED_LOCALES = ["en", "pt", "ja", "de", "es"] as const
|
|
3
|
-
export type SupportedLocales = (typeof SUPPORTED_LOCALES)[number]
|
|
4
|
-
|
|
5
|
-
// Default locale
|
|
6
|
-
export const DEFAULT_LOCALE: SupportedLocales = "en"
|
|
7
|
-
|
|
8
|
-
// Missing translation banner flag
|
|
9
|
-
export const ENABLE_MISSING_TRANSLATION_BANNER = true
|
|
10
|
-
|
|
11
|
-
// UI Labels
|
|
12
|
-
export const LANGUAGES: Record<SupportedLocales, string> = {
|
|
13
|
-
en: "English",
|
|
14
|
-
pt: "Português",
|
|
15
|
-
ja: "日本語",
|
|
16
|
-
de: "Deutsch",
|
|
17
|
-
es: "Español"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Cookie name
|
|
21
|
-
export const LANG_COOKIE_NAME = "lang"
|