@hashrytech/quick-components-kit 0.6.0 → 0.7.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @hashrytech/quick-components-kit
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - feat: Adding close button state to hamburger menu
8
+
9
+ ## 0.6.1
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: renaming transitionPosition property for drawer to position
14
+
3
15
  ## 0.6.0
4
16
 
5
17
  ### Minor Changes
@@ -12,7 +12,7 @@
12
12
  ariaLabel?: string;
13
13
  transitionDuration?: number;
14
14
  transitionDistance?: number;
15
- transitionPosition?: "left" | "right" | "top" | "bottom";
15
+ position?: "left" | "right" | "top" | "bottom";
16
16
  overlayClasses?: string;
17
17
  children?: Snippet;
18
18
  class?: ClassNameValue;
@@ -21,11 +21,11 @@
21
21
  </script>
22
22
 
23
23
  <script lang="ts">
24
- let {open=$bindable(false), escapeKeyClose=true, disableBodyScroll=true, ariaLabel="Drawer", transitionPosition="left", transitionDuration=200, transitionDistance=240, overlayClasses="", children, ...props}: DrawerProps = $props();
24
+ let {open=$bindable(false), escapeKeyClose=true, disableBodyScroll=true, ariaLabel="Drawer", position="left", transitionDuration=200, transitionDistance=240, overlayClasses="", children, ...props}: DrawerProps = $props();
25
25
 
26
26
  const transitionProperties = {
27
- x: transitionPosition == "left" ? -transitionDistance : transitionPosition == "right" ? transitionDistance : 0,
28
- y: transitionPosition == "top" ? -transitionDistance : transitionPosition == "bottom" ? transitionDistance : 0,
27
+ x: position == "left" ? -transitionDistance : position == "right" ? transitionDistance : 0,
28
+ y: position == "top" ? -transitionDistance : position == "bottom" ? transitionDistance : 0,
29
29
  duration: transitionDuration
30
30
  };
31
31
 
@@ -73,7 +73,7 @@
73
73
  <div transition:fade={{duration: transitionDuration}} class={twMerge("fixed inset-0 bg-overlay-primary", overlayClasses)} role="presentation" onclick={() => open = false}></div>
74
74
 
75
75
  <div role="dialog" aria-modal="true" aria-label={ariaLabel} tabindex="{open ? 0 : -1}" aria-hidden="{!open}"
76
- class={twMerge("fixed flex flex-col items-center gap-2 bg-white outline-0 focus:outline-0 active:outline-focus-primary focus:outline-focus-primary overflow-y-auto", postionClasses[transitionPosition], props.class)}
76
+ class={twMerge("fixed flex flex-col items-center gap-2 bg-white outline-0 focus:outline-0 active:outline-focus-primary focus:outline-focus-primary overflow-y-auto", postionClasses[position], props.class)}
77
77
  in:fly={transitionProperties}
78
78
  out:fly={transitionProperties}>
79
79
  {@render children?.()}
