@orbitkit/components 0.2.0 → 0.4.0

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.
Files changed (120) hide show
  1. package/dist/astro/accordion/Accordion.astro +34 -34
  2. package/dist/astro/accordion/AccordionItem.astro +19 -19
  3. package/dist/astro/accordion/AccordionTrigger.astro +33 -33
  4. package/dist/astro/accordion/AcordionContent.astro +23 -23
  5. package/dist/astro/accordion/accordion.ts +151 -151
  6. package/dist/astro/accordion/index.ts +6 -6
  7. package/dist/astro/ambient-image/AmbientFigcaption.astro +15 -0
  8. package/dist/astro/ambient-image/AmbientImage.astro +70 -0
  9. package/dist/astro/ambient-image/index.ts +4 -0
  10. package/dist/astro/button-group/ButtonGroup.astro +21 -0
  11. package/dist/astro/button-group/buttonGroupVariants.ts +34 -0
  12. package/dist/astro/button-group/index.ts +3 -0
  13. package/dist/astro/collapsible/Collapsible.astro +34 -34
  14. package/dist/astro/collapsible/CollapsibleContent.astro +20 -20
  15. package/dist/astro/collapsible/collapsible.ts +81 -81
  16. package/dist/astro/collapsible/index.ts +4 -4
  17. package/dist/astro/diff/Diff.astro +55 -0
  18. package/dist/astro/diff/DiffItem.astro +21 -0
  19. package/dist/astro/diff/index.ts +4 -0
  20. package/dist/astro/drawer/DrawerContent.astro +74 -74
  21. package/dist/astro/drawer/drawer.ts +104 -104
  22. package/dist/astro/drawer/index.ts +17 -17
  23. package/dist/astro/dropdown/DropdownMenu.astro +19 -19
  24. package/dist/astro/dropdown/DropdownMenuContent.astro +42 -42
  25. package/dist/astro/dropdown/DropdownMenuGroup.astro +3 -3
  26. package/dist/astro/dropdown/DropdownMenuItem.astro +27 -27
  27. package/dist/astro/dropdown/DropdownMenuLabel.astro +3 -3
  28. package/dist/astro/dropdown/DropdownMenuSeparator.astro +6 -6
  29. package/dist/astro/dropdown/dropdown.ts +157 -157
  30. package/dist/astro/dropdown/dropdownVariants.ts +134 -134
  31. package/dist/astro/dropdown/index.ts +23 -23
  32. package/dist/astro/loader/Loader.astro +16 -0
  33. package/dist/astro/loader/index.ts +6 -0
  34. package/dist/astro/loader/loaders/12-dots-scale-rotate.svg +1 -0
  35. package/dist/astro/loader/loaders/180-ring-with-bg.svg +1 -0
  36. package/dist/astro/loader/loaders/180-ring.svg +1 -0
  37. package/dist/astro/loader/loaders/270-ring-with-bg.svg +1 -0
  38. package/dist/astro/loader/loaders/270-ring.svg +1 -0
  39. package/dist/astro/loader/loaders/3-dots-bounce.svg +1 -0
  40. package/dist/astro/loader/loaders/3-dots-fade.svg +1 -0
  41. package/dist/astro/loader/loaders/3-dots-move.svg +1 -0
  42. package/dist/astro/loader/loaders/3-dots-rotate.svg +1 -0
  43. package/dist/astro/loader/loaders/3-dots-scale-middle.svg +1 -0
  44. package/dist/astro/loader/loaders/3-dots-scale.svg +1 -0
  45. package/dist/astro/loader/loaders/6-dots-rotate.svg +1 -0
  46. package/dist/astro/loader/loaders/6-dots-scale-middle.svg +1 -0
  47. package/dist/astro/loader/loaders/6-dots-scale.svg +1 -0
  48. package/dist/astro/loader/loaders/8-dots-rotate.svg +1 -0
  49. package/dist/astro/loader/loaders/90-ring-with-bg.svg +1 -0
  50. package/dist/astro/loader/loaders/90-ring.svg +1 -0
  51. package/dist/astro/loader/loaders/bars-fade.svg +1 -0
  52. package/dist/astro/loader/loaders/bars-rotate-fade.svg +1 -0
  53. package/dist/astro/loader/loaders/bars-scale-fade.svg +1 -0
  54. package/dist/astro/loader/loaders/bars-scale-middle.svg +1 -0
  55. package/dist/astro/loader/loaders/bars-scale.svg +1 -0
  56. package/dist/astro/loader/loaders/blocks-scale.svg +1 -0
  57. package/dist/astro/loader/loaders/blocks-shuffle-2.svg +1 -0
  58. package/dist/astro/loader/loaders/blocks-shuffle-3.svg +1 -0
  59. package/dist/astro/loader/loaders/blocks-wave.svg +1 -0
  60. package/dist/astro/loader/loaders/bouncing-ball.svg +1 -0
  61. package/dist/astro/loader/loaders/clock.svg +1 -0
  62. package/dist/astro/loader/loaders/dot-revolve.svg +1 -0
  63. package/dist/astro/loader/loaders/eclipse-half.svg +1 -0
  64. package/dist/astro/loader/loaders/eclipse.svg +1 -0
  65. package/dist/astro/loader/loaders/gooey-balls-1.svg +1 -0
  66. package/dist/astro/loader/loaders/gooey-balls-2.svg +1 -0
  67. package/dist/astro/loader/loaders/index.ts +99 -0
  68. package/dist/astro/loader/loaders/pulse-2.svg +1 -0
  69. package/dist/astro/loader/loaders/pulse-3.svg +1 -0
  70. package/dist/astro/loader/loaders/pulse-multiple.svg +1 -0
  71. package/dist/astro/loader/loaders/pulse-ring.svg +1 -0
  72. package/dist/astro/loader/loaders/pulse-rings-2.svg +1 -0
  73. package/dist/astro/loader/loaders/pulse-rings-3.svg +1 -0
  74. package/dist/astro/loader/loaders/pulse-rings-multiple.svg +1 -0
  75. package/dist/astro/loader/loaders/pulse.svg +1 -0
  76. package/dist/astro/loader/loaders/ring-resize.svg +1 -0
  77. package/dist/astro/loader/loaders/tadpole.svg +1 -0
  78. package/dist/astro/loader/loaders/wifi-fade.svg +1 -0
  79. package/dist/astro/loader/loaders/wifi.svg +1 -0
  80. package/dist/astro/loader/loaders/wind-toy.svg +1 -0
  81. package/dist/astro/marquee/Marquee.astro +53 -0
  82. package/dist/astro/marquee/index.ts +3 -0
  83. package/dist/astro/modal/Modal.astro +19 -19
  84. package/dist/astro/modal/ModalContent.astro +71 -71
  85. package/dist/astro/modal/ModalDescription.astro +12 -12
  86. package/dist/astro/modal/ModalFooter.astro +15 -15
  87. package/dist/astro/modal/ModalHeader.astro +12 -12
  88. package/dist/astro/modal/ModalTitle.astro +18 -18
  89. package/dist/astro/modal/index.ts +15 -15
  90. package/dist/astro/modal/modal.ts +101 -101
  91. package/dist/astro/pagination/index.ts +15 -15
  92. package/dist/astro/popover/Popover.astro +17 -17
  93. package/dist/astro/popover/PopoverContent.astro +39 -39
  94. package/dist/astro/popover/index.ts +5 -5
  95. package/dist/astro/popover/popover.ts +113 -113
  96. package/dist/astro/popover/popoverVariants.ts +115 -115
  97. package/dist/astro/scroll-progress/ScrollProgress.astro +41 -0
  98. package/dist/astro/scroll-progress/ScrollProgressBar.astro +19 -0
  99. package/dist/astro/scroll-progress/index.ts +4 -0
  100. package/dist/astro/stat/Stat.astro +12 -12
  101. package/dist/astro/stat/StatDescription.astro +12 -12
  102. package/dist/astro/stat/StatTitle.astro +18 -18
  103. package/dist/astro/stat/StatValue.astro +12 -12
  104. package/dist/astro/stat/index.ts +6 -6
  105. package/dist/astro/tab/TabList.astro +19 -19
  106. package/dist/astro/toast/Toast.astro +36 -0
  107. package/dist/astro/toast/ToastDescription.astro +10 -0
  108. package/dist/astro/toast/ToastTitle.astro +18 -0
  109. package/dist/astro/toast/Toaster.astro +78 -0
  110. package/dist/astro/toast/assets.ts +6 -0
  111. package/dist/astro/toast/index.ts +30 -0
  112. package/dist/astro/toast/toast.ts +277 -0
  113. package/dist/astro/tooltip/Tooltip.astro +40 -40
  114. package/dist/astro/tooltip/TooltipContent.astro +39 -39
  115. package/dist/astro/tooltip/index.ts +5 -5
  116. package/dist/astro/tooltip/tooltip.ts +137 -137
  117. package/dist/astro/tooltip/tooltipVariants.ts +115 -115
  118. package/dist/index.js +30 -2
  119. package/dist/index.js.map +1 -1
  120. package/package.json +9 -8
