@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,162 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
type Props = HTMLAttributes<"fieldset"> & {
|
|
6
|
+
/**
|
|
7
|
+
* Value for the radio group
|
|
8
|
+
*/
|
|
9
|
+
value?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Default value for the radio group
|
|
12
|
+
*/
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Legend for the radio group
|
|
16
|
+
*/
|
|
17
|
+
legend?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the radio group is disabled
|
|
20
|
+
*/
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Orientation of the radio group
|
|
24
|
+
*/
|
|
25
|
+
orientation?: "horizontal" | "vertical";
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const radioGroup = cv({
|
|
29
|
+
base: "starwind-radio-group disabled:cursor-not-allowed disabled:op-70",
|
|
30
|
+
variants: {
|
|
31
|
+
orientation: {
|
|
32
|
+
vertical: "grid gap-4xs",
|
|
33
|
+
horizontal: "flex flex-row items-center gap-4xs",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: {
|
|
37
|
+
orientation: "vertical",
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const {
|
|
42
|
+
class: className,
|
|
43
|
+
value,
|
|
44
|
+
defaultValue,
|
|
45
|
+
legend,
|
|
46
|
+
disabled = false,
|
|
47
|
+
orientation = "vertical",
|
|
48
|
+
...rest
|
|
49
|
+
} = Astro.props;
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<fieldset
|
|
53
|
+
class:list={[radioGroup({ orientation, className })]}
|
|
54
|
+
data-value={value || defaultValue}
|
|
55
|
+
disabled={disabled}
|
|
56
|
+
{...rest}
|
|
57
|
+
data-slot="radio-group"
|
|
58
|
+
>
|
|
59
|
+
{legend && <legend class="sr-only">{legend}</legend>}
|
|
60
|
+
<slot />
|
|
61
|
+
</fieldset>
|
|
62
|
+
|
|
63
|
+
<script>
|
|
64
|
+
import type { RadioGroupChangeEvent } from "./RadioGroupTypes";
|
|
65
|
+
|
|
66
|
+
class RadioGroupHandler {
|
|
67
|
+
private radioGroup: HTMLFieldSetElement;
|
|
68
|
+
private radioInputs: NodeListOf<HTMLInputElement> | undefined;
|
|
69
|
+
private radioGroupId: string;
|
|
70
|
+
|
|
71
|
+
constructor(radioGroup: HTMLFieldSetElement, idx: number) {
|
|
72
|
+
this.radioGroup = radioGroup;
|
|
73
|
+
this.radioGroupId = radioGroup.id || `starwind-radio-group-${idx}`;
|
|
74
|
+
this.radioInputs = radioGroup.querySelectorAll<HTMLInputElement>('input[type="radio"]');
|
|
75
|
+
this.init();
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private init() {
|
|
79
|
+
// Initialize checked state based on data-value
|
|
80
|
+
this.syncWithDataValue();
|
|
81
|
+
|
|
82
|
+
// Setup event listeners
|
|
83
|
+
this.setupEvents();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private syncWithDataValue() {
|
|
87
|
+
const initialValue = this.radioGroup.dataset.value;
|
|
88
|
+
if (!initialValue || !this.radioInputs) return;
|
|
89
|
+
|
|
90
|
+
// Find the radio input with the matching value and check it
|
|
91
|
+
this.radioInputs.forEach((input) => {
|
|
92
|
+
if (input.value === initialValue) {
|
|
93
|
+
input.checked = true;
|
|
94
|
+
} else {
|
|
95
|
+
input.checked = false;
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
private setupEvents() {
|
|
101
|
+
// Listen for changes to update the fieldset's data-value attribute
|
|
102
|
+
this.radioGroup.addEventListener("change", this.handleChange.bind(this));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
private handleChange(e: Event) {
|
|
106
|
+
const target = e.target as HTMLInputElement;
|
|
107
|
+
// console.log("target", target);
|
|
108
|
+
if (target.type !== "radio") return;
|
|
109
|
+
|
|
110
|
+
// Update the data-value attribute
|
|
111
|
+
this.radioGroup.dataset.value = target.value;
|
|
112
|
+
|
|
113
|
+
// Ensure all other radio buttons in the group are unchecked
|
|
114
|
+
if (this.radioInputs) {
|
|
115
|
+
this.radioInputs.forEach((radio) => {
|
|
116
|
+
if (radio !== target) {
|
|
117
|
+
radio.checked = false;
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Explicitly mark the clicked radio as checked
|
|
123
|
+
target.checked = true;
|
|
124
|
+
|
|
125
|
+
// Dispatch custom event for external listeners
|
|
126
|
+
this.dispatchChangeEvent(target.value);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private dispatchChangeEvent(value: string) {
|
|
130
|
+
const event = new CustomEvent<RadioGroupChangeEvent["detail"]>("starwind:value-change", {
|
|
131
|
+
bubbles: true,
|
|
132
|
+
detail: {
|
|
133
|
+
value: value,
|
|
134
|
+
radioGroupId: this.radioGroupId,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
this.radioGroup.dispatchEvent(event);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Store instances in a WeakMap to avoid memory leaks
|
|
142
|
+
const radioGroupInstances = new WeakMap<HTMLElement, RadioGroupHandler>();
|
|
143
|
+
let radioGroupCounter = 0;
|
|
144
|
+
|
|
145
|
+
const setupRadioGroups = () => {
|
|
146
|
+
document
|
|
147
|
+
.querySelectorAll<HTMLFieldSetElement>(".starwind-radio-group")
|
|
148
|
+
.forEach((radioGroup) => {
|
|
149
|
+
if (!radioGroupInstances.has(radioGroup)) {
|
|
150
|
+
radioGroupInstances.set(
|
|
151
|
+
radioGroup,
|
|
152
|
+
new RadioGroupHandler(radioGroup, radioGroupCounter++),
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
// Initialize on page load and after Astro view transitions
|
|
159
|
+
setupRadioGroups();
|
|
160
|
+
document.addEventListener("astro:after-swap", setupRadioGroups);
|
|
161
|
+
document.addEventListener("starwind:init", setupRadioGroups);
|
|
162
|
+
</script>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
import IconCircleDot from "~icons/lucide/circle-dot";
|
|
5
|
+
|
|
6
|
+
type VariantProps<T extends (...args: any) => any> = NonNullable<Parameters<T>[0]>;
|
|
7
|
+
|
|
8
|
+
type Props = HTMLAttributes<"input"> &
|
|
9
|
+
VariantProps<typeof radioWrapper> &
|
|
10
|
+
VariantProps<typeof radioControl> & {
|
|
11
|
+
/**
|
|
12
|
+
* Value of the radio item
|
|
13
|
+
*/
|
|
14
|
+
value: string;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the radio is disabled
|
|
17
|
+
*/
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Optional ID for the radio item
|
|
21
|
+
*/
|
|
22
|
+
id?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Name to group radio inputs
|
|
25
|
+
*/
|
|
26
|
+
name?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Whether the radio is checked (only for initial state)
|
|
29
|
+
*/
|
|
30
|
+
checked?: boolean;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const radioWrapper = cv({
|
|
34
|
+
base: "relative isolate flex shrink-0",
|
|
35
|
+
variants: {
|
|
36
|
+
size: {
|
|
37
|
+
sm: "size-4",
|
|
38
|
+
md: "size-5",
|
|
39
|
+
lg: "size-6",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
size: "md",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const radioItem = cv({
|
|
48
|
+
base: [
|
|
49
|
+
"starwind-radio-item peer z-10 h-full w-full",
|
|
50
|
+
"absolute inset-0 cursor-pointer op-0 outline-none focus:outline-none focus-visible:outline-none",
|
|
51
|
+
"disabled:cursor-not-allowed",
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const radioControl = cv({
|
|
56
|
+
base: [
|
|
57
|
+
"starwind-radio-control",
|
|
58
|
+
"border-input bg-background dark:bg-input/30",
|
|
59
|
+
"outline-none peer-focus-visible:ring-3",
|
|
60
|
+
"absolute inset-0 rounded-full b shadow-xs",
|
|
61
|
+
"transition-[color,box-shadow] peer-checked:[&>svg]:op-100",
|
|
62
|
+
"peer-disabled:cursor-not-allowed peer-disabled:op-50",
|
|
63
|
+
"peer-aria-invalid:border-error peer-focus-visible:peer-aria-invalid:ring-error/40",
|
|
64
|
+
"flex items-center justify-center",
|
|
65
|
+
],
|
|
66
|
+
variants: {
|
|
67
|
+
variant: {
|
|
68
|
+
default:
|
|
69
|
+
"peer-checked:border-foreground [&>svg]:fill-foreground peer-focus-visible:ring-outline/50",
|
|
70
|
+
primary:
|
|
71
|
+
"peer-checked:border-primary [&>svg]:fill-primary peer-focus-visible:ring-primary/50",
|
|
72
|
+
secondary:
|
|
73
|
+
"peer-checked:border-secondary [&>svg]:fill-secondary peer-focus-visible:ring-secondary/50",
|
|
74
|
+
info: "peer-checked:border-info [&>svg]:fill-info peer-focus-visible:ring-info/50",
|
|
75
|
+
success:
|
|
76
|
+
"peer-checked:border-success [&>svg]:fill-success peer-focus-visible:ring-success/50",
|
|
77
|
+
warning:
|
|
78
|
+
"peer-checked:border-warning [&>svg]:fill-warning peer-focus-visible:ring-warning/50",
|
|
79
|
+
error: "peer-checked:border-error [&>svg]:fill-error peer-focus-visible:ring-error/50",
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
defaultVariants: {
|
|
83
|
+
variant: "primary",
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export const radioIndicator = cv({
|
|
88
|
+
base: ["starwind-radio-indicator", "op-0 transition-op"],
|
|
89
|
+
variants: {
|
|
90
|
+
size: {
|
|
91
|
+
sm: "size-2",
|
|
92
|
+
md: "size-3",
|
|
93
|
+
lg: "size-4",
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
defaultVariants: {
|
|
97
|
+
size: "md",
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const {
|
|
102
|
+
value,
|
|
103
|
+
name,
|
|
104
|
+
disabled = false,
|
|
105
|
+
checked = false,
|
|
106
|
+
id,
|
|
107
|
+
class: className,
|
|
108
|
+
size = "md",
|
|
109
|
+
variant = "default",
|
|
110
|
+
...rest
|
|
111
|
+
} = Astro.props;
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
<div class={radioWrapper({ size })} data-slot="radio-group-item-wrapper">
|
|
115
|
+
<input
|
|
116
|
+
type="radio"
|
|
117
|
+
class={radioItem()}
|
|
118
|
+
name={name}
|
|
119
|
+
id={id}
|
|
120
|
+
value={value}
|
|
121
|
+
checked={checked}
|
|
122
|
+
disabled={disabled}
|
|
123
|
+
{...rest}
|
|
124
|
+
data-slot="radio-group-item"
|
|
125
|
+
/>
|
|
126
|
+
<span class:list={[radioControl({ variant }), className]} data-slot="radio-group-item-control">
|
|
127
|
+
<slot name="icon">
|
|
128
|
+
<span class={radioIndicator({ size })}>
|
|
129
|
+
<IconCircleDot />
|
|
130
|
+
</span>
|
|
131
|
+
</slot>
|
|
132
|
+
</span>
|
|
133
|
+
</div>
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { cv } from "css-variants";
|
|
4
|
+
|
|
5
|
+
import type { button } from "../button/Button.astro";
|
|
6
|
+
import Button from "../button/Button.astro";
|
|
7
|
+
|
|
8
|
+
export interface SectionAction {
|
|
9
|
+
text: string;
|
|
10
|
+
href: string;
|
|
11
|
+
variant?: NonNullable<Parameters<typeof button>[0]>["variant"];
|
|
12
|
+
icon?: any;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface SectionProps extends HTMLAttributes<"section">, NonNullable<Parameters<typeof sectionVariants>[0]> {
|
|
16
|
+
/** Main title text */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Description text */
|
|
19
|
+
description?: string;
|
|
20
|
+
/** Action buttons */
|
|
21
|
+
actions?: SectionAction[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type Props = SectionProps;
|
|
25
|
+
|
|
26
|
+
const sectionVariants = cv({
|
|
27
|
+
base: "container py-5xl",
|
|
28
|
+
|
|
29
|
+
variants: {
|
|
30
|
+
orientation: {
|
|
31
|
+
vertical: "flex flex-col gap-4xl",
|
|
32
|
+
horizontal: "flex flex-col gap-3xl items-center lg:grid lg:grid-cols-2 lg:items-center lg:gap-5xl",
|
|
33
|
+
},
|
|
34
|
+
alignment: {
|
|
35
|
+
left: "text-start items-start",
|
|
36
|
+
center: "text-center items-center",
|
|
37
|
+
right: "text-end items-end",
|
|
38
|
+
},
|
|
39
|
+
inverted: {
|
|
40
|
+
true: "",
|
|
41
|
+
false: "",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
compoundVariants: [
|
|
45
|
+
{
|
|
46
|
+
orientation: "vertical",
|
|
47
|
+
inverted: true,
|
|
48
|
+
className: "flex-col-reverse",
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
orientation: "vertical",
|
|
52
|
+
inverted: false,
|
|
53
|
+
className: "flex-col",
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
orientation: "horizontal",
|
|
57
|
+
inverted: false,
|
|
58
|
+
className: "lg:[&_.section-content]:order-1 lg:[&_.section-image]:order-2",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
orientation: "horizontal",
|
|
62
|
+
inverted: true,
|
|
63
|
+
className: "lg:[&_.section-image]:order-1 lg:[&_.section-content]:order-2",
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
orientation: "horizontal",
|
|
67
|
+
className: "[&_.section-content]:text-start [&_.section-content]:items-start lg:text-start lg:items-start",
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
defaultVariants: {
|
|
71
|
+
orientation: "vertical",
|
|
72
|
+
alignment: "center",
|
|
73
|
+
inverted: false,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
const {
|
|
78
|
+
title,
|
|
79
|
+
description,
|
|
80
|
+
actions = [],
|
|
81
|
+
orientation = "vertical",
|
|
82
|
+
alignment = "center",
|
|
83
|
+
inverted = false,
|
|
84
|
+
class: className,
|
|
85
|
+
...rest
|
|
86
|
+
} = Astro.props;
|
|
87
|
+
|
|
88
|
+
const effectiveAlignment = orientation === "horizontal" ? "left" : alignment;
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
<section class="relative w-full overflow-hidden" {...rest}>
|
|
92
|
+
<div class="absolute inset-0 -z-10" aria-hidden="true">
|
|
93
|
+
<slot name="bg" />
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<div class:list={[sectionVariants({ orientation, alignment, inverted }), className]}>
|
|
97
|
+
<div
|
|
98
|
+
class:list={[
|
|
99
|
+
"section-content flex flex-col w-full",
|
|
100
|
+
orientation === "vertical" && [
|
|
101
|
+
effectiveAlignment === "center" && "mx-auto",
|
|
102
|
+
effectiveAlignment === "left" && "mr-auto",
|
|
103
|
+
effectiveAlignment === "right" && "ml-auto",
|
|
104
|
+
],
|
|
105
|
+
effectiveAlignment === "center" && "text-center items-center",
|
|
106
|
+
effectiveAlignment === "left" && "text-start items-start",
|
|
107
|
+
effectiveAlignment === "right" && "text-end items-end",
|
|
108
|
+
]}
|
|
109
|
+
data-slot="content"
|
|
110
|
+
>
|
|
111
|
+
{
|
|
112
|
+
title && (
|
|
113
|
+
<h2 class="font-heading text-4xl font-bold tracking-tight text-pretty lg:text-5xl xl:text-6xl">
|
|
114
|
+
{title}
|
|
115
|
+
</h2>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
{
|
|
119
|
+
description && (
|
|
120
|
+
<p class="text-muted-foreground mt-2xl text-pretty lg:text-lg">
|
|
121
|
+
{description}
|
|
122
|
+
</p>
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
{
|
|
126
|
+
actions.length > 0 && (
|
|
127
|
+
<div
|
|
128
|
+
class:list={[
|
|
129
|
+
"mt-3xl flex w-full flex-wrap gap-3xs md:w-fit",
|
|
130
|
+
effectiveAlignment === "center" && "justify-center mx-auto",
|
|
131
|
+
effectiveAlignment === "left" && "justify-start",
|
|
132
|
+
effectiveAlignment === "right" && "justify-end md:ml-auto",
|
|
133
|
+
]}
|
|
134
|
+
>
|
|
135
|
+
{actions.map(({ text, href, variant, icon: Icon }) => (
|
|
136
|
+
<Button variant={variant} class="group w-full md:w-auto" href={href}>
|
|
137
|
+
{text}
|
|
138
|
+
{Icon && (
|
|
139
|
+
<Icon class="transition-transform group-hover:translate-x-5xs" />
|
|
140
|
+
)}
|
|
141
|
+
</Button>
|
|
142
|
+
))}
|
|
143
|
+
</div>
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<div class="section-image w-full">
|
|
149
|
+
<slot />
|
|
150
|
+
</div>
|
|
151
|
+
|
|
152
|
+
{Astro.slots.has("image") && (
|
|
153
|
+
<div
|
|
154
|
+
class:list={[
|
|
155
|
+
"section-image w-full flex",
|
|
156
|
+
effectiveAlignment === "center" && "justify-center",
|
|
157
|
+
effectiveAlignment === "left" && "justify-start",
|
|
158
|
+
effectiveAlignment === "right" && "justify-end",
|
|
159
|
+
]}
|
|
160
|
+
data-slot="image"
|
|
161
|
+
>
|
|
162
|
+
<slot name="image" />
|
|
163
|
+
</div>
|
|
164
|
+
)}
|
|
165
|
+
</div>
|
|
166
|
+
</section>
|
|
167
|
+
|