Skip to content

Commit 78e60f9

Browse files
committed
docs: update docs
1 parent ad76a61 commit 78e60f9

File tree

2 files changed

+83
-59
lines changed

2 files changed

+83
-59
lines changed

README.md

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,23 @@ Changes API name from "$vfm" to any other string value. It is useful when you us
182182

183183
## **API**
184184

185-
Plugin API can be called within any component through `this.$vfm`.
186-
187-
### `$vfm.openedModals`
185+
- In Options API:
188186

189-
- Type: `Array`
190-
191-
A stack array store the opened modal's vue component instance.
187+
Plugin API can be called within any component through `this.$vfm`.
192188

193-
You can use:
194-
1. `$vfm.openedModals[0]` to get the first opened modal instance.
195-
2. `$vfm.openedModals.length` to get how many modals is opened.
189+
- In Composition API (Only in Vue 3 version):
196190

197-
### `$vfm.modals`
191+
> Only support in Vue 3
198192
199-
- Type: `Array`
193+
```js
194+
import { inject } from 'vue'
200195

201-
All modal instances include show and hide.
196+
export default {
197+
setup() {
198+
const $vfm = inject('$vfm')
199+
}
200+
}
201+
```
202202

203203
### `$vfm.show(name, params)`
204204

@@ -227,19 +227,22 @@ Or get `params` on `@beforeOpen` event:
227227

228228
```html
229229
<template>
230-
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
230+
<vue-final-modal v-model="show" name="example">
231+
<template v-slot="{ params }">
232+
Hi {{ params.userName }}
233+
</template>
234+
</vue-final-modal>
231235
</template>
232236

233237
<script>
234-
export default {
235-
name: 'MyComponent',
238+
export default {
236239
data: () => ({
237240
show: false
238241
}),
239-
mounted () {
240-
this.$vfm.show('example')
242+
mounted() {
243+
this.$vfm.show('example', { userName: 'vue-final-modal' })
241244
}
242-
}
245+
}
243246
</script>
244247
```
245248

