@abhivarde/svelte-drawer 0.0.23 → 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
@@ -55,6 +55,42 @@ npm install @abhivarde/svelte-drawer
55
55
  </Drawer>
56
56
  ```
57
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
+
58
94
  ### Side Drawer
59
95
 
60
96
  ```svelte
@@ -403,6 +439,7 @@ Overlay component that appears behind the drawer.
403
439
  **Props:**
404
440
 
405
441
  - `class` (string, optional) - CSS classes for styling
442
+ - `blur` (boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl', optional) - Enable backdrop blur effect
406
443
 
407
444
  ### DrawerContent
408
445
 
@@ -487,6 +524,10 @@ Optional pre-styled footer component.
487
524
 
488
525
  Visit [drawer.abhivarde.in](https://drawer.abhivarde.in) to see live examples.
489
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
+
490
531
  ## License
491
532
 
492
533
  This project is licensed under the MIT License.
@@ -494,4 +535,4 @@ See the [LICENSE](./LICENSE) file for details.
494
535
 
495
536
  ## Credits
496
537
 
497
- Inspired by [Vaul](https://github.com/emilkowalski/vaul) by Emil Kowalski.
538
+ Inspired by [Vaul](https://github.com/emilkowalski/vaul) by Emil Kowalski.
@@ -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.23",
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",