fulldev-ui 0.13.0 → 0.14.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/CHANGELOG.md +16 -0
- package/package.json +3 -3
- package/public/r/carousel.json +6 -6
- package/public/r/navigation-menu.json +2 -2
- package/public/r/registry.json +2 -2
- package/public/r/reviews-3.json +1 -1
- package/registry.json +2 -2
- package/src/components/blocks/reviews-3.astro +4 -1
- package/src/components/ui/carousel/carousel-content.astro +13 -11
- package/src/components/ui/carousel/carousel-item.astro +5 -2
- package/src/components/ui/carousel/carousel.astro +123 -15
- package/src/components/ui/carousel/index.ts +5 -1
- package/src/components/ui/navigation-menu/navigation-menu-trigger-style.ts +1 -1
- package/src/components/ui/navigation-menu/navigation-menu-trigger.astro +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Fulldev UI
|
|
2
2
|
|
|
3
|
+
## 0.14.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#202](https://github.com/fulldotdev/ui/pull/202) [`30b1949`](https://github.com/fulldotdev/ui/commit/30b19499edf55ba3ae15490562334f50476f21c0) Thanks [@silveltman](https://github.com/silveltman)! - Match Navigation Menu trigger styling and chevron rotation to Data Slot's data-state attribute, while retaining compatibility with data-open and data-popup-open.
|
|
8
|
+
|
|
9
|
+
## 0.14.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#200](https://github.com/fulldotdev/ui/pull/200) [`cc38ebd`](https://github.com/fulldotdev/ui/commit/cc38ebd7cd6e00f12ed1be5cd32028e55ef48bd8) Thanks [@silveltman](https://github.com/silveltman)! - Restore the Embla-powered Carousel and shadcn-style composition, responsive slide widths and `opts` API. Use the vanilla `embla-carousel` 8.6.0 package without React. Other interactive components continue to use Data Slot directly.
|
|
14
|
+
|
|
15
|
+
This replaces the single-slide Carousel introduced in 0.13.0. Reinstall the registry component. Replace `defaultIndex`, `drag` and `loop` with `opts={{ startIndex, watchDrag, loop }}`; dragging is enabled by default. Restore `CarouselApi`, `CarouselOptions` and `CarouselPlugin` types and `carousel:init` / `carousel:select` events. Listen to their `detail.api` for programmatic navigation instead of `carousel:set`. `CarouselContent` classes apply to the inner track again; use matching negative track margins and slide padding for spacing.
|
|
16
|
+
|
|
17
|
+
Visible slide links stay interactive, and Embla handles focus scrolling, resizing and slide positions. Instances and event handlers are cleaned up before Astro page swaps. No observers override another library's accessibility state.
|
|
18
|
+
|
|
3
19
|
## 0.13.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fulldev-ui",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.14.1",
|
|
5
5
|
"description": "Open-source Astro UI components and blocks",
|
|
6
6
|
"homepage": "https://ui.full.dev",
|
|
7
7
|
"bugs": "https://github.com/fulldotdev/ui/issues",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"@astrojs/sitemap": "^3.7.3",
|
|
53
53
|
"@data-slot/accordion": "^1.0.2",
|
|
54
54
|
"@data-slot/alert-dialog": "^1.0.2",
|
|
55
|
-
"@data-slot/carousel": "^1.0.2",
|
|
56
55
|
"@data-slot/collapsible": "^1.0.2",
|
|
57
56
|
"@data-slot/combobox": "^1.0.2",
|
|
58
57
|
"@data-slot/command": "^1.0.2",
|
|
@@ -91,7 +90,8 @@
|
|
|
91
90
|
"tailwind-merge": "^3.6.0",
|
|
92
91
|
"tailwindcss": "^4.3.2",
|
|
93
92
|
"tw-animate-css": "^1.4.0",
|
|
94
|
-
"typescript": "^6.0.3"
|
|
93
|
+
"typescript": "^6.0.3",
|
|
94
|
+
"embla-carousel": "8.6.0"
|
|
95
95
|
},
|
|
96
96
|
"devDependencies": {
|
|
97
97
|
"@argos-ci/playwright": "^7.6.0",
|
package/public/r/carousel.json
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
3
|
"name": "carousel",
|
|
4
4
|
"title": "Carousel",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "A carousel with motion, swipe and responsive slides built using Embla.",
|
|
6
6
|
"dependencies": [
|
|
7
|
-
"
|
|
7
|
+
"embla-carousel@8.6.0",
|
|
8
8
|
"@lucide/astro"
|
|
9
9
|
],
|
|
10
10
|
"registryDependencies": [
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
"files": [
|
|
14
14
|
{
|
|
15
15
|
"path": "src/components/ui/carousel/carousel.astro",
|
|
16
|
-
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Props = HTMLAttributes<\"div\"> & {\n
|
|
16
|
+
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport type { EmblaOptionsType } from \"embla-carousel\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Props = HTMLAttributes<\"div\"> & {\n opts?: EmblaOptionsType\n orientation?: \"horizontal\" | \"vertical\"\n}\n\nconst {\n class: className,\n opts,\n orientation = opts?.axis === \"y\" ? \"vertical\" : \"horizontal\",\n ...props\n} = Astro.props\n\nconst resolvedOpts: EmblaOptionsType = {\n ...opts,\n axis: orientation === \"horizontal\" ? \"x\" : \"y\",\n}\n---\n\n<div\n data-slot=\"carousel\"\n data-orientation={orientation}\n data-carousel-options={JSON.stringify(resolvedOpts)}\n class={cn(\"group/carousel relative\", className)}\n role=\"region\"\n aria-roledescription=\"carousel\"\n {...props}\n>\n <slot />\n</div>\n\n<script>\n import EmblaCarousel, {\n type EmblaCarouselType,\n type EmblaOptionsType,\n } from \"embla-carousel\"\n\n type CarouselRoot = HTMLElement & {\n __fulldevCarouselApi?: EmblaCarouselType\n }\n\n const instances = new Map<CarouselRoot, () => void>()\n const initialize = () => {\n for (const root of document.querySelectorAll<CarouselRoot>(\n '[data-slot=\"carousel\"]'\n )) {\n if (instances.has(root)) continue\n const viewport = root.querySelector<HTMLElement>(\n '[data-slot=\"carousel-content\"]'\n )\n if (!viewport) continue\n const opts: EmblaOptionsType = JSON.parse(\n root.dataset.carouselOptions || \"{}\"\n )\n const api = EmblaCarousel(viewport, opts)\n root.__fulldevCarouselApi = api\n const previous = root.querySelectorAll<HTMLButtonElement>(\n '[data-slot=\"carousel-previous\"]'\n )\n const next = root.querySelectorAll<HTMLButtonElement>(\n '[data-slot=\"carousel-next\"]'\n )\n const emit = (type: \"carousel:init\" | \"carousel:select\") => {\n root.dispatchEvent(\n new CustomEvent(type, {\n detail: {\n api,\n canScrollPrev: api.canScrollPrev(),\n canScrollNext: api.canScrollNext(),\n selectedScrollSnap: api.selectedScrollSnap(),\n scrollSnapList: api.scrollSnapList(),\n },\n })\n )\n }\n const sync = () => {\n root.dataset.canScrollPrev = String(api.canScrollPrev())\n root.dataset.canScrollNext = String(api.canScrollNext())\n root.dataset.selectedScrollSnap = String(api.selectedScrollSnap())\n for (const button of previous)\n if (button.dataset.manualDisabled !== \"true\")\n button.disabled = !api.canScrollPrev()\n for (const button of next)\n if (button.dataset.manualDisabled !== \"true\")\n button.disabled = !api.canScrollNext()\n emit(\"carousel:select\")\n }\n const jump = () =>\n window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches\n const onPrevious = () => api.scrollPrev(jump())\n const onNext = () => api.scrollNext(jump())\n const onKeyDown = (event: KeyboardEvent) => {\n const target = event.target\n if (\n event.defaultPrevented ||\n !(target instanceof Element) ||\n target.closest('[data-slot=\"carousel\"]') !== root ||\n target.closest(\n 'input, textarea, select, [contenteditable]:not([contenteditable=\"false\"])'\n )\n )\n return\n const vertical = root.dataset.orientation === \"vertical\"\n switch (event.key) {\n case vertical ? \"ArrowUp\" : \"ArrowLeft\":\n onPrevious()\n break\n case vertical ? \"ArrowDown\" : \"ArrowRight\":\n onNext()\n break\n case \"Home\":\n api.scrollTo(0, jump())\n break\n case \"End\":\n api.scrollTo(api.scrollSnapList().length - 1, jump())\n break\n default:\n return\n }\n event.preventDefault()\n }\n for (const button of previous)\n button.addEventListener(\"click\", onPrevious)\n for (const button of next) button.addEventListener(\"click\", onNext)\n root.addEventListener(\"keydown\", onKeyDown)\n api.on(\"select\", sync)\n api.on(\"reInit\", sync)\n sync()\n const frame = requestAnimationFrame(() => emit(\"carousel:init\"))\n instances.set(root, () => {\n cancelAnimationFrame(frame)\n for (const button of previous)\n button.removeEventListener(\"click\", onPrevious)\n for (const button of next) button.removeEventListener(\"click\", onNext)\n root.removeEventListener(\"keydown\", onKeyDown)\n api.off(\"select\", sync)\n api.off(\"reInit\", sync)\n api.destroy()\n delete root.__fulldevCarouselApi\n })\n }\n }\n initialize()\n document.addEventListener(\"astro:page-load\", initialize)\n document.addEventListener(\"astro:before-swap\", () => {\n for (const cleanup of instances.values()) cleanup()\n instances.clear()\n })\n</script>\n",
|
|
17
17
|
"type": "registry:ui"
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
"path": "src/components/ui/carousel/carousel-content.astro",
|
|
21
|
-
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Props = HTMLAttributes<\"div\">\n\nconst { class: className, ...props } = Astro.props\n---\n\n<div\n data-slot=\"carousel-
|
|
21
|
+
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Props = HTMLAttributes<\"div\">\n\nconst { class: className, ...props } = Astro.props\n---\n\n<div class=\"overflow-hidden\" data-slot=\"carousel-content\">\n <div\n data-slot=\"carousel-container\"\n class={cn(\n \"flex [touch-action:pan-y_pinch-zoom]\",\n \"group-data-[orientation=vertical]/carousel:-mt-4 group-data-[orientation=vertical]/carousel:[touch-action:pan-x_pinch-zoom] group-data-[orientation=vertical]/carousel:flex-col\",\n \"group-data-[orientation=horizontal]/carousel:-ml-4\",\n className\n )}\n {...props}\n >\n <slot />\n </div>\n</div>\n",
|
|
22
22
|
"type": "registry:ui"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"path": "src/components/ui/carousel/carousel-item.astro",
|
|
26
|
-
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Props = HTMLAttributes<\"div\">\n\nconst { class: className, ...props } = Astro.props\n---\n\n<div\n data-slot=\"carousel-item\"\n class={cn(\n \"min-w-0 shrink-0 grow-0 basis-full
|
|
26
|
+
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\n\nimport { cn } from \"@/lib/utils\"\n\ntype Props = HTMLAttributes<\"div\">\n\nconst { class: className, ...props } = Astro.props\n---\n\n<div\n data-slot=\"carousel-item\"\n role=\"group\"\n aria-roledescription=\"slide\"\n class={cn(\n \"min-w-0 shrink-0 grow-0 basis-full\",\n \"group-data-[orientation=horizontal]/carousel:pl-4\",\n \"group-data-[orientation=vertical]/carousel:pt-4\",\n className\n )}\n {...props}\n>\n <slot />\n</div>\n",
|
|
27
27
|
"type": "registry:ui"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
40
|
"path": "src/components/ui/carousel/index.ts",
|
|
41
|
-
"content": "export type {
|
|
41
|
+
"content": "export type {\n EmblaCarouselType as CarouselApi,\n EmblaOptionsType as CarouselOptions,\n EmblaPluginType as CarouselPlugin,\n} from \"embla-carousel\"\n\nexport { default as Carousel } from \"./carousel.astro\"\nexport { default as CarouselContent } from \"./carousel-content.astro\"\nexport { default as CarouselItem } from \"./carousel-item.astro\"\nexport { default as CarouselPrevious } from \"./carousel-previous.astro\"\nexport { default as CarouselNext } from \"./carousel-next.astro\"\n",
|
|
42
42
|
"type": "registry:ui"
|
|
43
43
|
}
|
|
44
44
|
],
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"path": "src/components/ui/navigation-menu/navigation-menu-trigger.astro",
|
|
43
|
-
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport ChevronDownIcon from \"@lucide/astro/icons/chevron-down\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport navigationMenuTriggerStyle from \"./navigation-menu-trigger-style\"\n\ntype Props = HTMLAttributes<\"button\">\n\nconst { class: className, type = \"button\", ...props } = Astro.props\n---\n\n<button\n data-slot=\"navigation-menu-trigger\"\n type={type}\n class={cn(navigationMenuTriggerStyle(), \"group\", className)}\n {...props}\n>\n <slot />\n {\" \"}\n <ChevronDownIcon\n class=\"relative top-px ml-1 size-3 transition duration-300 group-data-open/navigation-menu-trigger:rotate-180 group-data-popup-open/navigation-menu-trigger:rotate-180\"\n aria-hidden=\"true\"\n />\n</button>\n",
|
|
43
|
+
"content": "---\nimport type { HTMLAttributes } from \"astro/types\"\nimport ChevronDownIcon from \"@lucide/astro/icons/chevron-down\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport navigationMenuTriggerStyle from \"./navigation-menu-trigger-style\"\n\ntype Props = HTMLAttributes<\"button\">\n\nconst { class: className, type = \"button\", ...props } = Astro.props\n---\n\n<button\n data-slot=\"navigation-menu-trigger\"\n type={type}\n class={cn(navigationMenuTriggerStyle(), \"group\", className)}\n {...props}\n>\n <slot />\n {\" \"}\n <ChevronDownIcon\n class=\"relative top-px ml-1 size-3 transition duration-300 group-data-open/navigation-menu-trigger:rotate-180 group-data-popup-open/navigation-menu-trigger:rotate-180 group-data-[state=open]/navigation-menu-trigger:rotate-180\"\n aria-hidden=\"true\"\n />\n</button>\n",
|
|
44
44
|
"type": "registry:ui"
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
"path": "src/components/ui/navigation-menu/navigation-menu-trigger-style.ts",
|
|
48
|
-
"content": "import { cva } from \"class-variance-authority\"\n\nconst navigationMenuTriggerStyle = cva(\n \"group/navigation-menu-trigger hover:bg-muted focus:bg-muted focus-visible:ring-ring/50 data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted inline-flex h-9 w-max items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-all outline-none focus-visible:ring-3 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50\"\n)\n\nexport default navigationMenuTriggerStyle\n",
|
|
48
|
+
"content": "import { cva } from \"class-variance-authority\"\n\nconst navigationMenuTriggerStyle = cva(\n \"group/navigation-menu-trigger hover:bg-muted focus:bg-muted focus-visible:ring-ring/50 data-[state=open]:bg-muted/50 data-[state=open]:hover:bg-muted data-[state=open]:focus:bg-muted data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted inline-flex h-9 w-max items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-all outline-none focus-visible:ring-3 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50\"\n)\n\nexport default navigationMenuTriggerStyle\n",
|
|
49
49
|
"type": "registry:ui"
|
|
50
50
|
},
|
|
51
51
|
{
|
package/public/r/registry.json
CHANGED
|
@@ -1079,13 +1079,13 @@
|
|
|
1079
1079
|
"name": "carousel",
|
|
1080
1080
|
"type": "registry:ui",
|
|
1081
1081
|
"title": "Carousel",
|
|
1082
|
-
"description": "
|
|
1082
|
+
"description": "A carousel with motion, swipe and responsive slides built using Embla.",
|
|
1083
1083
|
"categories": [
|
|
1084
1084
|
"ui"
|
|
1085
1085
|
],
|
|
1086
1086
|
"docs": "https://ui.full.dev/components/carousel/",
|
|
1087
1087
|
"dependencies": [
|
|
1088
|
-
"
|
|
1088
|
+
"embla-carousel@8.6.0",
|
|
1089
1089
|
"@lucide/astro"
|
|
1090
1090
|
],
|
|
1091
1091
|
"registryDependencies": [
|
package/public/r/reviews-3.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
{
|
|
17
17
|
"path": "src/components/blocks/reviews-3.astro",
|
|
18
|
-
"content": "---\nimport type { ImageMetadata } from \"astro\"\nimport type { HTMLAttributes } from \"astro/types\"\nimport QuoteIcon from \"@lucide/astro/icons/quote\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\"\nimport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n} from \"@/components/ui/carousel\"\nimport { Rating } from \"@/components/ui/rating\"\nimport {\n Section,\n SectionContainer,\n SectionDescription,\n SectionTitle,\n} from \"@/components/ui/section\"\n\ntype Props = HTMLAttributes<\"section\"> & {\n title?: string\n description?: string\n reviews: {\n rating: number\n quote: string\n image?: ImageMetadata\n initials: string\n name: string\n role: string\n }[]\n}\n\nconst { class: className, title, description, reviews, ...props } = Astro.props\n---\n\n<Section class={cn(\"\", className)} {...props}>\n {\n (title || description) && (\n <SectionContainer class=\"items-center gap-4 text-center\">\n {title && <SectionTitle>{title}</SectionTitle>}\n {description && (\n <SectionDescription class=\"max-w-2xl\">\n {description}\n </SectionDescription>\n )}\n </SectionContainer>\n )\n }\n <SectionContainer>\n <Carousel loop
|
|
18
|
+
"content": "---\nimport type { ImageMetadata } from \"astro\"\nimport type { HTMLAttributes } from \"astro/types\"\nimport QuoteIcon from \"@lucide/astro/icons/quote\"\n\nimport { cn } from \"@/lib/utils\"\nimport { Avatar, AvatarFallback, AvatarImage } from \"@/components/ui/avatar\"\nimport {\n Carousel,\n CarouselContent,\n CarouselItem,\n CarouselNext,\n CarouselPrevious,\n} from \"@/components/ui/carousel\"\nimport { Rating } from \"@/components/ui/rating\"\nimport {\n Section,\n SectionContainer,\n SectionDescription,\n SectionTitle,\n} from \"@/components/ui/section\"\n\ntype Props = HTMLAttributes<\"section\"> & {\n title?: string\n description?: string\n reviews: {\n rating: number\n quote: string\n image?: ImageMetadata\n initials: string\n name: string\n role: string\n }[]\n}\n\nconst { class: className, title, description, reviews, ...props } = Astro.props\n---\n\n<Section class={cn(\"\", className)} {...props}>\n {\n (title || description) && (\n <SectionContainer class=\"items-center gap-4 text-center\">\n {title && <SectionTitle>{title}</SectionTitle>}\n {description && (\n <SectionDescription class=\"max-w-2xl\">\n {description}\n </SectionDescription>\n )}\n </SectionContainer>\n )\n }\n <SectionContainer>\n <Carousel\n opts={{ loop: true }}\n class=\"mx-auto w-[calc(100%-6rem)] max-w-3xl\"\n >\n <CarouselContent>\n {\n reviews.map((item) => (\n <CarouselItem>\n <div class=\"flex flex-col items-center gap-6 px-4 py-8 text-center\">\n <QuoteIcon class=\"text-primary size-10\" />\n <Rating value={item.rating} />\n <blockquote class=\"text-foreground text-xl leading-relaxed font-medium text-balance sm:text-2xl\">\n {item.quote}\n </blockquote>\n <div class=\"flex items-center gap-3 pt-2\">\n <Avatar size=\"lg\">\n <AvatarImage src={item.image} alt={item.name} />\n <AvatarFallback>{item.initials}</AvatarFallback>\n </Avatar>\n <div class=\"text-left\">\n <p class=\"text-foreground text-sm font-medium\">\n {item.name}\n </p>\n <p class=\"text-muted-foreground text-xs\">{item.role}</p>\n </div>\n </div>\n </div>\n </CarouselItem>\n ))\n }\n </CarouselContent>\n <CarouselPrevious />\n <CarouselNext />\n </Carousel>\n </SectionContainer>\n</Section>\n",
|
|
19
19
|
"type": "registry:block"
|
|
20
20
|
}
|
|
21
21
|
],
|
package/registry.json
CHANGED
|
@@ -981,10 +981,10 @@
|
|
|
981
981
|
"name": "carousel",
|
|
982
982
|
"type": "registry:ui",
|
|
983
983
|
"title": "Carousel",
|
|
984
|
-
"description": "
|
|
984
|
+
"description": "A carousel with motion, swipe and responsive slides built using Embla.",
|
|
985
985
|
"categories": ["ui"],
|
|
986
986
|
"docs": "https://ui.full.dev/components/carousel/",
|
|
987
|
-
"dependencies": ["
|
|
987
|
+
"dependencies": ["embla-carousel@8.6.0", "@lucide/astro"],
|
|
988
988
|
"registryDependencies": ["@fulldev/button"],
|
|
989
989
|
"files": [
|
|
990
990
|
{
|
|
@@ -50,7 +50,10 @@ const { class: className, title, description, reviews, ...props } = Astro.props
|
|
|
50
50
|
)
|
|
51
51
|
}
|
|
52
52
|
<SectionContainer>
|
|
53
|
-
<Carousel
|
|
53
|
+
<Carousel
|
|
54
|
+
opts={{ loop: true }}
|
|
55
|
+
class="mx-auto w-[calc(100%-6rem)] max-w-3xl"
|
|
56
|
+
>
|
|
54
57
|
<CarouselContent>
|
|
55
58
|
{
|
|
56
59
|
reviews.map((item) => (
|
|
@@ -8,15 +8,17 @@ type Props = HTMLAttributes<"div">
|
|
|
8
8
|
const { class: className, ...props } = Astro.props
|
|
9
9
|
---
|
|
10
10
|
|
|
11
|
-
<div
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
<div class="overflow-hidden" data-slot="carousel-content">
|
|
12
|
+
<div
|
|
13
|
+
data-slot="carousel-container"
|
|
14
|
+
class={cn(
|
|
15
|
+
"flex [touch-action:pan-y_pinch-zoom]",
|
|
16
|
+
"group-data-[orientation=vertical]/carousel:-mt-4 group-data-[orientation=vertical]/carousel:[touch-action:pan-x_pinch-zoom] group-data-[orientation=vertical]/carousel:flex-col",
|
|
17
|
+
"group-data-[orientation=horizontal]/carousel:-ml-4",
|
|
18
|
+
className
|
|
19
|
+
)}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
<slot />
|
|
23
|
+
</div>
|
|
22
24
|
</div>
|
|
@@ -10,9 +10,12 @@ const { class: className, ...props } = Astro.props
|
|
|
10
10
|
|
|
11
11
|
<div
|
|
12
12
|
data-slot="carousel-item"
|
|
13
|
+
role="group"
|
|
14
|
+
aria-roledescription="slide"
|
|
13
15
|
class={cn(
|
|
14
|
-
"min-w-0 shrink-0 grow-0 basis-full
|
|
15
|
-
"group-data-[orientation=
|
|
16
|
+
"min-w-0 shrink-0 grow-0 basis-full",
|
|
17
|
+
"group-data-[orientation=horizontal]/carousel:pl-4",
|
|
18
|
+
"group-data-[orientation=vertical]/carousel:pt-4",
|
|
16
19
|
className
|
|
17
20
|
)}
|
|
18
21
|
{...props}
|
|
@@ -1,46 +1,154 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { HTMLAttributes } from "astro/types"
|
|
3
|
+
import type { EmblaOptionsType } from "embla-carousel"
|
|
3
4
|
|
|
4
5
|
import { cn } from "@/lib/utils"
|
|
5
6
|
|
|
6
7
|
type Props = HTMLAttributes<"div"> & {
|
|
7
|
-
|
|
8
|
+
opts?: EmblaOptionsType
|
|
8
9
|
orientation?: "horizontal" | "vertical"
|
|
9
|
-
drag?: boolean
|
|
10
|
-
loop?: boolean
|
|
11
10
|
}
|
|
12
11
|
|
|
13
12
|
const {
|
|
14
13
|
class: className,
|
|
15
|
-
|
|
16
|
-
orientation = "horizontal",
|
|
17
|
-
drag,
|
|
18
|
-
loop,
|
|
14
|
+
opts,
|
|
15
|
+
orientation = opts?.axis === "y" ? "vertical" : "horizontal",
|
|
19
16
|
...props
|
|
20
17
|
} = Astro.props
|
|
18
|
+
|
|
19
|
+
const resolvedOpts: EmblaOptionsType = {
|
|
20
|
+
...opts,
|
|
21
|
+
axis: orientation === "horizontal" ? "x" : "y",
|
|
22
|
+
}
|
|
21
23
|
---
|
|
22
24
|
|
|
23
25
|
<div
|
|
24
26
|
data-slot="carousel"
|
|
25
|
-
data-default-index={defaultIndex}
|
|
26
27
|
data-orientation={orientation}
|
|
27
|
-
data-
|
|
28
|
-
data-loop={loop}
|
|
28
|
+
data-carousel-options={JSON.stringify(resolvedOpts)}
|
|
29
29
|
class={cn("group/carousel relative", className)}
|
|
30
|
+
role="region"
|
|
31
|
+
aria-roledescription="carousel"
|
|
30
32
|
{...props}
|
|
31
33
|
>
|
|
32
34
|
<slot />
|
|
33
35
|
</div>
|
|
34
36
|
|
|
35
37
|
<script>
|
|
36
|
-
import {
|
|
38
|
+
import EmblaCarousel, {
|
|
39
|
+
type EmblaCarouselType,
|
|
40
|
+
type EmblaOptionsType,
|
|
41
|
+
} from "embla-carousel"
|
|
42
|
+
|
|
43
|
+
type CarouselRoot = HTMLElement & {
|
|
44
|
+
__fulldevCarouselApi?: EmblaCarouselType
|
|
45
|
+
}
|
|
37
46
|
|
|
38
|
-
const
|
|
39
|
-
const initialize = () =>
|
|
47
|
+
const instances = new Map<CarouselRoot, () => void>()
|
|
48
|
+
const initialize = () => {
|
|
49
|
+
for (const root of document.querySelectorAll<CarouselRoot>(
|
|
50
|
+
'[data-slot="carousel"]'
|
|
51
|
+
)) {
|
|
52
|
+
if (instances.has(root)) continue
|
|
53
|
+
const viewport = root.querySelector<HTMLElement>(
|
|
54
|
+
'[data-slot="carousel-content"]'
|
|
55
|
+
)
|
|
56
|
+
if (!viewport) continue
|
|
57
|
+
const opts: EmblaOptionsType = JSON.parse(
|
|
58
|
+
root.dataset.carouselOptions || "{}"
|
|
59
|
+
)
|
|
60
|
+
const api = EmblaCarousel(viewport, opts)
|
|
61
|
+
root.__fulldevCarouselApi = api
|
|
62
|
+
const previous = root.querySelectorAll<HTMLButtonElement>(
|
|
63
|
+
'[data-slot="carousel-previous"]'
|
|
64
|
+
)
|
|
65
|
+
const next = root.querySelectorAll<HTMLButtonElement>(
|
|
66
|
+
'[data-slot="carousel-next"]'
|
|
67
|
+
)
|
|
68
|
+
const emit = (type: "carousel:init" | "carousel:select") => {
|
|
69
|
+
root.dispatchEvent(
|
|
70
|
+
new CustomEvent(type, {
|
|
71
|
+
detail: {
|
|
72
|
+
api,
|
|
73
|
+
canScrollPrev: api.canScrollPrev(),
|
|
74
|
+
canScrollNext: api.canScrollNext(),
|
|
75
|
+
selectedScrollSnap: api.selectedScrollSnap(),
|
|
76
|
+
scrollSnapList: api.scrollSnapList(),
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
const sync = () => {
|
|
82
|
+
root.dataset.canScrollPrev = String(api.canScrollPrev())
|
|
83
|
+
root.dataset.canScrollNext = String(api.canScrollNext())
|
|
84
|
+
root.dataset.selectedScrollSnap = String(api.selectedScrollSnap())
|
|
85
|
+
for (const button of previous)
|
|
86
|
+
if (button.dataset.manualDisabled !== "true")
|
|
87
|
+
button.disabled = !api.canScrollPrev()
|
|
88
|
+
for (const button of next)
|
|
89
|
+
if (button.dataset.manualDisabled !== "true")
|
|
90
|
+
button.disabled = !api.canScrollNext()
|
|
91
|
+
emit("carousel:select")
|
|
92
|
+
}
|
|
93
|
+
const jump = () =>
|
|
94
|
+
window.matchMedia("(prefers-reduced-motion: reduce)").matches
|
|
95
|
+
const onPrevious = () => api.scrollPrev(jump())
|
|
96
|
+
const onNext = () => api.scrollNext(jump())
|
|
97
|
+
const onKeyDown = (event: KeyboardEvent) => {
|
|
98
|
+
const target = event.target
|
|
99
|
+
if (
|
|
100
|
+
event.defaultPrevented ||
|
|
101
|
+
!(target instanceof Element) ||
|
|
102
|
+
target.closest('[data-slot="carousel"]') !== root ||
|
|
103
|
+
target.closest(
|
|
104
|
+
'input, textarea, select, [contenteditable]:not([contenteditable="false"])'
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
return
|
|
108
|
+
const vertical = root.dataset.orientation === "vertical"
|
|
109
|
+
switch (event.key) {
|
|
110
|
+
case vertical ? "ArrowUp" : "ArrowLeft":
|
|
111
|
+
onPrevious()
|
|
112
|
+
break
|
|
113
|
+
case vertical ? "ArrowDown" : "ArrowRight":
|
|
114
|
+
onNext()
|
|
115
|
+
break
|
|
116
|
+
case "Home":
|
|
117
|
+
api.scrollTo(0, jump())
|
|
118
|
+
break
|
|
119
|
+
case "End":
|
|
120
|
+
api.scrollTo(api.scrollSnapList().length - 1, jump())
|
|
121
|
+
break
|
|
122
|
+
default:
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
event.preventDefault()
|
|
126
|
+
}
|
|
127
|
+
for (const button of previous)
|
|
128
|
+
button.addEventListener("click", onPrevious)
|
|
129
|
+
for (const button of next) button.addEventListener("click", onNext)
|
|
130
|
+
root.addEventListener("keydown", onKeyDown)
|
|
131
|
+
api.on("select", sync)
|
|
132
|
+
api.on("reInit", sync)
|
|
133
|
+
sync()
|
|
134
|
+
const frame = requestAnimationFrame(() => emit("carousel:init"))
|
|
135
|
+
instances.set(root, () => {
|
|
136
|
+
cancelAnimationFrame(frame)
|
|
137
|
+
for (const button of previous)
|
|
138
|
+
button.removeEventListener("click", onPrevious)
|
|
139
|
+
for (const button of next) button.removeEventListener("click", onNext)
|
|
140
|
+
root.removeEventListener("keydown", onKeyDown)
|
|
141
|
+
api.off("select", sync)
|
|
142
|
+
api.off("reInit", sync)
|
|
143
|
+
api.destroy()
|
|
144
|
+
delete root.__fulldevCarouselApi
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
}
|
|
40
148
|
initialize()
|
|
41
149
|
document.addEventListener("astro:page-load", initialize)
|
|
42
150
|
document.addEventListener("astro:before-swap", () => {
|
|
43
|
-
for (const
|
|
44
|
-
|
|
151
|
+
for (const cleanup of instances.values()) cleanup()
|
|
152
|
+
instances.clear()
|
|
45
153
|
})
|
|
46
154
|
</script>
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export type {
|
|
1
|
+
export type {
|
|
2
|
+
EmblaCarouselType as CarouselApi,
|
|
3
|
+
EmblaOptionsType as CarouselOptions,
|
|
4
|
+
EmblaPluginType as CarouselPlugin,
|
|
5
|
+
} from "embla-carousel"
|
|
2
6
|
|
|
3
7
|
export { default as Carousel } from "./carousel.astro"
|
|
4
8
|
export { default as CarouselContent } from "./carousel-content.astro"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority"
|
|
2
2
|
|
|
3
3
|
const navigationMenuTriggerStyle = cva(
|
|
4
|
-
"group/navigation-menu-trigger hover:bg-muted focus:bg-muted focus-visible:ring-ring/50 data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted inline-flex h-9 w-max items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-all outline-none focus-visible:ring-3 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50"
|
|
4
|
+
"group/navigation-menu-trigger hover:bg-muted focus:bg-muted focus-visible:ring-ring/50 data-[state=open]:bg-muted/50 data-[state=open]:hover:bg-muted data-[state=open]:focus:bg-muted data-popup-open:bg-muted/50 data-popup-open:hover:bg-muted data-open:bg-muted/50 data-open:hover:bg-muted data-open:focus:bg-muted inline-flex h-9 w-max items-center justify-center rounded-md px-4 py-2 text-sm font-medium transition-all outline-none focus-visible:ring-3 focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50"
|
|
5
5
|
)
|
|
6
6
|
|
|
7
7
|
export default navigationMenuTriggerStyle
|
|
@@ -20,7 +20,7 @@ const { class: className, type = "button", ...props } = Astro.props
|
|
|
20
20
|
<slot />
|
|
21
21
|
{" "}
|
|
22
22
|
<ChevronDownIcon
|
|
23
|
-
class="relative top-px ml-1 size-3 transition duration-300 group-data-open/navigation-menu-trigger:rotate-180 group-data-popup-open/navigation-menu-trigger:rotate-180"
|
|
23
|
+
class="relative top-px ml-1 size-3 transition duration-300 group-data-open/navigation-menu-trigger:rotate-180 group-data-popup-open/navigation-menu-trigger:rotate-180 group-data-[state=open]/navigation-menu-trigger:rotate-180"
|
|
24
24
|
aria-hidden="true"
|
|
25
25
|
/>
|
|
26
26
|
</button>
|