@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
|
+
[](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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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}
|
package/dist/types.d.ts
CHANGED