@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
@@ -0,0 +1,34 @@
1
+ import { cva } from "class-variance-authority";
2
+
3
+ const baseClass =
4
+ "inline-flex items-stretch w-fit *:focus:relative *:focus:z-10 has-[>[data-button-group]]:gap-2";
5
+ const buttonGroupVariants = cva(baseClass, {
6
+ variants: {
7
+ orientation: {
8
+ vertical: [
9
+ "flex-row",
10
+ "[&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0",
11
+ "[&>*:not(:last-child):not(:has(+_script:last-child))]:rounded-r-none",
12
+ "[&>*:not(:first-child)>select]:rounded-l-none [&>*:not(:first-child)>select]:border-l-0",
13
+ "[&>*:not(:last-child):not(:has(+_script:last-child))>select]:rounded-r-none",
14
+ "[&>*:not(:first-child)>[data-trigger]]:rounded-l-none [&>*:not(:first-child)>[data-trigger]]:border-l-0",
15
+ "[&>*:not(:last-child):not(:has(+_script:last-child))>[data-trigger]]:rounded-r-none",
16
+ ],
17
+
18
+ horizontal: [
19
+ "flex-col",
20
+ "[&>*:not(:first-child)]:rounded-t-none [&>*:not(:first-child)]:border-t-0",
21
+ "[&>*:not(:last-child):not(:has(+_script:last-child))]:rounded-b-none",
22
+ "[&>*:not(:first-child)>select]:rounded-t-none [&>*:not(:first-child)>select]:border-t-0",
23
+ "[&>*:not(:last-child):not(:has(+_script:last-child))>select]:rounded-b-none",
24
+ "[&>*:not(:first-child)>[data-trigger]]:rounded-t-none [&>*:not(:first-child)>[data-trigger]]:border-t-0",
25
+ "[&>*:not(:last-child):not(:has(+_script:last-child))>[data-trigger]]:rounded-b-none",
26
+ ],
27
+ },
28
+ },
29
+ defaultVariants: {
30
+ orientation: "vertical",
31
+ },
32
+ });
33
+
34
+ export { buttonGroupVariants };
@@ -0,0 +1,3 @@
1
+ import ButtonGroup from "./ButtonGroup.astro";
2
+
3
+ export { ButtonGroup };
@@ -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
- isOpen?: boolean;
7
- }
8
-
9
- const { class: className, isOpen = false, ...attrs } = Astro.props;
10
- ---
11
-
12
- <div
13
- {...attrs}
14
- data-collapsible
15
- data-open={isOpen}
16
- class={cn("w-full", className)}
17
- >
18
- <slot />
19
- </div>
20
-
21
- <script>
22
- import { Collapsible } from "./collapsible";
23
-
24
- function init() {
25
- const collapsibles =
26
- document.querySelectorAll<HTMLElement>("[data-collapsible]");
27
- collapsibles.forEach((collapsible) => {
28
- new Collapsible(collapsible);
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
+ isOpen?: boolean;
7
+ }
8
+
9
+ const { class: className, isOpen = false, ...attrs } = Astro.props;
10
+ ---
11
+
12
+ <div
13
+ {...attrs}
14
+ data-collapsible
15
+ data-open={isOpen}
16
+ class={cn("w-full", className)}
17
+ >
18
+ <slot />
19
+ </div>
20
+
21
+ <script>
22
+ import { Collapsible } from "./collapsible";
23
+
24
+ function init() {
25
+ const collapsibles =
26
+ document.querySelectorAll<HTMLElement>("[data-collapsible]");
27
+ collapsibles.forEach((collapsible) => {
28
+ new Collapsible(collapsible);
29
+ });
30
+ }
31
+
32
+ init();
33
+ document.addEventListener("astro:page-load", () => init());
34
+ </script>
@@ -1,20 +1,20 @@
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
- data-collapsible-content
12
- class={cn(
13
- "overflow-hidden transition-all duration-300 ease-in-out",
14
- className,
15
- )}
16
- hidden
17
- {...attrs}
18
- >
19
- <slot />
20
- </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
+ data-collapsible-content
12
+ class={cn(
13
+ "overflow-hidden transition-all duration-300 ease-in-out",
14
+ className,
15
+ )}
16
+ hidden
17
+ {...attrs}
18
+ >
19
+ <slot />
20
+ </div>
@@ -1,81 +1,81 @@
1
- export class Collapsible {
2
- private wrapper: HTMLElement;
3
- private content: HTMLElement | null;
4
- private trigger: HTMLElement | null;
5
-
6
- constructor(collapsibleWrapper: HTMLElement) {
7
- this.wrapper = collapsibleWrapper;
8
- this.content = this.wrapper.querySelector("[data-collapsible-content]");
9
- this.trigger = this.wrapper.querySelector("[data-trigger]");
10
-
11
- this.init();
12
- }
13
-
14
- private init() {
15
- this.setupAccessibility();
16
- this.setupEventListeners();
17
- }
18
-
19
- private setupAccessibility() {
20
- if (!this.trigger || !this.content) return;
21
-
22
- const id =
23
- this.content.id ||
24
- `collapsible-id-${Math.random().toString(36).substring(2, 9)}`;
25
-
26
- this.content.id = id;
27
- this.trigger.setAttribute("aria-controls", id);
28
-
29
- if (this.wrapper.dataset.open === "true") {
30
- this.setState("open");
31
- this.content?.removeAttribute("hidden");
32
- const height = this.content?.scrollHeight + "px";
33
- this.content!.style.maxHeight = height;
34
- } else {
35
- this.setState("closed");
36
- this.content?.setAttribute("hidden", "");
37
- this.content!.style.maxHeight = "0px";
38
- }
39
- }
40
-
41
- private setupEventListeners() {
42
- this.trigger?.addEventListener("click", () => this.toggleCollapsible());
43
- this.trigger?.addEventListener("keydown", (e) => this.handleKeyDown(e));
44
- }
45
-
46
- private toggleCollapsible() {
47
- if (this.trigger?.dataset.state === "open") {
48
- this.closeCollapsible();
49
- } else {
50
- this.openCollapsible();
51
- }
52
- }
53
-
54
- private openCollapsible() {
55
- this.content?.removeAttribute("hidden");
56
- this.setState("open");
57
- const height = this.content?.scrollHeight + "px";
58
- this.content!.style.maxHeight = height;
59
- }
60
-
61
- private closeCollapsible() {
62
- this.setState("closed");
63
- this.content!.style.maxHeight = "0px";
64
- window.setTimeout(() => {
65
- this.content?.setAttribute("hidden", "");
66
- }, 300);
67
- }
68
-
69
- private setState(state: "closed" | "open") {
70
- this.trigger?.setAttribute("data-state", state);
71
- this.trigger?.setAttribute("aria-expanded", `${state === "open"}`);
72
- this.content?.setAttribute("data-state", state);
73
- }
74
-
75
- private handleKeyDown = (event: KeyboardEvent) => {
76
- if (event.key === "Escape" && this.content!.dataset.status === "open") {
77
- this.closeCollapsible();
78
- event.preventDefault();
79
- }
80
- };
81
- }
1
+ export class Collapsible {
2
+ private wrapper: HTMLElement;
3
+ private content: HTMLElement | null;
4
+ private trigger: HTMLElement | null;
5
+
6
+ constructor(collapsibleWrapper: HTMLElement) {
7
+ this.wrapper = collapsibleWrapper;
8
+ this.content = this.wrapper.querySelector("[data-collapsible-content]");
9
+ this.trigger = this.wrapper.querySelector("[data-trigger]");
10
+
11
+ this.init();
12
+ }
13
+
14
+ private init() {
15
+ this.setupAccessibility();
16
+ this.setupEventListeners();
17
+ }
18
+
19
+ private setupAccessibility() {
20
+ if (!this.trigger || !this.content) return;
21
+
22
+ const id =
23
+ this.content.id ||
24
+ `collapsible-id-${Math.random().toString(36).substring(2, 9)}`;
25
+
26
+ this.content.id = id;
27
+ this.trigger.setAttribute("aria-controls", id);
28
+
29
+ if (this.wrapper.dataset.open === "true") {
30
+ this.setState("open");
31
+ this.content?.removeAttribute("hidden");
32
+ const height = this.content?.scrollHeight + "px";
33
+ this.content!.style.maxHeight = height;
34
+ } else {
35
+ this.setState("closed");
36
+ this.content?.setAttribute("hidden", "");
37
+ this.content!.style.maxHeight = "0px";
38
+ }
39
+ }
40
+
41
+ private setupEventListeners() {
42
+ this.trigger?.addEventListener("click", () => this.toggleCollapsible());
43
+ this.trigger?.addEventListener("keydown", (e) => this.handleKeyDown(e));
44
+ }
45
+
46
+ private toggleCollapsible() {
47
+ if (this.trigger?.dataset.state === "open") {
48
+ this.closeCollapsible();
49
+ } else {
50
+ this.openCollapsible();
51
+ }
52
+ }
53
+
54
+ private openCollapsible() {
55
+ this.content?.removeAttribute("hidden");
56
+ this.setState("open");
57
+ const height = this.content?.scrollHeight + "px";
58
+ this.content!.style.maxHeight = height;
59
+ }
60
+
61
+ private closeCollapsible() {
62
+ this.setState("closed");
63
+ this.content!.style.maxHeight = "0px";
64
+ window.setTimeout(() => {
65
+ this.content?.setAttribute("hidden", "");
66
+ }, 300);
67
+ }
68
+
69
+ private setState(state: "closed" | "open") {
70
+ this.trigger?.setAttribute("data-state", state);
71
+ this.trigger?.setAttribute("aria-expanded", `${state === "open"}`);
72
+ this.content?.setAttribute("data-state", state);
73
+ }
74
+
75
+ private handleKeyDown = (event: KeyboardEvent) => {
76
+ if (event.key === "Escape" && this.content!.dataset.status === "open") {
77
+ this.closeCollapsible();
78
+ event.preventDefault();
79
+ }
80
+ };
81
+ }
@@ -1,4 +1,4 @@
1
- import Collapsible from "./Collapsible.astro";
2
- import CollapsibleContent from "./CollapsibleContent.astro";
3
-
4
- export { Collapsible, CollapsibleContent };
1
+ import Collapsible from "./Collapsible.astro";
2
+ import CollapsibleContent from "./CollapsibleContent.astro";
3
+
4
+ export { Collapsible, CollapsibleContent };
@@ -0,0 +1,55 @@
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+
5
+ interface Props extends HTMLAttributes<"figure"> {}
6
+
7
+ const { class: className, ...attrs } = Astro.props;
8
+ ---
9
+
10
+ <figure
11
+ data-diff
12
+ class={cn(
13
+ "diff relative grid aspect-video w-full overflow-hidden select-none grid-cols-[auto_1fr] grid-rows-[1fr_1.8rem_1fr]",
14
+ className,
15
+ )}
16
+ style={{
17
+ "container-type": "inline-size",
18
+ }}
19
+ tabindex="0"
20
+ {...attrs}
21
+ >
22
+ <slot />
23
+ <div
24
+ data-resize
25
+ class="bg-background relative isolate z-2 col-start-1 row-start-2 h-3 w-[50cqi] max-w-[calc(100cqi-1rem)] min-w-4 cursor-ew-resize resize-x overflow-hidden opacity-0"
26
+ style={{
27
+ "clip-path": "inset(calc(100% - 0.75rem) 0 0 calc(100% - 0.75rem))",
28
+ "transform-origin": "100% 100%",
29
+ transition: "min-width 0.3s ease-out, max-width 0.3s ease-out",
30
+ transform: "scaleY(5) translate(0.32rem, 50%)",
31
+ }}
32
+ >
33
+ </div>
34
+ </figure>
35
+
36
+ <style is:global>
37
+ [data-diff-item]:nth-child(2)::after {
38
+ content: "";
39
+ position: absolute;
40
+ top: 50%;
41
+ bottom: 0;
42
+ right: 1px;
43
+ translate: 50% -50%;
44
+ width: 1rem;
45
+ height: 1.8rem;
46
+ background: var(--color-background);
47
+ z-index: 2;
48
+ pointer-events: none;
49
+ border-radius: 25%;
50
+ }
51
+
52
+ [data-diff-item]:nth-of-type(n + 3) {
53
+ display: none;
54
+ }
55
+ </style>
@@ -0,0 +1,21 @@
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
+ data-diff-item
12
+ class={cn(
13
+ "first:border-background relative col-start-1 row-[1/span_3] *:pointer-events-none *:absolute *:inset-0 *:h-full *:w-[100cqi] *:max-w-none *:object-cover *:object-center first:z-1 first:overflow-hidden first:border-e-2 first:border-solid",
14
+ className,
15
+ )}
16
+ role="img"
17
+ tabindex="0"
18
+ {...attrs}
19
+ >
20
+ <slot />
21
+ </div>
@@ -0,0 +1,4 @@
1
+ import Diff from "./Diff.astro";
2
+ import DiffItem from "./DiffItem.astro";
3
+
4
+ export { Diff, DiffItem };
@@ -1,74 +1,74 @@
1
- ---
2
- import { cn } from "@/utils/cn";
3
- import type { HTMLAttributes } from "astro/types";
4
- import type { VariantProps } from "class-variance-authority";
5
- import { drawerVariants } from "./drawerVariants";
6
-
7
- interface Props
8
- extends HTMLAttributes<"div">,
9
- VariantProps<typeof drawerVariants> {
10
- showCloseButton?: boolean;
11
- backdrop?: boolean;
12
- allowOutsideClick?: boolean;
13
- }
14
-
15
- const {
16
- class: className,
17
- showCloseButton = true,
18
- backdrop = true,
19
- allowOutsideClick = true,
20
- position = "right",
21
- size = "sm",
22
- ...attrs
23
- } = Astro.props;
24
- ---
25
-
26
- {
27
- backdrop && (
28
- <div
29
- aria-hidden="true"
30
- data-state="closed"
31
- data-drawer-backdrop
32
- class="bg-background fixed inset-0 left-0 top-0 z-50 hidden h-dvh w-full transition-opacity duration-100 data-[state=closed]:opacity-0 data-[state=open]:opacity-80"
33
- />
34
- )
35
- }
36
-
37
- <div
38
- data-drawer-content
39
- aria-hidden="true"
40
- data-state="closed"
41
- data-position={position}
42
- data-show-close-button={showCloseButton}
43
- data-allow-outside-click={allowOutsideClick}
44
- class={cn(drawerVariants({ position, size, className }))}
45
- {...attrs}
46
- >
47
- {
48
- showCloseButton && (
49
- <button
50
- class="text-foreground hover:bg-muted absolute right-3 top-3 cursor-pointer rounded-lg p-1 transition-colors duration-150"
51
- aria-label="close modal"
52
- data-close
53
- >
54
- <svg
55
- xmlns="http://www.w3.org/2000/svg"
56
- viewBox="0 0 24 24"
57
- fill="none"
58
- stroke="currentColor"
59
- stroke-width="2"
60
- stroke-linecap="round"
61
- stroke-linejoin="round"
62
- class="size-4"
63
- >
64
- <>
65
- <path stroke="none" d="M0 0h24v24H0z" fill="none" />
66
- <path d="M18 6l-12 12" />
67
- <path d="M6 6l12 12" />
68
- </>
69
- </svg>
70
- </button>
71
- )
72
- }
73
- <slot />
74
- </div>
1
+ ---
2
+ import { cn } from "@/utils/cn";
3
+ import type { HTMLAttributes } from "astro/types";
4
+ import type { VariantProps } from "class-variance-authority";
5
+ import { drawerVariants } from "./drawerVariants";
6
+
7
+ interface Props
8
+ extends HTMLAttributes<"div">,
9
+ VariantProps<typeof drawerVariants> {
10
+ showCloseButton?: boolean;
11
+ backdrop?: boolean;
12
+ allowOutsideClick?: boolean;
13
+ }
14
+
15
+ const {
16
+ class: className,
17
+ showCloseButton = true,
18
+ backdrop = true,
19
+ allowOutsideClick = true,
20
+ position = "right",
21
+ size = "sm",
22
+ ...attrs
23
+ } = Astro.props;
24
+ ---
25
+
26
+ {
27
+ backdrop && (
28
+ <div
29
+ aria-hidden="true"
30
+ data-state="closed"
31
+ data-drawer-backdrop
32
+ class="bg-background fixed inset-0 left-0 top-0 z-50 hidden h-dvh w-full transition-opacity duration-100 data-[state=closed]:opacity-0 data-[state=open]:opacity-80"
33
+ />
34
+ )
35
+ }
36
+
37
+ <div
38
+ data-drawer-content
39
+ aria-hidden="true"
40
+ data-state="closed"
41
+ data-position={position}
42
+ data-show-close-button={showCloseButton}
43
+ data-allow-outside-click={allowOutsideClick}
44
+ class={cn(drawerVariants({ position, size, className }))}
45
+ {...attrs}
46
+ >
47
+ {
48
+ showCloseButton && (
49
+ <button
50
+ class="text-foreground hover:bg-muted absolute right-3 top-3 cursor-pointer rounded-lg p-1 transition-colors duration-150"
51
+ aria-label="close modal"
52
+ data-close
53
+ >
54
+ <svg
55
+ xmlns="http://www.w3.org/2000/svg"
56
+ viewBox="0 0 24 24"
57
+ fill="none"
58
+ stroke="currentColor"
59
+ stroke-width="2"
60
+ stroke-linecap="round"
61
+ stroke-linejoin="round"
62
+ class="size-4"
63
+ >
64
+ <>
65
+ <path stroke="none" d="M0 0h24v24H0z" fill="none" />
66
+ <path d="M18 6l-12 12" />
67
+ <path d="M6 6l12 12" />
68
+ </>
69
+ </svg>
70
+ </button>
71
+ )
72
+ }
73
+ <slot />
74
+ </div>