@@ -1,34 +1,34 @@
1
- ---
2
- import { cn } from "@/utils/cn";
3
- import type { HTMLAttributes } from "astro/types";
4
-
5
- interface Props extends HTMLAttributes<"div"> {
6
- multiple?: boolean;
7
- }
8
-
9
- const { class: className, multiple = false, ...attrs } = Astro.props;
10
- ---
11
-
12
- <div
13
- {...attrs}
14
- data-accordion
15
- data-multiple={multiple}
16
- class={cn("w-full", className)}
17
- >
18
- <slot />
19
- </div>
20
-
21
- <script>
22
- import { Accordion } from "./accordion";
23
-
24
- function init() {
25
- const accordions =
26
- document.querySelectorAll<HTMLElement>("[data-accordion]");
27
- accordions.forEach((accordion) => {
28
- new Accordion(accordion);
29
- });
30
- }
31
-
32
- init();
33
- document.addEventListener("astro:page-load", () => init());
34
- </script>
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"div"> {
6
+ multiple?: boolean;
7
+ }
8
+
9
+ const { class: className, multiple = false, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <div
13
+ {...attrs}
14
+ data-accordion
15
+ data-multiple={multiple}
16
+ class={cn("w-full", className)}
17
+ >
18
+ <slot />
19
+ </div>
20
+
21
+ <script>
22
+ import { Accordion } from "./accordion";
23
+
24
+ function init() {
25
+ const accordions =
26
+ document.querySelectorAll<HTMLElement>("[data-accordion]");
27
+ accordions.forEach((accordion) => {
28
+ new Accordion(accordion);
29
+ });
30
+ }
31
+
32
+ init();
33
+ document.addEventListener("astro:page-load", () => init());
34
+ </script>
@@ -1,19 +1,19 @@
1
- ---
2
- import { cn } from "@/utils/cn";
3
- import type { HTMLAttributes } from "astro/types";
4
-
5
- interface Props extends HTMLAttributes<"div"> {
6
- isOpen?: boolean;
7
- }
8
-
9
- const { class: className, isOpen = false, ...attrs } = Astro.props;
10
- ---
11
-
12
- <div
13
- {...attrs}
14
- data-accordion-item
15
- data-default-open={isOpen}
16
- class={cn("border-b border-border last:border-b-0", className)}
17
- >
18
- <slot />
19
- </div>
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"div"> {
6
+ isOpen?: boolean;
7
+ }
8
+
9
+ const { class: className, isOpen = false, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <div
13
+ {...attrs}
14
+ data-accordion-item
15
+ data-default-open={isOpen}
16
+ class={cn("border-b border-border last:border-b-0", className)}
17
+ >
18
+ <slot />
19
+ </div>
@@ -1,33 +1,33 @@
1
- ---
2
- import { cn } from "@/utils/cn";
3
- import type { HTMLAttributes } from "astro/types";
4
-
5
- interface Props extends HTMLAttributes<"button"> {}
6
-
7
- const { class: className, ...attrs } = Astro.props;
8
- ---
9
-
10
- <h3>
11
- <button
12
- {...attrs}
13
- aria-expanded="false"
14
- data-accordion-trigger
15
- class={cn(
16
- "flex items-center justify-between py-4 border-b border-border last:border-b-0 w-full text-start text-base font-medium cursor-pointer [&[data-state=open]>svg]:rotate-180",
17
- className,
18
- )}
19
- >
20
- <slot />
21
- <svg
22
- viewBox="0 0 24 24"
23
- fill="none"
24
- stroke="currentColor"
25
- stroke-width="2"
26
- stroke-linecap="round"
27
- stroke-linejoin="round"
28
- class="size-4 transform transition-transform duration-200"
29
- ><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path
30
- d="M6 9l6 6l6 -6"></path></svg
31
- >
32
- </button>
33
- </h3>
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"button"> {}
6
+
7
+ const { class: className, ...attrs } = Astro.props;
8
+ ---
9
+
10
+ <h3>
11
+ <button
12
+ {...attrs}
13
+ aria-expanded="false"
14
+ data-accordion-trigger
15
+ class={cn(
16
+ "flex items-center justify-between py-4 border-b border-border last:border-b-0 w-full text-start text-base font-medium cursor-pointer [&[data-state=open]>svg]:rotate-180",
17
+ className,
18
+ )}
19
+ >
20
+ <slot />
21
+ <svg
22
+ viewBox="0 0 24 24"
23
+ fill="none"
24
+ stroke="currentColor"
25
+ stroke-width="2"
26
+ stroke-linecap="round"
27
+ stroke-linejoin="round"
28
+ class="size-4 transform transition-transform duration-200"
29
+ ><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path
30
+ d="M6 9l6 6l6 -6"></path></svg
31
+ >
32
+ </button>
33
+ </h3>
@@ -1,23 +1,23 @@
1
- ---
2
- import { cn } from "@/utils/cn";
3
- import type { HTMLAttributes } from "astro/types";
4
-
5
- interface Props extends HTMLAttributes<"div"> {}
6
-
7
- const { class: className, ...attrs } = Astro.props;
8
- ---
9
-
10
- <div
11
- {...attrs}
12
- role="region"
13
- data-accordion-content
14
- data-state="closed"
15
- class={cn(
16
- "overflow-hidden transition-all duration-300 ease-in-out data-[state=closed]:max-h-0",
17
- className,
18
- )}
19
- >
20
- <div class="pb-4">
21
- <slot />
22
- </div>
23
- </div>
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"div"> {}
6
+
7
+ const { class: className, ...attrs } = Astro.props;
8
+ ---
9
+
10
+ <div
11
+ {...attrs}
12
+ role="region"
13
+ data-accordion-content
14
+ data-state="closed"
15
+ class={cn(
16
+ "overflow-hidden transition-all duration-300 ease-in-out data-[state=closed]:max-h-0",
17
+ className,
18
+ )}
19
+ >
20
+ <div class="pb-4">
21
+ <slot />
22
+ </div>
23
+ </div>
@@ -1,151 +1,151 @@
1
- interface AccordionItem extends HTMLElement {
2
- trigger?: HTMLElement;
3
- content?: HTMLElement;
4
- }
5
-
6
- export class Accordion {
7
- private wrapper: HTMLElement;
8
- private items: NodeListOf<HTMLElement> | null;
9
-
10
- constructor(accordionWrapper: HTMLElement) {
11
- this.wrapper = accordionWrapper;
12
- this.items = this.wrapper.querySelectorAll("[data-accordion-item]");
13
-
14
- this.init();
15
- }
16
-
17
- private init() {
18
- const defaultOpenItems = [];
19
-
20
- this.items?.forEach((item: AccordionItem) => {
21
- const trigger = item.querySelector<HTMLElement>(
22
- "[data-accordion-trigger]",
23
- );
24
- const content = item.querySelector<HTMLElement>(
25
- "[data-accordion-content]",
26
- );
27
-
28
- if (trigger && content) {
29
- item.trigger = trigger;
30
- item.content = content;
31
-
32
- this.setupAccessibility(item);
33
- this.setupEventListeners(item);
34
-
35
- if (item.dataset.defaultOpen === "true") {
36
- if (
37
- defaultOpenItems.length > 0 &&
38
- this.wrapper.dataset.multiple !== "true"
39
- ) {
40
- console.warn(
41
- "Warning! This accordion is not configured to open multiple items by default. " +
42
- "Only the first item will be opened." +
43
- "Consider adding the multiple prop to the accordion if you want to allow multiple items to be open by default.",
44
- );
45
- return;
46
- }
47
-
48
- this.setContentHeight(content);
49
- this.setState(item, "open");
50
- defaultOpenItems.push(item);
51
- }
52
- }
53
- });
54
- }
55
-
56
- private setupAccessibility(item: AccordionItem) {
57
- if (item.trigger && item.content) {
58
- const triggerId =
59
- item.trigger.id ||
60
- `accordion-id-${Math.random().toString(36).substring(2, 9)}`;
61
- const contentId =
62
- item.content.id ||
63
- `accordion-id-${Math.random().toString(36).substring(2, 9)}`;
64
-
65
- item.trigger.id = triggerId;
66
- item.trigger.setAttribute("aria-controls", contentId);
67
-
68
- item.content.id = contentId;
69
- item.content.setAttribute("aria-labelledby", triggerId);
70
- item.content.setAttribute("role", "region");
71
-
72
- this.setState(item, "closed");
73
- }
74
- }
75
-
76
- private setupEventListeners(item: AccordionItem) {
77
- if (!item.trigger && !item.content) return;
78
-
79
- item.trigger?.addEventListener("click", () =>
80
- this.toggleAccordionItem(item),
81
- );
82
- item.trigger?.addEventListener("keydown", (e) =>
83
- this.handleKeydown(e, item),
84
- );
85
- }
86
-
87
- private toggleAccordionItem(item: AccordionItem) {
88
- if (item.trigger?.getAttribute("aria-expanded") === "true") {
89
- this.closeAccordionItem(item);
90
- } else {
91
- if (this.wrapper.dataset.multiple !== "true") {
92
- this.closeAllContents();
93
- }
94
- this.openAccordionItem(item);
95
- }
96
- }
97
-
98
- private openAccordionItem(item: AccordionItem) {
99
- this.setState(item, "open");
100
- if (item.content) {
101
- this.setContentHeight(item.content);
102
- }
103
- }
104
-
105
- private closeAccordionItem(item: AccordionItem) {
106
- this.setState(item, "closed");
107
- item.content!.style.maxHeight = "0px";
108
- }
109
-
110
- private closeAllContents() {
111
- this.items?.forEach((item) => {
112
- this.closeAccordionItem(item);
113
- });
114
- }
115
-
116
- private handleKeydown(event: KeyboardEvent, item: AccordionItem) {
117
- const items = Array.from(this.items || []);
118
- const currentItemIndex = items.indexOf(item);
119
-
120
- const keyActions: Record<string, () => void> = {
121
- ArrowDown: () => this.setFocusItem(items, currentItemIndex + 1),
122
- ArrowUp: () => this.setFocusItem(items, currentItemIndex - 1),
123
- Home: () => this.setFocusItem(items, 0),
124
- End: () => this.setFocusItem(items, items.length - 1),
125
- };
126
-
127
- const action = keyActions[event.key];
128
- if (action) {
129
- event.preventDefault();
130
- action();
131
- }
132
- }
133
-
134
- private setFocusItem(items: AccordionItem[], index: number) {
135
- const newIndex = (index + items.length) % items.length;
136
- if (items[newIndex].trigger) {
137
- items[newIndex].trigger.focus();
138
- }
139
- }
140
-
141
- private setContentHeight(content: HTMLElement) {
142
- const height = content.scrollHeight + "px";
143
- content.style.maxHeight = height;
144
- }
145
-
146
- private setState(item: AccordionItem, state: "closed" | "open") {
147
- item.trigger?.setAttribute("data-state", state);
148
- item.trigger?.setAttribute("aria-expanded", `${state === "open"}`);
149
- item.content?.setAttribute("data-state", state);
150
- }
151
- }
1
+ interface AccordionItem extends HTMLElement {
2
+ trigger?: HTMLElement;
3
+ content?: HTMLElement;
4
+ }
5
+
6
+ export class Accordion {
7
+ private wrapper: HTMLElement;
8
+ private items: NodeListOf<HTMLElement> | null;
9
+
10
+ constructor(accordionWrapper: HTMLElement) {
11
+ this.wrapper = accordionWrapper;
12
+ this.items = this.wrapper.querySelectorAll("[data-accordion-item]");
13
+
14
+ this.init();
15
+ }
16
+
17
+ private init() {
18
+ const defaultOpenItems = [];
19
+
20
+ this.items?.forEach((item: AccordionItem) => {
21
+ const trigger = item.querySelector<HTMLElement>(
22
+ "[data-accordion-trigger]",
23
+ );
24
+ const content = item.querySelector<HTMLElement>(
25
+ "[data-accordion-content]",
26
+ );
27
+
28
+ if (trigger && content) {
29
+ item.trigger = trigger;
30
+ item.content = content;
31
+
32
+ this.setupAccessibility(item);
33
+ this.setupEventListeners(item);
34
+
35
+ if (item.dataset.defaultOpen === "true") {
36
+ if (
37
+ defaultOpenItems.length > 0 &&
38
+ this.wrapper.dataset.multiple !== "true"
39
+ ) {
40
+ console.warn(
41
+ "Warning! This accordion is not configured to open multiple items by default. " +
42
+ "Only the first item will be opened." +
43
+ "Consider adding the multiple prop to the accordion if you want to allow multiple items to be open by default.",
44
+ );
45
+ return;
46
+ }
47
+
48
+ this.setContentHeight(content);
49
+ this.setState(item, "open");
50
+ defaultOpenItems.push(item);
51
+ }
52
+ }
53
+ });
54
+ }
55
+
56
+ private setupAccessibility(item: AccordionItem) {
57
+ if (item.trigger && item.content) {
58
+ const triggerId =
59
+ item.trigger.id ||
60
+ `accordion-id-${Math.random().toString(36).substring(2, 9)}`;
61
+ const contentId =
62
+ item.content.id ||
63
+ `accordion-id-${Math.random().toString(36).substring(2, 9)}`;
64
+
65
+ item.trigger.id = triggerId;
66
+ item.trigger.setAttribute("aria-controls", contentId);
67
+
68
+ item.content.id = contentId;
69
+ item.content.setAttribute("aria-labelledby", triggerId);
70
+ item.content.setAttribute("role", "region");
71
+
72
+ this.setState(item, "closed");
73
+ }
74
+ }
75
+
76
+ private setupEventListeners(item: AccordionItem) {
77
+ if (!item.trigger && !item.content) return;
78
+
79
+ item.trigger?.addEventListener("click", () =>
80
+ this.toggleAccordionItem(item),
81
+ );
82
+ item.trigger?.addEventListener("keydown", (e) =>
83
+ this.handleKeydown(e, item),
84
+ );
85
+ }
86
+
87
+ private toggleAccordionItem(item: AccordionItem) {
88
+ if (item.trigger?.getAttribute("aria-expanded") === "true") {
89
+ this.closeAccordionItem(item);
90
+ } else {
91
+ if (this.wrapper.dataset.multiple !== "true") {
92
+ this.closeAllContents();
93
+ }
94
+ this.openAccordionItem(item);
95
+ }
96
+ }
97
+
98
+ private openAccordionItem(item: AccordionItem) {
99
+ this.setState(item, "open");
100
+ if (item.content) {
101
+ this.setContentHeight(item.content);
102
+ }
103
+ }
104
+
105
+ private closeAccordionItem(item: AccordionItem) {
106
+ this.setState(item, "closed");
107
+ item.content!.style.maxHeight = "0px";
108
+ }
109
+
110
+ private closeAllContents() {
111
+ this.items?.forEach((item) => {
112
+ this.closeAccordionItem(item);
113
+ });
114
+ }
115
+
116
+ private handleKeydown(event: KeyboardEvent, item: AccordionItem) {
117
+ const items = Array.from(this.items || []);
118
+ const currentItemIndex = items.indexOf(item);
119
+
120
+ const keyActions: Record<string, () => void> = {
121
+ ArrowDown: () => this.setFocusItem(items, currentItemIndex + 1),
122
+ ArrowUp: () => this.setFocusItem(items, currentItemIndex - 1),
123
+ Home: () => this.setFocusItem(items, 0),
124
+ End: () => this.setFocusItem(items, items.length - 1),
125
+ };
126
+
127
+ const action = keyActions[event.key];
128
+ if (action) {
129
+ event.preventDefault();
130
+ action();
131
+ }
132
+ }
133
+
134
+ private setFocusItem(items: AccordionItem[], index: number) {
135
+ const newIndex = (index + items.length) % items.length;
136
+ if (items[newIndex].trigger) {
137
+ items[newIndex].trigger.focus();
138
+ }
139
+ }
140
+
141
+ private setContentHeight(content: HTMLElement) {
142
+ const height = content.scrollHeight + "px";
143
+ content.style.maxHeight = height;
144
+ }
145
+
146
+ private setState(item: AccordionItem, state: "closed" | "open") {
147
+ item.trigger?.setAttribute("data-state", state);
148
+ item.trigger?.setAttribute("aria-expanded", `${state === "open"}`);
149
+ item.content?.setAttribute("data-state", state);
150
+ }
151
+ }
@@ -1,6 +1,6 @@
1
- import Accordion from "./Accordion.astro";
2
- import AccordionItem from "./AccordionItem.astro";
3
- import AccordionTrigger from "./AccordionTrigger.astro";
4
- import AccordionContent from "./AcordionContent.astro";
5
-
6
- export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
1
+ import Accordion from "./Accordion.astro";
2
+ import AccordionItem from "./AccordionItem.astro";
3
+ import AccordionTrigger from "./AccordionTrigger.astro";
4
+ import AccordionContent from "./AcordionContent.astro";
5
+
6
+ export { Accordion, AccordionContent, AccordionItem, AccordionTrigger };
@@ -0,0 +1,15 @@
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"figcaption"> {}
6
+
7
+ const { class: className, ...attrs } = Astro.props;
8
+ ---
9
+
10
+ <figcaption
11
+ class={cn("text-foreground absolute bottom-4 left-4", className)}
12
+ {...attrs}
13
+ >
14
+ <slot />
15
+ </figcaption>
@@ -0,0 +1,70 @@
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props
6
+ extends HTMLAttributes<"figure">,
7
+ Pick<
8
+ HTMLAttributes<"img">,
9
+ "src" | "alt" | "width" | "height" | "loading"
10
+ > {
11
+ blur?: number;
12
+ saturate?: number;
13
+ contrast?: number;
14
+ brightness?: number;
15
+ opacity?: number;
16
+ }
17
+
18
+ const {
19
+ class: className,
20
+ src,
21
+ alt,
22
+ width,
23
+ height,
24
+ loading,
25
+ blur = 15,
26
+ saturate = 150,
27
+ contrast = 100,
28
+ brightness = 100,
29
+ opacity = 80,
30
+ ...attrs
31
+ } = Astro.props;
32
+ ---
33
+
34
+ <figure
35
+ class={cn("relative z-1 inline-block rounded-md", className)}
36
+ style={{
37
+ "--blur": `${blur}px`,
38
+ "--saturate": `${saturate}%`,
39
+ "--contrast": `${contrast}%`,
40
+ "--brightness": `${brightness}%`,
41
+ "--opacity": `${opacity}%`,
42
+ }}
43
+ {...attrs}
44
+ >
45
+ <div
46
+ class={cn(
47
+ "absolute inset-0 z-[-1] blur-(--blur) saturate-(--saturate) contrast-(--contrast) brightness-(--brightness) opacity-(--opacity)",
48
+ )}
49
+ aria-hidden="true"
50
+ >
51
+ <img
52
+ src={src}
53
+ alt={alt}
54
+ width={width}
55
+ height={height}
56
+ class="h-full w-full rounded-[inherit] object-cover"
57
+ />
58
+ </div>
59
+
60
+ <img
61
+ src={src}
62
+ alt={alt}
63
+ width={width}
64
+ height={height}
65
+ loading={loading}
66
+ class="relative block rounded-[inherit] object-cover"
67
+ />
68
+
69
+ <slot />
70
+ </figure>
@@ -0,0 +1,4 @@
1
+ import AmbientFigcaption from "./AmbientFigcaption.astro";
2
+ import AmbientImage from "./AmbientImage.astro";
3
+
4
+ export { AmbientFigcaption, AmbientImage };
@@ -0,0 +1,21 @@
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+ import type { VariantProps } from "class-variance-authority";
5
+ import { buttonGroupVariants } from "./buttonGroupVariants";
6
+
7
+ interface Props
8
+ extends HTMLAttributes<"div">,
9
+ VariantProps<typeof buttonGroupVariants> {}
10
+
11
+ const { orientation, ...attrs } = Astro.props;
12
+ ---
13
+
14
+ <div
15
+ role="group"
16
+ data-button-group
17
+ class={cn(buttonGroupVariants({ orientation }))}
18
+ {...attrs}
19
+ >
20
+ <slot />
21
+ </div>