@@ -7,7 +7,7 @@ export type DrawerProps = {
7
7
  ariaLabel?: string;
8
8
  transitionDuration?: number;
9
9
  transitionDistance?: number;
10
- transitionPosition?: "left" | "right" | "top" | "bottom";
10
+ position?: "left" | "right" | "top" | "bottom";
11
11
  overlayClasses?: string;
12
12
  children?: Snippet;
13
13
  class?: ClassNameValue;
@@ -1,11 +1,11 @@
1
1
  <script lang="ts" module>
2
2
  import type { ClassNameValue } from 'tailwind-merge';
3
3
 
4
- export type ButtonProps = {
4
+ export type HamburgerProps = {
5
5
  open?: boolean;
6
+ useCloseBtn?: boolean;
6
7
  ariaLabel: string;
7
8
  linesClasses?: string;
8
- numberOfLines?: number;
9
9
  onclick?: (event: MouseEvent) => void;
10
10
  class?: ClassNameValue;
11
11
  };
@@ -15,12 +15,12 @@
15
15
  <script lang="ts">
16
16
  import {twMerge} from 'tailwind-merge';
17
17
 
18
- let { open=$bindable(true), ariaLabel, linesClasses, numberOfLines=3, onclick, ...props }: ButtonProps = $props();
18
+ let { open=$bindable(true), ariaLabel, linesClasses, useCloseBtn=true, onclick, ...props }: HamburgerProps = $props();
19
19
 
20
20
  </script>
21
21
 
22
- <button class={twMerge("p-2 rounded focus:outline-none focus:ring-2 focus:ring-focus-primary cursor-pointer w-fit", props.class)} aria-label={ariaLabel} {onclick}>
23
- <!-- Icon -->
22
+ <!--
23
+ <button class={twMerge("p-2 rounded focus:outline-none focus:ring-2 focus:ring-focus-primary cursor-pointer w-fit", props.class)} aria-label={ariaLabel} {onclick}>
24
24
  <div class="space-y-2">
25
25
  {#each Array(numberOfLines) as _}
26
26
  <span class={twMerge("block w-7 h-0.5 bg-button-primary", linesClasses)}></span>
@@ -28,3 +28,24 @@
28
28
  </div>
29
29
  </button>
30
30
 
31
+ <button class={twMerge("p-2 rounded focus:outline-none focus:ring-2 focus:ring-focus-primary cursor-pointer w-fit", props.class)} aria-label={ariaLabel} {onclick}>
32
+ <div class="relative w-7 h-7">
33
+ <span class={twMerge("absolute left-0 top-1.5 w-full h-0.5 bg-button-primary transition-all duration-300", open ? "rotate-45 top-3.5" : "")}></span>
34
+ <span class={twMerge("absolute left-0 top-3.5 w-full h-0.5 bg-button-primary transition-all duration-300", open ? "opacity-0" : "opacity-100")}></span>
35
+ <span class={twMerge("absolute left-0 bottom-1 w-full h-0.5 bg-button-primary transition-all duration-300", open ? "-rotate-45 top-3.5" : "")}></span>
36
+ </div>
37
+ </button>
38
+ -->
39
+
40
+ <button aria-label={ariaLabel} class={twMerge("p-2 rounded focus:outline-none focus:ring-2 focus:ring-focus-primary cursor-pointer w-fit", props.class)} {onclick}>
41
+ <div class="flex flex-col items-center justify-center size-7 transition-all gap-2">
42
+ <!-- Top bar -->
43
+ <span class={twMerge("h-0.5 w-7 bg-button-primary transition-transform duration-300 origin-center", open && useCloseBtn ? "rotate-45 translate-y-2.5" : "", linesClasses)}></span>
44
+
45
+ <!-- Middle bar -->
46
+ <span class={twMerge("h-0.5 w-7 bg-button-primary transition-opacity duration-300", open && useCloseBtn ? "opacity-0" : "opacity-100", linesClasses)}></span>
47
+
48
+ <!-- Bottom bar -->
49
+ <span class={twMerge("h-0.5 w-7 bg-button-primary transition-transform duration-300 origin-center", open && useCloseBtn ? "-rotate-45 -translate-y-2.5" : "", linesClasses)}></span>
50
+ </div>
51
+ </button>
@@ -1,12 +1,12 @@
1
1
  import type { ClassNameValue } from 'tailwind-merge';
2
- export type ButtonProps = {
2
+ export type HamburgerProps = {
3
3
  open?: boolean;
4
+ useCloseBtn?: boolean;
4
5
  ariaLabel: string;
5
6
  linesClasses?: string;
6
- numberOfLines?: number;
7
7
  onclick?: (event: MouseEvent) => void;
8
8
  class?: ClassNameValue;
9
9
  };
10
- declare const HamburgerMenu: import("svelte").Component<ButtonProps, {}, "open">;
10
+ declare const HamburgerMenu: import("svelte").Component<HamburgerProps, {}, "open">;
11
11
  type HamburgerMenu = ReturnType<typeof HamburgerMenu>;
12
12
  export default HamburgerMenu;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/hashrytech/quick-components-kit.git"
7
7
  },
8
- "version": "0.6.0",
8
+ "version": "0.7.0",
9
9
  "license": "MIT",
10
10
  "author": "Hashry Tech",
11
11
  "files": [