@abhivarde/svelte-drawer 0.0.13 → 0.0.15
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 +65 -4
- package/dist/components/DrawerHandle.svelte +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ A drawer component for Svelte 5, inspired by [Vaul](https://github.com/emilkowal
|
|
|
11
11
|
- ✅ Mobile-optimized drag handling with **scroll prevention**
|
|
12
12
|
- ✅ Multiple directions (bottom, top, left, right)
|
|
13
13
|
- ✅ Prebuilt variants (default, sheet, dialog, minimal, sidebar)
|
|
14
|
+
- ✅ **Drag handle component** with auto-adaptive orientation
|
|
14
15
|
- ✅ Nested drawers support
|
|
15
16
|
- ✅ Scrollable content
|
|
16
17
|
- ✅ Keyboard shortcuts (Escape to close, Tab navigation)
|
|
@@ -31,7 +32,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
31
32
|
|
|
32
33
|
```svelte
|
|
33
34
|
<script>
|
|
34
|
-
import { Drawer, DrawerOverlay, DrawerContent } from '@abhivarde/svelte-drawer';
|
|
35
|
+
import { Drawer, DrawerOverlay, DrawerContent, DrawerHandle } from '@abhivarde/svelte-drawer';
|
|
35
36
|
|
|
36
37
|
let open = $state(false);
|
|
37
38
|
</script>
|
|
@@ -43,6 +44,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
43
44
|
<Drawer bind:open>
|
|
44
45
|
<DrawerOverlay class="fixed inset-0 bg-black/40" />
|
|
45
46
|
<DrawerContent class="fixed bottom-0 left-0 right-0 bg-white rounded-t-lg p-4">
|
|
47
|
+
<DrawerHandle class="mb-8" />
|
|
46
48
|
<h2>Drawer Content</h2>
|
|
47
49
|
<p>This is a drawer component.</p>
|
|
48
50
|
<button onclick={() => open = false}>Close</button>
|
|
@@ -54,7 +56,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
54
56
|
|
|
55
57
|
```svelte
|
|
56
58
|
<script>
|
|
57
|
-
import { Drawer, DrawerOverlay, DrawerContent } from '@abhivarde/svelte-drawer';
|
|
59
|
+
import { Drawer, DrawerOverlay, DrawerContent, DrawerHandle } from '@abhivarde/svelte-drawer';
|
|
58
60
|
|
|
59
61
|
let open = $state(false);
|
|
60
62
|
</script>
|
|
@@ -62,6 +64,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
62
64
|
<Drawer bind:open direction="right">
|
|
63
65
|
<DrawerOverlay class="fixed inset-0 bg-black/40" />
|
|
64
66
|
<DrawerContent class="fixed right-0 top-0 bottom-0 w-80 bg-white p-4">
|
|
67
|
+
<DrawerHandle class="mb-4" />
|
|
65
68
|
<h2>Side Drawer</h2>
|
|
66
69
|
<button onclick={() => open = false}>Close</button>
|
|
67
70
|
</DrawerContent>
|
|
@@ -72,7 +75,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
72
75
|
|
|
73
76
|
```svelte
|
|
74
77
|
<script>
|
|
75
|
-
import { Drawer, DrawerOverlay, DrawerContent } from '@abhivarde/svelte-drawer';
|
|
78
|
+
import { Drawer, DrawerOverlay, DrawerContent, DrawerHandle } from '@abhivarde/svelte-drawer';
|
|
76
79
|
|
|
77
80
|
let open = $state(false);
|
|
78
81
|
|
|
@@ -85,6 +88,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
85
88
|
<Drawer bind:open onOpenChange={handleOpenChange}>
|
|
86
89
|
<DrawerOverlay class="fixed inset-0 bg-black/40" />
|
|
87
90
|
<DrawerContent class="fixed bottom-0 left-0 right-0 bg-white rounded-t-lg p-4">
|
|
91
|
+
<DrawerHandle class="mb-8" />
|
|
88
92
|
<h2>Controlled Drawer</h2>
|
|
89
93
|
</DrawerContent>
|
|
90
94
|
</Drawer>
|
|
@@ -120,7 +124,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
120
124
|
|
|
121
125
|
```svelte
|
|
122
126
|
<script>
|
|
123
|
-
import { Drawer, DrawerOverlay, DrawerVariants } from '@abhivarde/svelte-drawer';
|
|
127
|
+
import { Drawer, DrawerOverlay, DrawerVariants, DrawerHandle } from '@abhivarde/svelte-drawer';
|
|
124
128
|
|
|
125
129
|
let open = $state(false);
|
|
126
130
|
</script>
|
|
@@ -130,6 +134,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
130
134
|
<DrawerOverlay class="fixed inset-0 bg-black/40" />
|
|
131
135
|
<DrawerVariants variant="sheet">
|
|
132
136
|
<div class="p-6">
|
|
137
|
+
<DrawerHandle class="mb-6" />
|
|
133
138
|
<h2>iOS-style Sheet</h2>
|
|
134
139
|
<p>Clean and modern bottom sheet design</p>
|
|
135
140
|
</div>
|
|
@@ -152,6 +157,7 @@ npm install @abhivarde/svelte-drawer
|
|
|
152
157
|
<DrawerOverlay class="fixed inset-0 bg-black/40" />
|
|
153
158
|
<DrawerVariants variant="sidebar">
|
|
154
159
|
<div class="p-6">
|
|
160
|
+
<DrawerHandle class="mb-4" />
|
|
155
161
|
<h2>Sidebar Navigation</h2>
|
|
156
162
|
<p>Side navigation drawer</p>
|
|
157
163
|
</div>
|
|
@@ -159,6 +165,33 @@ npm install @abhivarde/svelte-drawer
|
|
|
159
165
|
</Drawer>
|
|
160
166
|
```
|
|
161
167
|
|
|
168
|
+
### Drag Handle Customization
|
|
169
|
+
|
|
170
|
+
```svelte
|
|
171
|
+
<script>
|
|
172
|
+
import { Drawer, DrawerOverlay, DrawerContent, DrawerHandle } from '@abhivarde/svelte-drawer';
|
|
173
|
+
|
|
174
|
+
let open = $state(false);
|
|
175
|
+
</script>
|
|
176
|
+
|
|
177
|
+
<Drawer bind:open>
|
|
178
|
+
<DrawerOverlay class="fixed inset-0 bg-black/40" />
|
|
179
|
+
<DrawerContent class="fixed bottom-0 left-0 right-0 bg-white rounded-t-lg p-4">
|
|
180
|
+
<!-- Default gray handle -->
|
|
181
|
+
<DrawerHandle class="mb-8" />
|
|
182
|
+
|
|
183
|
+
<!-- Custom colored handle -->
|
|
184
|
+
<!-- <DrawerHandle class="bg-blue-500 mb-8" /> -->
|
|
185
|
+
|
|
186
|
+
<!-- Larger handle -->
|
|
187
|
+
<!-- <DrawerHandle class="w-16 h-2 mb-8" /> -->
|
|
188
|
+
|
|
189
|
+
<h2>Drawer with Custom Handle</h2>
|
|
190
|
+
<p>The handle automatically adapts to drawer direction.</p>
|
|
191
|
+
</DrawerContent>
|
|
192
|
+
</Drawer>
|
|
193
|
+
```
|
|
194
|
+
|
|
162
195
|
## Variants
|
|
163
196
|
|
|
164
197
|
Available variants for `DrawerVariants` component:
|
|
@@ -205,6 +238,34 @@ Content container for the drawer.
|
|
|
205
238
|
- `class` (string, optional) - CSS classes for styling
|
|
206
239
|
- `trapFocus` (boolean, optional, default: true) - Whether to trap focus inside drawer
|
|
207
240
|
|
|
241
|
+
### DrawerHandle
|
|
242
|
+
|
|
243
|
+
Visual drag indicator that automatically adapts to drawer direction.
|
|
244
|
+
|
|
245
|
+
**Props:**
|
|
246
|
+
|
|
247
|
+
- `class` (string, optional) - CSS classes for styling
|
|
248
|
+
|
|
249
|
+
**Features:**
|
|
250
|
+
|
|
251
|
+
- Automatically horizontal for `bottom`/`top` drawers (12px wide, 1.5px tall)
|
|
252
|
+
- Automatically vertical for `left`/`right` drawers (1.5px wide, 12px tall)
|
|
253
|
+
- Includes `data-drawer-drag` attribute for improved touch targeting
|
|
254
|
+
- Fully customizable with Tailwind classes
|
|
255
|
+
|
|
256
|
+
**Example:**
|
|
257
|
+
|
|
258
|
+
```svelte
|
|
259
|
+
<!-- Default gray handle -->
|
|
260
|
+
<DrawerHandle class="mb-8" />
|
|
261
|
+
|
|
262
|
+
<!-- Custom color -->
|
|
263
|
+
<DrawerHandle class="bg-blue-500 mb-8" />
|
|
264
|
+
|
|
265
|
+
<!-- Larger size -->
|
|
266
|
+
<DrawerHandle class="w-16 h-2 mb-8" />
|
|
267
|
+
```
|
|
268
|
+
|
|
208
269
|
### DrawerVariants
|
|
209
270
|
|
|
210
271
|
Pre-styled drawer content with built-in variants.
|
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
|
|
16
16
|
const defaultClasses = $derived(
|
|
17
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"
|
|
18
|
+
? "mx-auto w-12 h-1.5 flex-shrink-0 rounded-full bg-gray-300 cursor-grab active:cursor-grabbing"
|
|
19
|
+
: "my-auto w-1.5 h-12 flex-shrink-0 rounded-full bg-gray-300 cursor-grab active:cursor-grabbing"
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
const combinedClass = $derived(
|