@abhivarde/svelte-drawer 0.0.22 → 0.0.24

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/README.md CHANGED
@@ -13,6 +13,8 @@ A drawer component for Svelte 5, inspired by [Vaul](https://github.com/emilkowal
13
13
  - ✅ Prebuilt variants (**default, sheet, dialog, minimal, sidebar**)
14
14
  - ✅ **Drag handle component** with auto-adaptive orientation
15
15
  - ✅ **Snap points** for iOS-like multi-height drawers
16
+ - ✅ **Portal rendering** to escape z-index conflicts
17
+ - ✅ **Optional header & footer** components for quick setup
16
18
  - ✅ Nested drawer support
17
19
  - ✅ Scrollable content areas
18
20
  - ✅ Keyboard shortcuts (**Escape to close**, Tab navigation)
@@ -53,6 +55,42 @@ npm install @abhivarde/svelte-drawer
53
55
  </Drawer>
54
56
  ```
55
57
 
58
+
59
+ ### Backdrop Blur
60
+
61
+ Add a premium blur effect to the overlay background:
62
+ ```svelte
63
+ <script>
64
+ import { Drawer, DrawerOverlay, DrawerContent, DrawerHandle } from '@abhivarde/svelte-drawer';
65
+
66
+ let open = $state(false);
67
+ </script>
68
+
69
+ <Drawer bind:open>
70
+ <!-- Default medium blur -->
71
+ <DrawerOverlay blur class="fixed inset-0 bg-black/40" />
72
+
73
+ <!-- Or specify blur intensity -->
74
+ <!-- <DrawerOverlay blur="sm" class="fixed inset-0 bg-black/40" /> -->
75
+ <!-- <DrawerOverlay blur="lg" class="fixed inset-0 bg-black/40" /> -->
76
+ <!-- <DrawerOverlay blur="xl" class="fixed inset-0 bg-black/40" /> -->
77
+
78
+ <DrawerContent class="fixed bottom-0 left-0 right-0 bg-white rounded-t-lg p-4">
79
+ <DrawerHandle class="mb-8" />
80
+ <h2>Blurred Backdrop</h2>
81
+ <p>Notice the premium blur effect behind this drawer.</p>
82
+ </DrawerContent>
83
+ </Drawer>
84
+ ```
85
+
86
+ **Available blur intensities:**
87
+ - `blur={true}` or `blur="md"` - Medium blur (default)
88
+ - `blur="sm"` - Small blur
89
+ - `blur="lg"` - Large blur
90
+ - `blur="xl"` - Extra large blur
91
+ - `blur="2xl"` - 2x extra large blur
92
+ - `blur="3xl"` - 3x extra large blur
93
+
56
94
  ### Side Drawer
57
95
 
58
96
  ```svelte
@@ -401,6 +439,7 @@ Overlay component that appears behind the drawer.
401
439
  **Props:**
402
440
 
403
441
  - `class` (string, optional) - CSS classes for styling
442
+ - `blur` (boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl', optional) - Enable backdrop blur effect
404
443
 
405
444
  ### DrawerContent
406
445
 
@@ -485,6 +524,10 @@ Optional pre-styled footer component.
485
524
 
486
525
  Visit [drawer.abhivarde.in](https://drawer.abhivarde.in) to see live examples.
487
526
 
527
+ ## Star History
528
+
529
+ [![Star History Chart](https://api.star-history.com/svg?repos=AbhiVarde/svelte-drawer&type=Date)](https://star-history.com/#AbhiVarde/svelte-drawer&Date)
530
+
488
531
  ## License
489
532
 
490
533
  This project is licensed under the MIT License.
@@ -492,4 +535,4 @@ See the [LICENSE](./LICENSE) file for details.
492
535
 
493
536
  ## Credits
494
537
 
495
- Inspired by [Vaul](https://github.com/emilkowalski/vaul) by Emil Kowalski.
538
+ Inspired by [Vaul](https://github.com/emilkowalski/vaul) by Emil Kowalski.
@@ -12,11 +12,11 @@
12
12
  } = $props();
13
13
  </script>
14
14
 
15
- <div class="p-4 border-t border-gray-200 mt-auto {className}" {...restProps}>
15
+ <div class="border-t border-gray-200 p-4 mt-auto {className}" {...restProps}>
16
16
  {#if children}
17
17
  {@render children()}
18
18
  {:else if actions}
19
- <div class="flex gap-3 justify-end">
19
+ <div class="flex justify-end gap-3">
20
20
  {@render actions()}
21
21
  </div>
22
22
  {/if}
@@ -1,4 +1,6 @@
1
1
  <script lang="ts">
2
+ import { getContext } from "svelte";
3
+
2
4
  let {
3
5
  title,
4
6
  description,
@@ -17,55 +19,49 @@
17
19
  [key: string]: any;
18
20
  } = $props();
19
21
 
20
- import { getContext } from "svelte";
21
-
22
22
  const drawer = getContext<any>("drawer");
23
23
 
24
24
  function handleClose() {
25
- if (onClose) {
26
- onClose();
27
- } else {
28
- drawer?.closeDrawer();
29
- }
25
+ if (onClose) onClose();
26
+ else drawer?.closeDrawer();
30
27
  }
31
28
  </script>
32
29
 
33
- <div
34
- class="flex items-center justify-between p-4 border-b border-gray-200 {className}"
35
- {...restProps}
36
- >
37
- {#if children}
38
- {@render children()}
39
- {:else}
40
- <div class="flex-1">
41
- {#if title}
42
- <h2 class="text-lg font-semibold text-gray-900">{title}</h2>
43
- {/if}
44
- {#if description}
45
- <p class="text-sm text-gray-600 mt-1">{description}</p>
46
- {/if}
47
- </div>
30
+ <div class="border-b border-gray-200 p-4 {className}" {...restProps}>
31
+ <div class="flex items-start justify-between gap-4">
32
+ {#if children}
33
+ {@render children()}
34
+ {:else}
35
+ <div class="flex-1">
36
+ {#if title}
37
+ <h2 class="text-lg font-semibold text-gray-900">{title}</h2>
38
+ {/if}
39
+ {#if description}
40
+ <p class="text-sm text-gray-600 mt-1">{description}</p>
41
+ {/if}
42
+ </div>
48
43
 
49
- {#if showCloseButton}
50
- <button
51
- onclick={handleClose}
52
- class="p-2 rounded-md hover:bg-gray-100 transition-colors"
53
- aria-label="Close drawer"
54
- >
55
- <svg
56
- class="w-5 h-5 text-gray-500"
57
- fill="none"
58
- stroke="currentColor"
59
- viewBox="0 0 24 24"
44
+ {#if showCloseButton}
45
+ <button
46
+ onclick={handleClose}
47
+ class="p-2 rounded-md hover:bg-gray-100 transition-colors"
48
+ aria-label="Close drawer"
60
49
  >
61
- <path
62
- stroke-linecap="round"
63
- stroke-linejoin="round"
64
- stroke-width="2"
65
- d="M6 18L18 6M6 6l12 12"
66
- />
67
- </svg>
68
- </button>
50
+ <svg
51
+ class="w-5 h-5 text-gray-500"
52
+ fill="none"
53
+ stroke="currentColor"
54
+ viewBox="0 0 24 24"
55
+ >
56
+ <path
57
+ stroke-linecap="round"
58
+ stroke-linejoin="round"
59
+ stroke-width="2"
60
+ d="M6 18L18 6M6 6l12 12"
61
+ />
62
+ </svg>
63
+ </button>
64
+ {/if}
69
65
  {/if}
70
- {/if}
66
+ </div>
71
67
  </div>
@@ -1,33 +1,47 @@
1
1
  <script>
2
- import { getContext } from 'svelte';
3
-
4
- let {
5
- class: className = '',
6
- ...restProps
7
- } = $props();
8
-
9
- const drawer = getContext('drawer');
10
-
11
- /**
12
- * @param {KeyboardEvent} e
13
- */
14
- function handleKeydown(e) {
15
- if (e.key === 'Enter' || e.key === ' ') {
16
- e.preventDefault();
17
- drawer.closeDrawer();
18
- }
19
- }
2
+ import { getContext } from "svelte";
3
+
4
+ let { class: className = "", blur = false, ...restProps } = $props();
5
+
6
+ const drawer = getContext("drawer");
7
+
8
+ const blurClass = $derived(() => {
9
+ if (!blur) return "";
10
+
11
+ if (blur === true) return "backdrop-blur-md";
12
+
13
+ const blurMap = {
14
+ sm: "backdrop-blur-sm",
15
+ md: "backdrop-blur-md",
16
+ lg: "backdrop-blur-lg",
17
+ xl: "backdrop-blur-xl",
18
+ "2xl": "backdrop-blur-2xl",
19
+ "3xl": "backdrop-blur-3xl",
20
+ };
21
+
22
+ return blurMap[blur] || "backdrop-blur-md";
23
+ });
24
+
25
+ /**
26
+ * @param {KeyboardEvent} e
27
+ */
28
+ function handleKeydown(e) {
29
+ if (e.key === "Enter" || e.key === " ") {
30
+ e.preventDefault();
31
+ drawer.closeDrawer();
32
+ }
33
+ }
20
34
  </script>
21
35
 
22
36
  {#if drawer.open}
23
- <div
24
- class="fixed inset-0 bg-black/40 cursor-pointer {className}"
25
- style="opacity: {drawer.overlayOpacity.current}; z-index: 40;"
26
- onclick={drawer.closeDrawer}
27
- onkeydown={handleKeydown}
28
- role="button"
29
- tabindex="0"
30
- aria-label="Close drawer"
31
- {...restProps}
32
- ></div>
33
- {/if}
37
+ <div
38
+ class="fixed inset-0 bg-black/40 cursor-pointer {blurClass()} {className}"
39
+ style="opacity: {drawer.overlayOpacity.current}; z-index: 40;"
40
+ onclick={drawer.closeDrawer}
41
+ onkeydown={handleKeydown}
42
+ role="button"
43
+ tabindex="0"
44
+ aria-label="Close drawer"
45
+ {...restProps}
46
+ ></div>
47
+ {/if}
@@ -5,7 +5,9 @@ type DrawerOverlay = {
5
5
  };
6
6
  declare const DrawerOverlay: import("svelte").Component<{
7
7
  class?: string;
8
+ blur?: boolean;
8
9
  } & Record<string, any>, {}, "">;
9
10
  type $$ComponentProps = {
10
11
  class?: string;
12
+ blur?: boolean;
11
13
  } & Record<string, any>;
package/dist/types.d.ts CHANGED
@@ -15,6 +15,7 @@ export interface DrawerContentProps {
15
15
  }
16
16
  export interface DrawerOverlayProps {
17
17
  class?: string;
18
+ blur?: boolean | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl";
18
19
  }
19
20
  export interface DrawerHandleProps {
20
21
  class?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhivarde/svelte-drawer",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "description": "A drawer component for Svelte 5, inspired by Vaul",
5
5
  "author": "Abhi Varde",
6
6
  "license": "MIT",