@douxcode/vue-spring-bottom-sheet 2.0.0 → 2.0.1

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.
Files changed (2) hide show
  1. package/README.md +155 -0
  2. package/package.json +2 -2
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # Vue Spring Bottom Sheet
2
+
3
+ **vue-spring-bottom-sheet** is built on top of **[motion-v]**.
4
+
5
+ 😎 **Modern** and 🚀 **Performant** Bottom Sheet for Vue.js
6
+
7
+ [Demo](https://vue-spring-bottom-sheet.douxcode.com/) 👀
8
+
9
+ | ![](https://vue-spring-bottom-sheet.douxcode.com/example_basic.png) | ![](https://vue-spring-bottom-sheet.douxcode.com/example_snap.png) | ![](https://vue-spring-bottom-sheet.douxcode.com/example_blocking.png) | ![](https://vue-spring-bottom-sheet.douxcode.com/example_sticky.png) |
10
+ | :-----------------------------------------------------------------: | :----------------------------------------------------------------: | :--------------------------------------------------------------------: | :------------------------------------------------------------------: |
11
+
12
+ # Installation
13
+
14
+ ```
15
+ npm install @douxcode/vue-spring-bottom-sheet
16
+ ```
17
+
18
+ ```
19
+ bun install @douxcode/vue-spring-bottom-sheet
20
+ ```
21
+
22
+ # Getting started
23
+
24
+ ## Basic usage
25
+
26
+ ```vue
27
+ <script setup>
28
+ import BottomSheet from '@douxcode/vue-spring-bottom-sheet'
29
+ import '@douxcode/vue-spring-bottom-sheet/dist/style.css'
30
+ import { ref } from 'vue'
31
+
32
+ const bottomSheet = ref(null)
33
+
34
+ const open = () => {
35
+ bottomSheet.value.open()
36
+ }
37
+
38
+ const close = () => {
39
+ bottomSheet.value.close()
40
+ }
41
+ </script>
42
+
43
+ <template>
44
+ <BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
45
+ </template>
46
+ ```
47
+
48
+ ## Basic usage `setup` + TS
49
+
50
+ ```vue
51
+ <script setup lang="ts">
52
+ import BottomSheet from '@douxcode/vue-spring-bottom-sheet'
53
+ import '@douxcode/vue-spring-bottom-sheet/dist/style.css'
54
+ import { ref } from 'vue'
55
+
56
+ const bottomSheet = ref<InstanceType<typeof BottomSheet>>()
57
+
58
+ /* For vue 3.5+ you can use useTemplateRef() */
59
+ const bottomSheet = useTemplateRef('bottomSheet')
60
+
61
+ const open = () => {
62
+ bottomSheet.value.open()
63
+ }
64
+
65
+ const close = () => {
66
+ bottomSheet.value.close()
67
+ }
68
+ </script>
69
+
70
+ <template>
71
+ <BottomSheet ref="bottomSheet"> Your content </BottomSheet>
72
+ </template>
73
+ ```
74
+
75
+ ## Usage in Nuxt 3
76
+
77
+ For Nuxt 3, just wrap component in `<ClientOnly>`
78
+
79
+ ```vue
80
+ <template>
81
+ <ClientOnly>
82
+ <BottomSheet ref="bottomSheet"> Your awesome content </BottomSheet>
83
+ </ClientOnly>
84
+ </template>
85
+ ```
86
+
87
+ ## Slots
88
+
89
+ ```vue
90
+ <template>
91
+ <BottomSheet ref="bottomSheet">
92
+ <template #header> Header </template>
93
+ <div>Your content</div>
94
+ <template #footer> Footer </template>
95
+ </BottomSheet>
96
+ </template>
97
+ ```
98
+
99
+ ## CSS Custom Properties
100
+
101
+ ```css
102
+ --vsbs-backdrop-bg: rgba(0, 0, 0, 0.5);
103
+ --vsbs-shadow-color: rgba(89, 89, 89, 0.2);
104
+ --vsbs-background: #fff;
105
+ --vsbs-border-radius: 16px;
106
+ --vsbs-max-width: 640px;
107
+ --vsbs-border-color: rgba(46, 59, 66, 0.125);
108
+ --vsbs-padding-x: 16px;
109
+ --vsbs-handle-background: rgba(0, 0, 0, 0.28);
110
+ ```
111
+
112
+ ## Props
113
+
114
+ ### Prop Definitions
115
+
116
+ | Prop | Type | Default | Description |
117
+ | ------------------- | --------------------- | ---------------- | ------------------------------------------ |
118
+ | duration | Number | 250 | Animation duration in milliseconds |
119
+ | snapPoints | Array<number\|string> | [instinctHeight] | Custom snapping positions |
120
+ | initialSnapPoint | Number | minHeight | Initial snap point index |
121
+ | blocking | Boolean | true | Block interactions with underlying content |
122
+ | canSwipeClose | Boolean | true | Enable swipe-to-close gesture |
123
+ | canOverlayClose | Boolean | true | Allow closing by tapping backdrop |
124
+ | expandOnContentDrag | Boolean | true | Enable expanding by dragging content |
125
+
126
+ ## Exposed methods
127
+
128
+ Assuming there is `const bottomSheet = ref()`
129
+
130
+ | Method | Description | Example |
131
+ | ----------- | ------------------------- | ------------------------------------ |
132
+ | open | Opens the bottom sheet | `bottomSheet.value.open()` |
133
+ | close | Closes the bottom sheet | `bottomSheet.value.close()` |
134
+ | snapToPoint | Snaps to a specific point | `bottomSheet.value.snapToPoint(300)` |
135
+
136
+ ## Events
137
+
138
+ | Event | Description | Payload |
139
+ | -------------- | -------------------------------------- | --------------- |
140
+ | opened | Emitted when sheet finishes opening | - |
141
+ | closed | Emitted when sheet finishes closing | - |
142
+ | dragging-up | Emitted when user drags sheet upward | - |
143
+ | dragging-down | Emitted when user drags sheet downward | - |
144
+ | instinctHeight | Emitted when content height changes | height (number) |
145
+
146
+ ## Acknowledgments
147
+
148
+ This project was inspired by the following:
149
+
150
+ - [react-spring-bottom-sheet]: Accessible ♿️, Delightful ✨, & Fast 🚀
151
+ - [@webzlodimir/vue-bottom-sheet]: 🔥 A nice clean and touch-friendly bottom sheet component based on Vue.js and Hammer.js for Vue 3
152
+
153
+ [motion-v]: https://motion.unovue.com/
154
+ [react-spring-bottom-sheet]: https://react-spring.bottom-sheet.dev/
155
+ [@webzlodimir/vue-bottom-sheet]: https://github.com/vaban-ru/vue-bottom-sheet
package/package.json CHANGED
@@ -32,7 +32,7 @@
32
32
  "url": "https://github.com/megaarmos/vue-spring-bottom-sheet/issues"
33
33
  },
34
34
  "private": false,
35
- "version": "2.0.0",
35
+ "version": "2.0.1",
36
36
  "type": "module",
37
37
  "exports": {
38
38
  ".": {
@@ -52,7 +52,7 @@
52
52
  "type-check": "vue-tsc --build",
53
53
  "lint": "eslint . --fix",
54
54
  "format": "prettier --write src/",
55
- "release": "npm run build && npm publish --access public"
55
+ "release": "cp ../../README.md . && npm run build && npm publish --access public"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "vue": ">=3.3"