@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,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
export interface SidebarMenuItemProps extends HTMLAttributes<"li"> {}
|
|
6
|
+
type Props = SidebarMenuItemProps;
|
|
7
|
+
|
|
8
|
+
export const sidebarMenuItem = cv({
|
|
9
|
+
base: "group/menu-item relative",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const { class: className, ...rest } = Astro.props;
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<li
|
|
16
|
+
class:list={[sidebarMenuItem(), className]}
|
|
17
|
+
data-sidebar="menu-item"
|
|
18
|
+
{...rest}
|
|
19
|
+
data-slot="sidebar-menu-item"
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</li>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
import Skeleton from "../skeleton/Skeleton.astro";
|
|
6
|
+
|
|
7
|
+
const sidebarMenuSkeleton = cv({
|
|
8
|
+
base: "flex h-8 items-center gap-md rounded-md px-2",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export interface SidebarMenuSkeletonProps extends HTMLAttributes<"div"> {
|
|
12
|
+
/**
|
|
13
|
+
* Whether to show the icon skeleton
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
16
|
+
showIcon?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Width of the text skeleton (random 50-90% if not specified)
|
|
19
|
+
*/
|
|
20
|
+
width?: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type Props = SidebarMenuSkeletonProps;
|
|
24
|
+
|
|
25
|
+
const { showIcon = false, width, class: className, ...rest } = Astro.props;
|
|
26
|
+
|
|
27
|
+
const skeletonWidth = width || `${Math.floor(Math.random() * 40) + 50}%`;
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
<div
|
|
31
|
+
class:list={[sidebarMenuSkeleton(), className]}
|
|
32
|
+
data-sidebar="menu-skeleton"
|
|
33
|
+
{...rest}
|
|
34
|
+
data-slot="sidebar-menu-skeleton"
|
|
35
|
+
>
|
|
36
|
+
{showIcon && <Skeleton class="size-4 rounded-md" data-sidebar="menu-skeleton-icon" />}
|
|
37
|
+
<Skeleton
|
|
38
|
+
class="h-4 max-w-(--skeleton-width) flex-1"
|
|
39
|
+
style={`--skeleton-width: ${skeletonWidth}`}
|
|
40
|
+
data-sidebar="menu-skeleton-text"
|
|
41
|
+
/>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
export interface SidebarMenuSubProps extends HTMLAttributes<"ul"> {}
|
|
6
|
+
type Props = SidebarMenuSubProps;
|
|
7
|
+
|
|
8
|
+
export const sidebarMenuSub = cv({
|
|
9
|
+
base: [
|
|
10
|
+
"border-sidebar-border mx-4.5 flex min-w-0 translate-x-px flex-col gap-5xs b-l px-2.5 py-6xs",
|
|
11
|
+
"group-data-[collapsible=icon]:hidden",
|
|
12
|
+
],
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const { class: className, ...rest } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<ul
|
|
19
|
+
class:list={[sidebarMenuSub(), className]}
|
|
20
|
+
data-sidebar="menu-sub"
|
|
21
|
+
{...rest}
|
|
22
|
+
data-slot="sidebar-menu-sub"
|
|
23
|
+
>
|
|
24
|
+
<slot />
|
|
25
|
+
</ul>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type VariantProps<T extends (...args: any) => any> = NonNullable<Parameters<T>[0]>;
|
|
6
|
+
|
|
7
|
+
export interface SidebarMenuSubButtonProps extends HTMLAttributes<"a">, VariantProps<typeof sidebarMenuSubButton> {
|
|
8
|
+
/**
|
|
9
|
+
* Whether the menu sub item is currently active
|
|
10
|
+
*/
|
|
11
|
+
isActive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
type Props = SidebarMenuSubButtonProps;
|
|
15
|
+
|
|
16
|
+
export const sidebarMenuSubButton = cv({
|
|
17
|
+
base: [
|
|
18
|
+
"text-sidebar-foreground ring-sidebar-outline",
|
|
19
|
+
"flex h-3xs min-w-0 -translate-x-px items-center gap-md overflow-hidden rounded-md px-2.5",
|
|
20
|
+
"outline-hidden",
|
|
21
|
+
"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
22
|
+
"focus-visible:ring-2",
|
|
23
|
+
"active:bg-sidebar-accent active:text-sidebar-accent-foreground",
|
|
24
|
+
"disabled:pointer-events-none disabled:op-50",
|
|
25
|
+
"aria-disabled:pointer-events-none aria-disabled:op-50",
|
|
26
|
+
"[&>svg]:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
|
|
27
|
+
"data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",
|
|
28
|
+
],
|
|
29
|
+
variants: {
|
|
30
|
+
size: {
|
|
31
|
+
sm: "text-sm",
|
|
32
|
+
md: "text-base",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
size: "md",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const { size, isActive = false, class: className, ...rest } = Astro.props;
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
<a
|
|
44
|
+
class:list={[sidebarMenuSubButton({ size }), className]}
|
|
45
|
+
data-sidebar="menu-sub-button"
|
|
46
|
+
data-size={size || "md"}
|
|
47
|
+
data-active={isActive}
|
|
48
|
+
{...rest}
|
|
49
|
+
data-slot="sidebar-menu-sub-button"
|
|
50
|
+
>
|
|
51
|
+
<slot />
|
|
52
|
+
</a>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
|
|
4
|
+
export interface SidebarMenuSubItemProps extends HTMLAttributes<"li"> {}
|
|
5
|
+
type Props = SidebarMenuSubItemProps;
|
|
6
|
+
|
|
7
|
+
const { class: className, ...rest } = Astro.props;
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
<li
|
|
11
|
+
class:list={["group/menu-sub-item relative", className]}
|
|
12
|
+
data-sidebar="menu-sub-item"
|
|
13
|
+
{...rest}
|
|
14
|
+
data-slot="sidebar-menu-sub-item"
|
|
15
|
+
>
|
|
16
|
+
<slot />
|
|
17
|
+
</li>
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
export interface SidebarProviderProps extends HTMLAttributes<"div"> {
|
|
6
|
+
/**
|
|
7
|
+
* Default open state of the sidebar
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
defaultOpen?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Keyboard shortcut to toggle the sidebar
|
|
13
|
+
* @default "b"
|
|
14
|
+
*/
|
|
15
|
+
keyboardShortcut?: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type Props = SidebarProviderProps;
|
|
19
|
+
|
|
20
|
+
export const sidebarProvider = cv({
|
|
21
|
+
base: [
|
|
22
|
+
"starwind-sidebar-provider",
|
|
23
|
+
"group/sidebar-wrapper flex min-h-svh w-full",
|
|
24
|
+
"has-data-[variant=inset]:bg-sidebar",
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
const {
|
|
29
|
+
defaultOpen = true,
|
|
30
|
+
keyboardShortcut = "b",
|
|
31
|
+
class: className,
|
|
32
|
+
style,
|
|
33
|
+
...rest
|
|
34
|
+
} = Astro.props;
|
|
35
|
+
|
|
36
|
+
const SIDEBAR_WIDTH = "18rem";
|
|
37
|
+
const SIDEBAR_WIDTH_ICON = "3.5rem";
|
|
38
|
+
|
|
39
|
+
// Parse style prop to extract CSS variable overrides
|
|
40
|
+
const styleObj = typeof style === "string" ? {} : ((style as Record<string, string>) ?? {});
|
|
41
|
+
const mergedStyle = {
|
|
42
|
+
"--sidebar-width": styleObj["--sidebar-width"] ?? SIDEBAR_WIDTH,
|
|
43
|
+
"--sidebar-width-icon": styleObj["--sidebar-width-icon"] ?? SIDEBAR_WIDTH_ICON,
|
|
44
|
+
...styleObj,
|
|
45
|
+
};
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
class:list={[sidebarProvider(), className]}
|
|
50
|
+
data-state={defaultOpen ? "expanded" : "collapsed"}
|
|
51
|
+
data-mobile-open="false"
|
|
52
|
+
data-keyboard-shortcut={keyboardShortcut}
|
|
53
|
+
style={mergedStyle}
|
|
54
|
+
{...rest}
|
|
55
|
+
data-slot="sidebar-provider"
|
|
56
|
+
>
|
|
57
|
+
<slot />
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
<script>
|
|
61
|
+
class SidebarController {
|
|
62
|
+
private provider: HTMLElement;
|
|
63
|
+
private boundKeyHandler: (e: KeyboardEvent) => void;
|
|
64
|
+
private boundResizeHandler: () => void;
|
|
65
|
+
private wasMobile: boolean = false;
|
|
66
|
+
|
|
67
|
+
constructor(provider: HTMLElement) {
|
|
68
|
+
this.provider = provider;
|
|
69
|
+
this.boundKeyHandler = this.handleKeydown.bind(this);
|
|
70
|
+
this.boundResizeHandler = this.handleResize.bind(this);
|
|
71
|
+
this.wasMobile = this.isMobile();
|
|
72
|
+
this.setupKeyboardShortcut();
|
|
73
|
+
this.setupCustomEvents();
|
|
74
|
+
this.setupResizeListener();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private handleKeydown(e: KeyboardEvent) {
|
|
78
|
+
// Skip if focus is in an editable element
|
|
79
|
+
const target = e.target as HTMLElement | null;
|
|
80
|
+
if (target) {
|
|
81
|
+
const tagName = target.tagName.toLowerCase();
|
|
82
|
+
if (
|
|
83
|
+
tagName === "input" ||
|
|
84
|
+
tagName === "textarea" ||
|
|
85
|
+
tagName === "select" ||
|
|
86
|
+
target.isContentEditable ||
|
|
87
|
+
target.closest("[contenteditable='true']")
|
|
88
|
+
) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const shortcut = this.provider.getAttribute("data-keyboard-shortcut") || "b";
|
|
94
|
+
if (e.key === shortcut && (e.metaKey || e.ctrlKey)) {
|
|
95
|
+
e.preventDefault();
|
|
96
|
+
this.toggle();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private setupKeyboardShortcut() {
|
|
101
|
+
document.removeEventListener("keydown", this.boundKeyHandler);
|
|
102
|
+
document.addEventListener("keydown", this.boundKeyHandler);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private setupCustomEvents() {
|
|
106
|
+
this.provider.addEventListener("sidebar:toggle", () => this.toggle());
|
|
107
|
+
this.provider.addEventListener("sidebar:open", () => this.setOpen(true));
|
|
108
|
+
this.provider.addEventListener("sidebar:close", () => this.setOpen(false));
|
|
109
|
+
this.provider.addEventListener("sidebar:toggle-mobile", () => this.toggleMobile());
|
|
110
|
+
this.provider.addEventListener("sidebar:open-mobile", () => this.setMobileOpen(true));
|
|
111
|
+
this.provider.addEventListener("sidebar:close-mobile", () => this.setMobileOpen(false));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private handleResize() {
|
|
115
|
+
const isMobileNow = this.isMobile();
|
|
116
|
+
// Close mobile sheet when transitioning from mobile to desktop
|
|
117
|
+
if (this.wasMobile && !isMobileNow) {
|
|
118
|
+
this.setMobileOpen(false);
|
|
119
|
+
}
|
|
120
|
+
this.wasMobile = isMobileNow;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private setupResizeListener() {
|
|
124
|
+
window.removeEventListener("resize", this.boundResizeHandler);
|
|
125
|
+
window.addEventListener("resize", this.boundResizeHandler);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
isMobile(): boolean {
|
|
129
|
+
// Check if desktop sidebar is hidden (has display: none from hidden class)
|
|
130
|
+
const desktopSidebar = this.provider.querySelector<HTMLElement>('[data-slot="sidebar"]');
|
|
131
|
+
if (!desktopSidebar) return false;
|
|
132
|
+
return getComputedStyle(desktopSidebar).display === "none";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
getState(): "expanded" | "collapsed" {
|
|
136
|
+
return this.provider.getAttribute("data-state") as "expanded" | "collapsed";
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
isOpen(): boolean {
|
|
140
|
+
return this.getState() === "expanded";
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
isMobileOpen(): boolean {
|
|
144
|
+
return this.provider.getAttribute("data-mobile-open") === "true";
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
toggle() {
|
|
148
|
+
if (this.isMobile()) {
|
|
149
|
+
this.toggleMobile();
|
|
150
|
+
} else {
|
|
151
|
+
this.setOpen(!this.isOpen());
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
setOpen(open: boolean) {
|
|
156
|
+
const state = open ? "expanded" : "collapsed";
|
|
157
|
+
this.provider.setAttribute("data-state", state);
|
|
158
|
+
this.provider.dispatchEvent(new CustomEvent("sidebar:change", { detail: { open, state } }));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
toggleMobile() {
|
|
162
|
+
// Check the actual dialog state instead of our tracked state
|
|
163
|
+
const mobileSheet = this.provider.querySelector<HTMLElement>(".starwind-sheet");
|
|
164
|
+
const dialogContent = mobileSheet?.querySelector<HTMLElement>(".starwind-dialog-content");
|
|
165
|
+
const isCurrentlyOpen = dialogContent?.dataset.state === "open";
|
|
166
|
+
|
|
167
|
+
this.setMobileOpen(!isCurrentlyOpen);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
setMobileOpen(open: boolean) {
|
|
171
|
+
this.provider.setAttribute("data-mobile-open", String(open));
|
|
172
|
+
|
|
173
|
+
// Find the mobile sidebar Sheet and use Dialog's programmatic API
|
|
174
|
+
const mobileSheet = this.provider.querySelector<HTMLElement>(".starwind-sheet");
|
|
175
|
+
if (mobileSheet) {
|
|
176
|
+
const eventName = open ? "dialog:open" : "dialog:close";
|
|
177
|
+
mobileSheet.dispatchEvent(new CustomEvent(eventName));
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
this.provider.dispatchEvent(new CustomEvent("sidebar:mobile-change", { detail: { open } }));
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
destroy() {
|
|
184
|
+
document.removeEventListener("keydown", this.boundKeyHandler);
|
|
185
|
+
window.removeEventListener("resize", this.boundResizeHandler);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const sidebarInstances = new WeakMap<HTMLElement, SidebarController>();
|
|
190
|
+
const trackedProviders = new Set<HTMLElement>();
|
|
191
|
+
|
|
192
|
+
const cleanupSidebars = () => {
|
|
193
|
+
// Destroy controllers for providers no longer in DOM
|
|
194
|
+
for (const provider of trackedProviders) {
|
|
195
|
+
if (!document.contains(provider)) {
|
|
196
|
+
sidebarInstances.get(provider)?.destroy();
|
|
197
|
+
trackedProviders.delete(provider);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const setupSidebars = () => {
|
|
203
|
+
document.querySelectorAll<HTMLElement>(".starwind-sidebar-provider").forEach((provider) => {
|
|
204
|
+
if (!sidebarInstances.has(provider)) {
|
|
205
|
+
sidebarInstances.set(provider, new SidebarController(provider));
|
|
206
|
+
trackedProviders.add(provider);
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
setupSidebars();
|
|
212
|
+
document.addEventListener("astro:before-swap", cleanupSidebars);
|
|
213
|
+
document.addEventListener("astro:after-swap", setupSidebars);
|
|
214
|
+
document.addEventListener("starwind:init", setupSidebars);
|
|
215
|
+
</script>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
export interface SidebarRailProps extends HTMLAttributes<"button"> {}
|
|
6
|
+
type Props = SidebarRailProps;
|
|
7
|
+
|
|
8
|
+
export const sidebarRail = cv({
|
|
9
|
+
base: [
|
|
10
|
+
"starwind-sidebar-rail",
|
|
11
|
+
"absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear sm:flex",
|
|
12
|
+
"group-data-[side=left]:-right-4 group-data-[side=right]:left-0",
|
|
13
|
+
"after:absolute after:inset-y-0 after:left-1/2 after:w-6xs",
|
|
14
|
+
"hover:after:bg-sidebar-border",
|
|
15
|
+
"in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",
|
|
16
|
+
"[[data-side=left][data-state=collapsed]_&]:cursor-e-resize",
|
|
17
|
+
"[[data-side=right][data-state=collapsed]_&]:cursor-w-resize",
|
|
18
|
+
"hover:group-data-[collapsible=offcanvas]:bg-sidebar",
|
|
19
|
+
"group-data-[collapsible=offcanvas]:translate-x-0",
|
|
20
|
+
"group-data-[collapsible=offcanvas]:after:left-full",
|
|
21
|
+
"[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",
|
|
22
|
+
"[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",
|
|
23
|
+
],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const { class: className, ...rest } = Astro.props;
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<button
|
|
30
|
+
type="button"
|
|
31
|
+
class:list={[sidebarRail(), className]}
|
|
32
|
+
data-sidebar="rail"
|
|
33
|
+
aria-label="Toggle Sidebar"
|
|
34
|
+
tabindex="-1"
|
|
35
|
+
{...rest}
|
|
36
|
+
data-slot="sidebar-rail"></button>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
class SidebarRailHandler {
|
|
40
|
+
private rail: HTMLElement;
|
|
41
|
+
private provider: HTMLElement | null;
|
|
42
|
+
|
|
43
|
+
constructor(rail: HTMLElement) {
|
|
44
|
+
this.rail = rail;
|
|
45
|
+
this.provider = rail.closest<HTMLElement>('[data-slot="sidebar-provider"]');
|
|
46
|
+
this.init();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private init() {
|
|
50
|
+
this.rail.addEventListener("click", this.handleClick.bind(this));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private handleClick() {
|
|
54
|
+
if (this.provider) {
|
|
55
|
+
this.provider.dispatchEvent(new CustomEvent("sidebar:toggle"));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const railInstances = new WeakMap<HTMLElement, SidebarRailHandler>();
|
|
61
|
+
|
|
62
|
+
const setupSidebarRails = () => {
|
|
63
|
+
document.querySelectorAll<HTMLElement>(".starwind-sidebar-rail").forEach((rail) => {
|
|
64
|
+
if (railInstances.has(rail)) return;
|
|
65
|
+
railInstances.set(rail, new SidebarRailHandler(rail));
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
setupSidebarRails();
|
|
70
|
+
document.addEventListener("astro:after-swap", setupSidebarRails);
|
|
71
|
+
document.addEventListener("starwind:init", setupSidebarRails);
|
|
72
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ComponentProps } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
// eslint-disable-next-line typescript/consistent-type-imports
|
|
6
|
+
import Separator from "../separator/Separator.astro";
|
|
7
|
+
|
|
8
|
+
const sidebarSeparator = cv({
|
|
9
|
+
base: "bg-sidebar-border mx-5xs w-auto",
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export interface SidebarSeparatorProps extends ComponentProps<typeof Separator> {}
|
|
13
|
+
type Props = SidebarSeparatorProps;
|
|
14
|
+
|
|
15
|
+
const { orientation = "horizontal", class: className, ...rest } = Astro.props;
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
<Separator
|
|
19
|
+
orientation={orientation}
|
|
20
|
+
class:list={[sidebarSeparator(), className]}
|
|
21
|
+
data-sidebar="separator"
|
|
22
|
+
{...rest}
|
|
23
|
+
data-slot="sidebar-separator"
|
|
24
|
+
/>
|
|
25
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { ComponentProps } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
import IconPanelLeft from "~icons/lucide/panel-left";
|
|
5
|
+
|
|
6
|
+
const sidebarTrigger = cv({
|
|
7
|
+
base: "starwind-sidebar-trigger",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
// eslint-disable-next-line typescript/consistent-type-imports
|
|
11
|
+
import Button from "../button/Button.astro";
|
|
12
|
+
|
|
13
|
+
export interface SidebarTriggerProps extends ComponentProps<typeof Button> {}
|
|
14
|
+
type Props = SidebarTriggerProps;
|
|
15
|
+
|
|
16
|
+
const { class: className, size = "icon-sm", variant = "ghost", ...rest } = Astro.props;
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
<Button
|
|
20
|
+
variant={variant}
|
|
21
|
+
size={size}
|
|
22
|
+
class:list={[sidebarTrigger(), className]}
|
|
23
|
+
data-sidebar="trigger"
|
|
24
|
+
aria-label="Toggle Sidebar"
|
|
25
|
+
{...rest}
|
|
26
|
+
data-slot="sidebar-trigger"
|
|
27
|
+
>
|
|
28
|
+
<slot name="icon">
|
|
29
|
+
<IconPanelLeft />
|
|
30
|
+
</slot>
|
|
31
|
+
<span class="sr-only">Toggle Sidebar</span>
|
|
32
|
+
</Button>
|
|
33
|
+
|
|
34
|
+
<script>
|
|
35
|
+
class SidebarTriggerHandler {
|
|
36
|
+
private trigger: HTMLElement;
|
|
37
|
+
private provider: HTMLElement | null;
|
|
38
|
+
|
|
39
|
+
constructor(trigger: HTMLElement) {
|
|
40
|
+
this.trigger = trigger;
|
|
41
|
+
this.provider = trigger.closest<HTMLElement>('[data-slot="sidebar-provider"]');
|
|
42
|
+
this.init();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private init() {
|
|
46
|
+
this.trigger.addEventListener("click", this.handleClick.bind(this));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
private handleClick() {
|
|
50
|
+
if (this.provider) {
|
|
51
|
+
this.provider.dispatchEvent(new CustomEvent("sidebar:toggle"));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const triggerInstances = new WeakMap<HTMLElement, SidebarTriggerHandler>();
|
|
57
|
+
|
|
58
|
+
const setupSidebarTriggers = () => {
|
|
59
|
+
document.querySelectorAll<HTMLElement>(".starwind-sidebar-trigger").forEach((trigger) => {
|
|
60
|
+
if (triggerInstances.has(trigger)) return;
|
|
61
|
+
triggerInstances.set(trigger, new SidebarTriggerHandler(trigger));
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
setupSidebarTriggers();
|
|
66
|
+
document.addEventListener("astro:after-swap", setupSidebarTriggers);
|
|
67
|
+
document.addEventListener("starwind:init", setupSidebarTriggers);
|
|
68
|
+
</script>
|
|
69
|
+
|
|
@@ -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
|
+
const { class: className, ...rest } = Astro.props;
|
|
8
|
+
|
|
9
|
+
export const skeleton = cv({
|
|
10
|
+
base: "bg-muted animate-pulse rounded-md",
|
|
11
|
+
});
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<div class:list={[skeleton(), className]} {...rest} data-slot="skeleton"></div>
|