@@ -257,7 +260,6 @@ export default {
257260

258261
<script>
259262
export default {
260-
name: 'MyComponent',
261263
data: () => ({
262264
show: true
263265
}),
@@ -298,6 +300,30 @@ Or get `params` on `@beforeOpen` event:
298300
299301
toggle modal by name.
300302

303+
### `$vfm.get(name)`
304+
305+
- Type: `Function`
306+
- Arguments:
307+
- name: `String` - Name of the modal
308+
309+
return the modal comopnent instance.
310+
311+
### `$vfm.openedModals`
312+
313+
- Type: `Array`
314+
315+
A stack array store the opened modal's vue component instance.
316+
317+
You can use:
318+
1. `$vfm.openedModals[0]` to get the first opened modal instance.
319+
2. `$vfm.openedModals.length` to get how many modals is opened.
320+
321+
### `$vfm.modals`
322+
323+
- Type: `Array`
324+
325+
All modal instances include show and hide.
326+
301327
## **Props**
302328

303329
```js

docs/content/en/index.md

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ features:
3737
<a href="https://www.npmjs.com/package/vue-final-modal"><img src="https://badgen.net/badgesize/brotli/hunterliu1003/vue-final-modal/next/dist/VueFinalModal.umd.js" alt="Size"></a>
3838
</p>
3939

40-
4140
<p align="right">
4241
<a href="https://www.buymeacoffee.com/PL2qJIx" target="_blank" rel="noopener noreferrer">
4342
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-green.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" >
@@ -117,18 +116,16 @@ Vue.use(VueFinalModal())
117116

118117
```js[nuxt.config.js]
119118
export default {
120-
plugins: [
121-
'~plugins/vue-final-modal.js'
122-
],
119+
plugins: ['~plugins/vue-final-modal.js'],
123120
build: {
124-
transpile: ['vue-final-modal'],
121+
transpile: ['vue-final-modal']
125122
}
126123
}
127124
```
128125

129126
### CDN
130127

131-
> [Live demo](https://codepen.io/hunterliu1003/pen/ZEWoYeE)
128+
<alert>[Live demo](https://codepen.io/hunterliu1003/pen/ZEWoYeE)</alert>
132129

133130
- **jsDelivr**
134131

@@ -188,15 +185,15 @@ Changes component name from "VueFinalModal" to any other string value. It is use
188185
- Type: `String`
189186
- default: `'$vfm'`
190187

191-
Changes API name from "$vfm" to any other string value. It is useful when you use `vue-final-modal` as spinner, toast, notify, etc.
188+
Changes API name from "\$vfm" to any other string value. It is useful when you use `vue-final-modal` as spinner, toast, notify, etc.
192189

193190
## **API**
194191

195-
- In Options API:
192+
- **Options API**
196193

197194
Plugin API can be called within any component through `this.$vfm`.
198195

199-
- In Composition API:
196+
- **Composition API** <badge>Only in Vue 3 version</badge>
200197

201198
```js
202199
import { inject } from 'vue'
@@ -229,25 +226,28 @@ Or get `params` on `@beforeOpen` event:
229226
</vue-final-modal>
230227
```
231228

232-
> `parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.
229+
<alert>`parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.</alert>
233230

234231
- Example:
235232

236233
```html
237234
<template>
238-
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
235+
<vue-final-modal v-model="show" name="example">
236+
<template v-slot="{ params }">
237+
Hi {{ params.userName }}
238+
</template>
239+
</vue-final-modal>
239240
</template>
240241

241242
<script>
242-
export default {
243-
name: 'MyComponent',
243+
export default {
244244
data: () => ({
245245
show: false
246246
}),
247-
mounted () {
248-
this.$vfm.show('example')
247+
mounted() {
248+
this.$vfm.show('example', { userName: 'vue-final-modal' })
249249
}
250-
}
250+
}
251251
</script>
252252
```
253253

@@ -260,19 +260,18 @@ export default {
260260

261261
```html
262262
<template>
263-
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
263+
<vue-final-modal v-model="show" name="example">Vue Final Modal is awesome</vue-final-modal>
264264
</template>
265265

266266
<script>
267-
export default {
268-
name: 'MyComponent',
267+
export default {
269268
data: () => ({
270269
show: true
271270
}),
272-
mounted () {
273-
this.$vfm.hide('example')
271+
mounted() {
272+
this.$vfm.hide('example')
274273
}
275-
}
274+
}
276275
</script>
277276
```
278277

@@ -302,7 +301,7 @@ Or get `params` on `@beforeOpen` event:
302301
</vue-final-modal>
303302
```
304303

305-
> `parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.
304+
<alert>`parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.</alert>
306305

307306
toggle modal by name.
308307

@@ -321,6 +320,7 @@ return the modal comopnent instance.
321320
A stack array store the opened modal's vue component instance.
322321

323322
You can use:
323+
324324
1. `$vfm.openedModals[0]` to get the first opened modal instance.
325325
2. `$vfm.openedModals.length` to get how many modals is opened.
326326

@@ -464,7 +464,7 @@ Set the root element of `vue-final-modal` style to `pointer-events: none;`.
464464

465465
Specifies which DOM element that this component should detach to.
466466

467-
1. Set `false` will disabled this feature.
467+
1. Set `false` will disabled this feature.
468468
2. String can be any valid `querySelector`, e.g. `'body'`, `'#app'`.
469469
3. Object can be any valid `Node`, e.g. `this.$refs.container`.
470470

@@ -513,21 +513,20 @@ Enables focus trap meaning that only inputs/buttons that are withing the modal w
513513

514514
```vue
515515
<template>
516-
<vue-final-modal
517-
@click-outside="clickOutside"
518-
@before-open="beforeOpen"
519-
@opened="opened"
520-
@before-close="beforeClose"
521-
@closed="closed"
522-
>
523-
...modal content
524-
</vue-final-modal>
516+
<vue-final-modal
517+
@click-outside="clickOutside"
518+
@before-open="beforeOpen"
519+
@opened="opened"
520+
@before-close="beforeClose"
521+
@closed="closed"
522+
>
523+
...modal content
524+
</vue-final-modal>
525525
</template>
526526
```
527527

528528
</show-code>
529529

530-
531530
### `@click-outside`
532531

533532
- Emits while modal container on click.
@@ -544,7 +543,7 @@ If prop `clickToClose` is `false`, the event will still be emitted.
544543

545544
### `@opened`
546545

547-
- Emits after modal became visible and transition ended.
546+
- Emits after modal became visible and transition ended.
548547

549548
### `@before-close`
550549

@@ -572,12 +571,11 @@ Or get `params` on `@beforeOpen` event:
572571
</vue-final-modal>
573572
```
574573

575-
> `parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.
576-
574+
<alert>`parmas` will be reset to `{}` automatically after `closed` event. You can avoid the modal to reset the `params` to empty object by calling `event.stop()`.</alert>
577575

578576
## **Contribution**
579577

580-
👋 Hi I'm Hunter, the author of `vue-final-modal`.
578+
👋 Hi I'm Hunter, the author of `vue-final-modal`.
581579

582580
To develop vue-final-modal, I learn a lot from these awesome libraries:
583581

@@ -594,6 +592,6 @@ To develop vue-final-modal, I learn a lot from these awesome libraries:
594592
- [Bootstrap Vue](https://bootstrap-vue.org/)
595593
- lockScroll
596594

597-
> There is no perfect library even the `final` of vue modal.
595+
<alert>There is no perfect library even the `final` of vue modal.</alert>
598596

599-
If you have any ideas for optimization of `vue-final-modal`, feel free to open [issues](https://github.com/hunterliu1003/vue-final-modal/issues) or [pull requests](https://github.com/hunterliu1003/vue-final-modal/pulls).
597+
🚀 If you have any ideas for optimization of `vue-final-modal`, feel free to open [issues](https://github.com/hunterliu1003/vue-final-modal/issues) or [pull requests](https://github.com/hunterliu1003/vue-final-modal/pulls).

0 commit comments

Comments
 (0)