@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
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
import Carousel from "@rimelight/ui/components/carousel/Carousel.astro";
|
|
3
|
+
import CarouselPrevious from "@rimelight/ui/components/carousel/CarouselPrevious.astro";
|
|
4
|
+
import CarouselNext from "@rimelight/ui/components/carousel/CarouselNext.astro";
|
|
5
|
+
import type { HTMLAttributes } from "astro/types";
|
|
6
|
+
import type { EmblaOptionsType } from "embla-carousel";
|
|
7
|
+
|
|
8
|
+
export interface ExtendedCarouselProps extends HTMLAttributes<"div"> {
|
|
9
|
+
opts?: EmblaOptionsType;
|
|
10
|
+
orientation?: "horizontal" | "vertical";
|
|
11
|
+
showDots?: boolean;
|
|
12
|
+
}
|
|
13
|
+
type Props = ExtendedCarouselProps;
|
|
14
|
+
|
|
15
|
+
const { opts = {}, orientation = "horizontal", showDots = true, class: className, ...rest } = Astro.props;
|
|
16
|
+
|
|
17
|
+
// Default loop to true for ExtendedCarousel
|
|
18
|
+
const carouselOpts: EmblaOptionsType = {
|
|
19
|
+
loop: true,
|
|
20
|
+
...opts
|
|
21
|
+
};
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
<Carousel
|
|
25
|
+
opts={carouselOpts}
|
|
26
|
+
orientation={orientation}
|
|
27
|
+
class:list={["extended-carousel group/extended-carousel", className]}
|
|
28
|
+
{...rest}
|
|
29
|
+
data-extended-carousel
|
|
30
|
+
autoInit={false}
|
|
31
|
+
>
|
|
32
|
+
<slot />
|
|
33
|
+
|
|
34
|
+
<div class="hidden md:block">
|
|
35
|
+
<CarouselPrevious class="-left-12 opacity-50 hover:opacity-100 transition-opacity" />
|
|
36
|
+
<CarouselNext class="-right-12 opacity-50 hover:opacity-100 transition-opacity" />
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
{showDots && (
|
|
40
|
+
<div class="carousel-pagination absolute bottom-8 left-1/2 -translate-x-1/2 z-10 flex justify-center items-center gap-1.5" data-slot="pagination">
|
|
41
|
+
{/* Dots injected by script */}
|
|
42
|
+
</div>
|
|
43
|
+
)}
|
|
44
|
+
</Carousel>
|
|
45
|
+
|
|
46
|
+
<script>
|
|
47
|
+
import { initCarousel } from "@rimelight/ui/components/carousel/carousel-script.ts";
|
|
48
|
+
|
|
49
|
+
const setupExtendedCarousels = () => {
|
|
50
|
+
const extendedCarousels = document.querySelectorAll('[data-extended-carousel]') as NodeListOf<HTMLElement>;
|
|
51
|
+
|
|
52
|
+
extendedCarousels.forEach((carousel) => {
|
|
53
|
+
// Avoid double-initialization
|
|
54
|
+
if (carousel.dataset.extendedInitialized === "true") return;
|
|
55
|
+
carousel.dataset.extendedInitialized = "true";
|
|
56
|
+
|
|
57
|
+
// Initialize the underlying Starwind carousel
|
|
58
|
+
// Passing autoInit={false} to the component means we handle init here
|
|
59
|
+
const manager = initCarousel(carousel);
|
|
60
|
+
if (!manager) return;
|
|
61
|
+
|
|
62
|
+
const api = manager.api;
|
|
63
|
+
const pagination = carousel.querySelector('[data-slot="pagination"]');
|
|
64
|
+
|
|
65
|
+
if (pagination) {
|
|
66
|
+
const scrollSnaps = api.scrollSnapList();
|
|
67
|
+
const dots: HTMLButtonElement[] = [];
|
|
68
|
+
|
|
69
|
+
// Clear existing (useful for handle re-init cases)
|
|
70
|
+
pagination.innerHTML = '';
|
|
71
|
+
|
|
72
|
+
scrollSnaps.forEach((_: number, index: number) => {
|
|
73
|
+
const dot = document.createElement('button');
|
|
74
|
+
dot.className = 'size-4 rounded-full bg-border transition-all hover:bg-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary h-4 cursor-pointer';
|
|
75
|
+
dot.setAttribute('aria-label', `Go to slide ${index + 1}`);
|
|
76
|
+
dot.addEventListener('click', () => api.scrollTo(index));
|
|
77
|
+
pagination.appendChild(dot);
|
|
78
|
+
dots.push(dot);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const updateDots = () => {
|
|
82
|
+
const selectedIndex = api.selectedScrollSnap();
|
|
83
|
+
dots.forEach((dot, index) => {
|
|
84
|
+
if (index === selectedIndex) {
|
|
85
|
+
dot.classList.add('bg-primary');
|
|
86
|
+
dot.classList.remove('bg-border');
|
|
87
|
+
} else {
|
|
88
|
+
dot.classList.remove('bg-primary');
|
|
89
|
+
dot.classList.add('bg-border');
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
api.on('select', updateDots);
|
|
95
|
+
api.on('init', updateDots);
|
|
96
|
+
api.on('reInit', updateDots);
|
|
97
|
+
|
|
98
|
+
updateDots();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// Run on load and after Astro page swaps
|
|
104
|
+
document.addEventListener("DOMContentLoaded", setupExtendedCarousels);
|
|
105
|
+
document.addEventListener("astro:after-swap", setupExtendedCarousels);
|
|
106
|
+
</script>
|
|
107
|
+
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
---
|
|
2
2
|
export interface FormattedDateProps {
|
|
3
3
|
date?: Date | undefined;
|
|
4
|
+
locale?: string;
|
|
4
5
|
}
|
|
5
6
|
type Props = FormattedDateProps;
|
|
6
7
|
|
|
7
|
-
const {
|
|
8
|
+
const {
|
|
9
|
+
date,
|
|
10
|
+
locale = Astro.locals.astroI18n?.locale || "en-US"
|
|
11
|
+
} = Astro.props;
|
|
8
12
|
---
|
|
9
13
|
|
|
10
14
|
{
|
|
11
15
|
date && (
|
|
12
16
|
<time datetime={date.toISOString()}>
|
|
13
17
|
{
|
|
14
|
-
date.toLocaleDateString(
|
|
18
|
+
date.toLocaleDateString(locale, {
|
|
15
19
|
year: 'numeric',
|
|
16
20
|
month: 'short',
|
|
17
21
|
day: 'numeric',
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { ClientRouter } from 'astro:transitions';
|
|
3
|
+
import type { SiteConfig } from '@/config';
|
|
4
|
+
import UApp from './nuxt/App.vue';
|
|
5
|
+
|
|
6
|
+
export interface HeadProps {
|
|
7
|
+
/** Page title */
|
|
8
|
+
title?: string;
|
|
9
|
+
/** Page description */
|
|
10
|
+
description?: string;
|
|
11
|
+
/** Open Graph image URL */
|
|
12
|
+
ogImage?: string;
|
|
13
|
+
/** Whether to prevent indexing */
|
|
14
|
+
noindex?: boolean;
|
|
15
|
+
/** Whether this is a 404 page */
|
|
16
|
+
is404?: boolean;
|
|
17
|
+
/** Robots metadata (overrides noindex/is404 logic if provided) */
|
|
18
|
+
robots?: string;
|
|
19
|
+
/** Canonical URL */
|
|
20
|
+
canonical?: string;
|
|
21
|
+
/** Language alternates for i18n */
|
|
22
|
+
languageAlternates?: Array<{ hreflang: string; href: string }>;
|
|
23
|
+
/** Site configuration for defaults */
|
|
24
|
+
config?: SiteConfig;
|
|
25
|
+
/** Whether to enable View Transitions (ClientRouter) */
|
|
26
|
+
transitions?: boolean;
|
|
27
|
+
/** Meta charset */
|
|
28
|
+
charset?: string;
|
|
29
|
+
/** Meta viewport */
|
|
30
|
+
viewport?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
title,
|
|
35
|
+
description,
|
|
36
|
+
ogImage,
|
|
37
|
+
noindex = false,
|
|
38
|
+
is404 = false,
|
|
39
|
+
robots,
|
|
40
|
+
canonical,
|
|
41
|
+
languageAlternates = [],
|
|
42
|
+
config,
|
|
43
|
+
transitions = true,
|
|
44
|
+
charset = "utf-8",
|
|
45
|
+
viewport = "width=device-width,initial-scale=1",
|
|
46
|
+
} = Astro.props as HeadProps
|
|
47
|
+
|
|
48
|
+
// Resolve defaults from config if available
|
|
49
|
+
const siteName = config?.name || "Rimelight";
|
|
50
|
+
const siteUrl = config?.url || "";
|
|
51
|
+
const siteDescription = config?.description || "";
|
|
52
|
+
const ogImageFallback = config?.seo?.ogImageFallback || config?.ogImage || "";
|
|
53
|
+
const themeColor = config?.branding?.colors?.themeColor;
|
|
54
|
+
const favicon = config?.branding?.favicon?.svg || "/favicon.svg";
|
|
55
|
+
const twitterHandle = config?.seo?.authorHandle;
|
|
56
|
+
const titleTemplate = config?.seo?.titleTemplate || `%s | ${siteName}`;
|
|
57
|
+
|
|
58
|
+
// Calculated Values
|
|
59
|
+
const displayTitle = is404
|
|
60
|
+
? `404 - Not Found | ${siteName}`
|
|
61
|
+
: title
|
|
62
|
+
? titleTemplate.replace('%s', title)
|
|
63
|
+
: siteName;
|
|
64
|
+
|
|
65
|
+
const finalDescription = description || siteDescription;
|
|
66
|
+
const safeDescription = finalDescription && config?.seo?.maxDescriptionLength
|
|
67
|
+
? (finalDescription.length > config.seo.maxDescriptionLength
|
|
68
|
+
? finalDescription.slice(0, config.seo.maxDescriptionLength - 3) + "..."
|
|
69
|
+
: finalDescription)
|
|
70
|
+
: finalDescription;
|
|
71
|
+
|
|
72
|
+
const finalOgImage = ogImage || ogImageFallback;
|
|
73
|
+
const absoluteOgImage = finalOgImage
|
|
74
|
+
? (finalOgImage.startsWith('http') ? finalOgImage : `${siteUrl}${finalOgImage}`)
|
|
75
|
+
: undefined;
|
|
76
|
+
|
|
77
|
+
const finalCanonical = canonical || (!is404 ? Astro.url.href : undefined);
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
<!-- Basic Metadata -->
|
|
81
|
+
<meta charset={charset} />
|
|
82
|
+
<meta name="viewport" content={viewport} />
|
|
83
|
+
<meta name="generator" content={Astro.generator} />
|
|
84
|
+
|
|
85
|
+
<!-- SEO -->
|
|
86
|
+
<title>{displayTitle}</title>
|
|
87
|
+
{safeDescription && <meta name="description" content={safeDescription} />}
|
|
88
|
+
{robots ? <meta name="robots" content={robots} /> : (noindex || is404) && <meta name="robots" content="noindex, nofollow" />}
|
|
89
|
+
{finalCanonical && <link rel="canonical" href={finalCanonical} />}
|
|
90
|
+
|
|
91
|
+
<!-- i18n Alternates -->
|
|
92
|
+
{languageAlternates.map((alt) => (
|
|
93
|
+
<link rel="alternate" hreflang={alt.hreflang} href={alt.href} />
|
|
94
|
+
))}
|
|
95
|
+
|
|
96
|
+
<!-- Open Graph / Facebook -->
|
|
97
|
+
<meta property="og:type" content="website" />
|
|
98
|
+
<meta property="og:url" content={Astro.url.href} />
|
|
99
|
+
<meta property="og:title" content={title || siteName} />
|
|
100
|
+
{safeDescription && <meta property="og:description" content={safeDescription} />}
|
|
101
|
+
{absoluteOgImage && <meta property="og:image" content={absoluteOgImage} />}
|
|
102
|
+
<meta property="og:site_name" content={siteName} />
|
|
103
|
+
|
|
104
|
+
<!-- Twitter -->
|
|
105
|
+
<meta property="twitter:card" content="summary_large_image" />
|
|
106
|
+
<meta property="twitter:url" content={Astro.url.href} />
|
|
107
|
+
<meta property="twitter:title" content={title || siteName} />
|
|
108
|
+
{safeDescription && <meta property="twitter:description" content={safeDescription} />}
|
|
109
|
+
{absoluteOgImage && <meta property="twitter:image" content={absoluteOgImage} />}
|
|
110
|
+
{twitterHandle && <meta property="twitter:site" content={twitterHandle} />}
|
|
111
|
+
{twitterHandle && <meta property="twitter:creator" content={twitterHandle} />}
|
|
112
|
+
|
|
113
|
+
<!-- Icons -->
|
|
114
|
+
<link rel="icon" type="image/svg+xml" href={favicon} />
|
|
115
|
+
|
|
116
|
+
<!-- Theme -->
|
|
117
|
+
{themeColor && <meta name="theme-color" content={themeColor} />}
|
|
118
|
+
|
|
119
|
+
<script is:inline>
|
|
120
|
+
const theme = (() => {
|
|
121
|
+
if (typeof localStorage !== 'undefined' && localStorage.getItem('theme')) {
|
|
122
|
+
return localStorage.getItem('theme');
|
|
123
|
+
}
|
|
124
|
+
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
125
|
+
return 'dark';
|
|
126
|
+
}
|
|
127
|
+
return 'light';
|
|
128
|
+
})();
|
|
129
|
+
|
|
130
|
+
if (theme === 'dark') {
|
|
131
|
+
document.documentElement.classList.add('dark');
|
|
132
|
+
} else {
|
|
133
|
+
document.documentElement.classList.remove('dark');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
window.localStorage.setItem('theme', theme);
|
|
137
|
+
</script>
|
|
138
|
+
|
|
139
|
+
<script>
|
|
140
|
+
document.addEventListener('astro:after-swap', () => {
|
|
141
|
+
if (localStorage.getItem('theme') === 'dark') {
|
|
142
|
+
document.documentElement.classList.add('dark');
|
|
143
|
+
} else {
|
|
144
|
+
document.documentElement.classList.remove('dark');
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
</script>
|
|
148
|
+
|
|
149
|
+
{transitions && <ClientRouter />}
|
|
150
|
+
|
|
151
|
+
<UApp client:load>
|
|
152
|
+
<slot />
|
|
153
|
+
</UApp>
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { Image } from "astro:assets";
|
|
3
|
+
import { scv } from "css-variants";
|
|
4
|
+
import type { CollectionEntry } from "astro:content";
|
|
5
|
+
import Separator from "@rimelight/ui/components/separator/Separator.astro";
|
|
6
|
+
import Avatar from "@rimelight/ui/components/avatar/Avatar.astro";
|
|
7
|
+
import AvatarImage from "@rimelight/ui/components/avatar/AvatarImage.astro";
|
|
8
|
+
import avatarAsset from "../assets/team/Daniel-Marchi_0000_00.webp";
|
|
9
|
+
|
|
10
|
+
// Support both Astro content collections and CMS documents
|
|
11
|
+
export type CMSProjectDocument = {
|
|
12
|
+
_id: string;
|
|
13
|
+
slug?: string;
|
|
14
|
+
title: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
heroImage?: string;
|
|
17
|
+
publishedDate?: string | Date | null;
|
|
18
|
+
featured?: boolean;
|
|
19
|
+
tags?: string[] | Record<string, unknown> | null;
|
|
20
|
+
_updatedAt?: string;
|
|
21
|
+
_createdAt?: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface ProjectPostProps extends NonNullable<Parameters<typeof projectPostVariants>[0]> {
|
|
25
|
+
project: CollectionEntry<"projects"> | CMSProjectDocument;
|
|
26
|
+
class?: string;
|
|
27
|
+
showImage?: boolean;
|
|
28
|
+
separator?: boolean;
|
|
29
|
+
/** Translations for the component */
|
|
30
|
+
t?: {
|
|
31
|
+
latest_badge?: string;
|
|
32
|
+
view_project?: string;
|
|
33
|
+
};
|
|
34
|
+
/** The current locale for formatting and links */
|
|
35
|
+
locale?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type Props = ProjectPostProps;
|
|
39
|
+
|
|
40
|
+
const projectPostVariants = scv({
|
|
41
|
+
slots: [
|
|
42
|
+
"root",
|
|
43
|
+
"imageWrapper",
|
|
44
|
+
"image",
|
|
45
|
+
"content",
|
|
46
|
+
"title",
|
|
47
|
+
"description",
|
|
48
|
+
"footer",
|
|
49
|
+
"authorGroup",
|
|
50
|
+
"author",
|
|
51
|
+
"link",
|
|
52
|
+
"badge",
|
|
53
|
+
"featuredBadge"
|
|
54
|
+
],
|
|
55
|
+
base: {
|
|
56
|
+
root: "group flex transition-all duration-300 w-full",
|
|
57
|
+
imageWrapper: "relative overflow-hidden ring-1 ring-border shadow-sm shrink-0 bg-muted isolate",
|
|
58
|
+
image: "absolute inset-0 h-full w-full !object-cover transition-transform duration-500 group-hover:scale-105 block",
|
|
59
|
+
content: "flex flex-col flex-1",
|
|
60
|
+
title: "font-heading font-bold tracking-tight text-pretty group-hover:text-primary transition-colors",
|
|
61
|
+
description: "text-muted-foreground line-clamp-2 text-base text-pretty",
|
|
62
|
+
footer: "mt-auto flex items-end justify-end w-full",
|
|
63
|
+
authorGroup: "flex flex-col gap-5xs text-xs font-medium text-muted-foreground",
|
|
64
|
+
author: "font-bold text-foreground",
|
|
65
|
+
link: "inline-flex items-center gap-5xs text-sm font-semibold hover:underline decoration-primary underline-offset-4",
|
|
66
|
+
badge: "px-2xs py-6xs rounded-full bg-muted text-muted-foreground text-[10px] font-bold uppercase tracking-wider",
|
|
67
|
+
featuredBadge: "absolute top-3 left-3 z-20 flex items-center gap-5xs px-3xs py-5xs rounded-full bg-primary text-primary-foreground text-[10px] font-bold uppercase tracking-wider shadow-lg ring-1 ring-white/20",
|
|
68
|
+
},
|
|
69
|
+
variants: {
|
|
70
|
+
variant: {
|
|
71
|
+
flat: {
|
|
72
|
+
root: "flex-col md:flex-row gap-3xl md:gap-4xl items-stretch py-4xl first:pt-0 last:pb-0 text-left",
|
|
73
|
+
imageWrapper: "w-full md:w-5/12 aspect-video self-stretch rounded-3xl shrink-0 shadow-none ring-0",
|
|
74
|
+
content: "gap-2xl justify-center items-start text-left",
|
|
75
|
+
title: "text-xl",
|
|
76
|
+
description: "text-base",
|
|
77
|
+
},
|
|
78
|
+
card: {
|
|
79
|
+
root: "flex-col bg-muted/20 p-2xl rounded-3xl border border-border/50 hover:bg-muted/40 hover:shadow-2xl hover:-translate-y-1 gap-2xl text-left items-stretch",
|
|
80
|
+
imageWrapper: "w-full aspect-video rounded-2xl shadow-lg",
|
|
81
|
+
title: "text-xl",
|
|
82
|
+
content: "gap-2xl text-left items-start",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
defaultVariants: {
|
|
87
|
+
variant: "flat",
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const {
|
|
92
|
+
project,
|
|
93
|
+
variant,
|
|
94
|
+
class: className,
|
|
95
|
+
showImage = true,
|
|
96
|
+
separator = false,
|
|
97
|
+
t: tProp,
|
|
98
|
+
locale = Astro.locals.astroI18n?.locale || "en"
|
|
99
|
+
} = Astro.props;
|
|
100
|
+
|
|
101
|
+
const t = {
|
|
102
|
+
latest_badge: tProp?.latest_badge || (Astro.locals.astroI18n ? Astro.locals.astroI18n.t("projects.latest_badge") : "Latest"),
|
|
103
|
+
view_project: tProp?.view_project || (Astro.locals.astroI18n ? Astro.locals.astroI18n.t("projects.view_project") : "View Project"),
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// Detect if this is a CMS document or Astro content entry
|
|
107
|
+
const isCMSDocument = "_id" in project && !("id" in project);
|
|
108
|
+
|
|
109
|
+
// Extract fields based on source type
|
|
110
|
+
const projectTitle = isCMSDocument ? project.title : (project as CollectionEntry<"projects">).data.title;
|
|
111
|
+
const projectDescription = isCMSDocument ? project.description : (project as CollectionEntry<"projects">).data.description;
|
|
112
|
+
const projectImage = isCMSDocument ? project.heroImage : (project as CollectionEntry<"projects">).data.heroImage;
|
|
113
|
+
const projectFeatured = isCMSDocument ? (project.featured ?? false) : (project as CollectionEntry<"projects">).data.featured;
|
|
114
|
+
const projectTags = isCMSDocument ? (project.tags || []) : ((project as CollectionEntry<"projects">).data.tags || []);
|
|
115
|
+
|
|
116
|
+
// Handle date formatting
|
|
117
|
+
const rawDate = isCMSDocument ? (project.publishedDate || project._createdAt) : (project as CollectionEntry<"projects">).data.publishedDate;
|
|
118
|
+
const d = rawDate ? new Date(rawDate) : null;
|
|
119
|
+
const formattedDate = d && !isNaN(d.getTime())
|
|
120
|
+
? new Intl.DateTimeFormat(locale, {
|
|
121
|
+
dateStyle: "medium",
|
|
122
|
+
}).format(d)
|
|
123
|
+
: "";
|
|
124
|
+
|
|
125
|
+
// Get slug from CMS or Astro content
|
|
126
|
+
const projectSlug = isCMSDocument
|
|
127
|
+
? (project.slug || "")
|
|
128
|
+
: (project as CollectionEntry<"projects">).id.replace(/^(en|pt|de|es|ja)\//, "");
|
|
129
|
+
|
|
130
|
+
const { root, imageWrapper, image, content, title, description, footer, authorGroup, author, link, badge, featuredBadge } = projectPostVariants({ variant });
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
<div class="flex flex-col w-full">
|
|
134
|
+
<a href={Astro.locals.astroI18n ? Astro.locals.astroI18n.l(`/projects/${projectSlug}`) : `/${locale}/projects/${projectSlug}`} class:list={[root, className]}>
|
|
135
|
+
{showImage && (
|
|
136
|
+
<div class={imageWrapper}>
|
|
137
|
+
{projectFeatured && (
|
|
138
|
+
<div class={featuredBadge}>
|
|
139
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 24 24" fill="currentColor" stroke="none"><path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"></path></svg>
|
|
140
|
+
{t.latest_badge}
|
|
141
|
+
</div>
|
|
142
|
+
)}
|
|
143
|
+
{projectImage && (
|
|
144
|
+
<Image
|
|
145
|
+
src={projectImage as any}
|
|
146
|
+
alt={projectTitle}
|
|
147
|
+
width={800}
|
|
148
|
+
height={450}
|
|
149
|
+
class={image}
|
|
150
|
+
loading="lazy"
|
|
151
|
+
decoding="async"
|
|
152
|
+
/>
|
|
153
|
+
)}
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
<div class={content}>
|
|
158
|
+
<h3 class={title}>
|
|
159
|
+
{projectTitle}
|
|
160
|
+
</h3>
|
|
161
|
+
|
|
162
|
+
<div class="flex items-center gap-3xs mt-3xs">
|
|
163
|
+
<Avatar size="sm" variant="primary">
|
|
164
|
+
<AvatarImage image={avatarAsset} alt="Daniel Marchi" />
|
|
165
|
+
</Avatar>
|
|
166
|
+
<div class={authorGroup}>
|
|
167
|
+
<span class={author}>Daniel Marchi</span>
|
|
168
|
+
<div class="flex items-center gap-3xs">
|
|
169
|
+
<span>{formattedDate}</span>
|
|
170
|
+
<div class="flex flex-wrap gap-5xs ml-3xs">
|
|
171
|
+
{Array.isArray(projectTags) && projectTags.map((tag: string) => (
|
|
172
|
+
<span class={badge}>{tag}</span>
|
|
173
|
+
))}
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
</div>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<p class={description}>
|
|
180
|
+
{projectDescription}
|
|
181
|
+
</p>
|
|
182
|
+
|
|
183
|
+
<div class={footer}>
|
|
184
|
+
<span class={link}>
|
|
185
|
+
{t.view_project}
|
|
186
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" class="transition-transform group-hover:translate-x-1"><path d="M5 12h14"></path><path d="m12 5 7 7-7 7"></path></svg>
|
|
187
|
+
</span>
|
|
188
|
+
</div>
|
|
189
|
+
</div>
|
|
190
|
+
</a>
|
|
191
|
+
|
|
192
|
+
{separator && (
|
|
193
|
+
<div class="py-4xl last:hidden">
|
|
194
|
+
<Separator />
|
|
195
|
+
</div>
|
|
196
|
+
)}
|
|
197
|
+
</div>
|
|
@@ -1,71 +1,59 @@
|
|
|
1
1
|
---
|
|
2
|
+
import RLAButton from "./astro/RLAButton.astro";
|
|
2
3
|
import IconSun from "~icons/lucide/sun"
|
|
3
4
|
import IconMoon from "~icons/lucide/moon"
|
|
4
|
-
import Toggle from "./toggle/Toggle.astro";
|
|
5
5
|
|
|
6
6
|
export interface ThemeToggleProps {
|
|
7
7
|
class?: string;
|
|
8
8
|
size?: "sm" | "md" | "lg";
|
|
9
9
|
}
|
|
10
|
+
|
|
10
11
|
type Props = ThemeToggleProps;
|
|
11
12
|
|
|
12
|
-
const { class: className, size = "md" } = Astro.props as Props
|
|
13
|
+
const { class: className, size = "md" } = Astro.props as Props
|
|
13
14
|
---
|
|
14
15
|
|
|
15
|
-
<
|
|
16
|
-
id="theme-toggle"
|
|
16
|
+
<RLAButton
|
|
17
17
|
size={size}
|
|
18
18
|
class:list={[
|
|
19
|
+
"theme-toggle-button",
|
|
19
20
|
"group text-muted-foreground hover:text-foreground rounded-full hover:bg-transparent",
|
|
20
21
|
className,
|
|
21
22
|
]}
|
|
22
23
|
variant="ghost"
|
|
23
|
-
className={className}
|
|
24
24
|
aria-label="Toggle theme"
|
|
25
25
|
>
|
|
26
|
-
<IconSun class="sun-wrapper" />
|
|
27
|
-
<IconMoon class="moon-wrapper" />
|
|
28
|
-
</
|
|
29
|
-
|
|
30
|
-
<style>
|
|
31
|
-
#theme-toggle[data-state="on"] .sun-wrapper {
|
|
32
|
-
display: none;
|
|
33
|
-
}
|
|
34
|
-
#theme-toggle[data-state="off"] .sun-wrapper {
|
|
35
|
-
display: flex;
|
|
36
|
-
}
|
|
37
|
-
#theme-toggle[data-state="on"] .moon-wrapper {
|
|
38
|
-
display: flex;
|
|
39
|
-
}
|
|
40
|
-
#theme-toggle[data-state="off"] .moon-wrapper {
|
|
41
|
-
display: none;
|
|
42
|
-
}
|
|
43
|
-
</style>
|
|
26
|
+
<IconSun class="sun-wrapper block dark:hidden" />
|
|
27
|
+
<IconMoon class="moon-wrapper hidden dark:block" />
|
|
28
|
+
</RLAButton>
|
|
44
29
|
|
|
45
30
|
<script>
|
|
46
31
|
function setupThemeToggle() {
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
button.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
32
|
+
const buttons = document.querySelectorAll('.theme-toggle-button');
|
|
33
|
+
|
|
34
|
+
const updateButtons = (isDark: boolean) => {
|
|
35
|
+
buttons.forEach(btn => {
|
|
36
|
+
btn.setAttribute('data-state', isDark ? 'on' : 'off');
|
|
37
|
+
btn.setAttribute('aria-pressed', isDark.toString());
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Set initial state
|
|
42
|
+
const currentIsDark = document.documentElement.classList.contains('dark');
|
|
43
|
+
updateButtons(currentIsDark);
|
|
44
|
+
|
|
45
|
+
buttons.forEach(button => {
|
|
46
|
+
button.addEventListener('click', () => {
|
|
47
|
+
const isDark = document.documentElement.classList.toggle('dark');
|
|
48
|
+
localStorage.setItem('theme', isDark ? 'dark' : 'light');
|
|
49
|
+
updateButtons(isDark);
|
|
50
|
+
});
|
|
65
51
|
});
|
|
66
52
|
}
|
|
67
53
|
|
|
68
|
-
//
|
|
54
|
+
// Initial setup
|
|
55
|
+
setupThemeToggle();
|
|
56
|
+
// Re-run on View Transitions
|
|
69
57
|
document.addEventListener('astro:page-load', setupThemeToggle);
|
|
70
58
|
</script>
|
|
71
59
|
|