@abhivarde/svelte-drawer 0.0.11 → 0.0.13

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
@@ -1,10 +1,14 @@
1
1
  # Svelte Drawer
2
2
 
3
+ [![npm version](https://img.shields.io/npm/v/@abhivarde/svelte-drawer)](https://www.npmjs.com/package/@abhivarde/svelte-drawer)
4
+ ![GitHub Repo Views](https://gitviews.com/repo/AbhiVarde/svelte-drawer.svg)
5
+
3
6
  A drawer component for Svelte 5, inspired by [Vaul](https://github.com/emilkowalski/vaul).
4
7
 
5
8
  ## Features
6
9
 
7
- - ✅ Smooth animations using Svelte 5's Tween motion
10
+ - ✅ Smooth animations and **gesture-driven dragging** (mouse & touch)
11
+ - ✅ Mobile-optimized drag handling with **scroll prevention**
8
12
  - ✅ Multiple directions (bottom, top, left, right)
9
13
  - ✅ Prebuilt variants (default, sheet, dialog, minimal, sidebar)
10
14
  - ✅ Nested drawers support
@@ -0,0 +1,33 @@
1
+ <script lang="ts">
2
+ import { getContext } from "svelte";
3
+
4
+ type DrawerContext = {
5
+ direction: "bottom" | "top" | "left" | "right";
6
+ };
7
+
8
+ let { class: className = "", ...restProps } = $props();
9
+
10
+ const drawer = getContext<DrawerContext>("drawer");
11
+
12
+ const isVertical = $derived(
13
+ drawer.direction === "bottom" || drawer.direction === "top"
14
+ );
15
+
16
+ const defaultClasses = $derived(
17
+ isVertical
18
+ ? "mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-gray-300"
19
+ : "my-auto w-1.5 h-12 flex-shrink-0 rounded-full bg-gray-300"
20
+ );
21
+
22
+ const combinedClass = $derived(
23
+ className ? `${defaultClasses} ${className}` : defaultClasses
24
+ );
25
+ </script>
26
+
27
+ <div
28
+ data-drawer-drag
29
+ class={combinedClass}
30
+ aria-hidden="true"
31
+ role="presentation"
32
+ {...restProps}
33
+ ></div>
@@ -0,0 +1,5 @@
1
+ declare const DrawerHandle: import("svelte").Component<{
2
+ class?: string;
3
+ } & Record<string, any>, {}, "">;
4
+ type DrawerHandle = ReturnType<typeof DrawerHandle>;
5
+ export default DrawerHandle;
package/dist/index.d.ts CHANGED
@@ -2,4 +2,5 @@ export { default as Drawer } from "./components/Drawer.svelte";
2
2
  export { default as DrawerContent } from "./components/DrawerContent.svelte";
3
3
  export { default as DrawerOverlay } from "./components/DrawerOverlay.svelte";
4
4
  export { default as DrawerVariants } from "./components/DrawerVariants.svelte";
5
- export type { DrawerProps, DrawerContentProps, DrawerOverlayProps, } from "./types";
5
+ export { default as DrawerHandle } from "./components/DrawerHandle.svelte";
6
+ export type { DrawerProps, DrawerContentProps, DrawerOverlayProps, DrawerHandleProps, DrawerVariant, DrawerVariantsProps, } from "./types";
package/dist/index.js CHANGED
@@ -2,3 +2,4 @@ export { default as Drawer } from "./components/Drawer.svelte";
2
2
  export { default as DrawerContent } from "./components/DrawerContent.svelte";
3
3
  export { default as DrawerOverlay } from "./components/DrawerOverlay.svelte";
4
4
  export { default as DrawerVariants } from "./components/DrawerVariants.svelte";
5
+ export { default as DrawerHandle } from "./components/DrawerHandle.svelte";
package/dist/types.d.ts CHANGED
@@ -11,6 +11,9 @@ export interface DrawerContentProps {
11
11
  export interface DrawerOverlayProps {
12
12
  class?: string;
13
13
  }
14
+ export interface DrawerHandleProps {
15
+ class?: string;
16
+ }
14
17
  export type DrawerVariant = "default" | "sheet" | "dialog" | "minimal" | "sidebar";
15
18
  export interface DrawerVariantsProps {
16
19
  variant?: DrawerVariant;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abhivarde/svelte-drawer",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "A drawer component for Svelte 5, inspired by Vaul",
5
5
  "author": "Abhi Varde",
6
6
  "license": "MIT",