Skip to content

Commit 77699f4

Browse files
committed
rename configuration, add docs
1 parent b8e16d0 commit 77699f4

File tree

10 files changed

+74
-21
lines changed

10 files changed

+74
-21
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ yarn add vue-final-modal
8484
```js
8585
import VueFinalModal from 'vue-final-modal'
8686

87-
Vue.use(VueFinalModal)
87+
Vue.use(VueFinalModal())
8888
```
8989

9090
### Nuxt
@@ -95,7 +95,7 @@ Vue.use(VueFinalModal)
9595
// plugins/vue-final-modal.js
9696
import VueFinalModal from 'vue-final-modal/lib'
9797

98-
Vue.use(VueFinalModal)
98+
Vue.use(VueFinalModal())
9999
```
100100

101101
- **Add plugin into `nuxt.config.js`**
@@ -152,6 +152,33 @@ export default {
152152
this.$vfm.show('example')
153153
```
154154

155+
## **Configuration**
156+
157+
> Only work in v0.18+
158+
159+
Configuration options can be passed as a second argument to `Vue.use`.
160+
161+
```js
162+
import VueFinalModal from 'vue-final-modal'
163+
164+
Vue.use(VueFinalModal(), { ... })
165+
```
166+
167+
### `componentName`
168+
169+
- Type: `String`
170+
- default: `'VueFinalModal'`
171+
172+
Changes component name from "VueFinalModal" to any other string value. It is useful when there is already a global "modal" component.
173+
174+
### `key`
175+
176+
- Type: `String`
177+
- default: `'$vfm'`
178+
179+
Changes API name from "$vfm" to any other string value. It is useful when you use `vue-final-modal` as spinner, toast, notify, etc.
180+
181+
155182
## **API**
156183

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

dist/VueFinalModal.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.esm.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/VueFinalModal.umd.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/content/en/index.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Introduction
33
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
44
position: 0
55
category: Getting Start
6-
version: 0.17
6+
version: 0.18
77
features:
88
- Support Vue 3 and Vue 2
99
- Tailwind CSS friendly
@@ -100,7 +100,7 @@ npm install vue-final-modal
100100
```js[main.js]
101101
import VueFinalModal from 'vue-final-modal'
102102
103-
Vue.use(VueFinalModal)
103+
Vue.use(VueFinalModal())
104104
```
105105

106106
### Nuxt
@@ -110,7 +110,7 @@ Vue.use(VueFinalModal)
110110
```js[plugins/vue-final-modal.js]
111111
import VueFinalModal from 'vue-final-modal/lib'
112112
113-
Vue.use(VueFinalModal)
113+
Vue.use(VueFinalModal())
114114
```
115115

116116
- **Add plugin into `nuxt.config.js`**
@@ -166,6 +166,32 @@ export default {
166166
this.$vfm.show('example')
167167
```
168168

169+
## **Configuration**
170+
171+
<badge>v0.18+</badge>
172+
173+
Configuration options can be passed as a second argument to `Vue.use`.
174+
175+
```js
176+
import VueFinalModal from 'vue-final-modal'
177+
178+
Vue.use(VueFinalModal(), { ... })
179+
```
180+
181+
### `componentName`
182+
183+
- Type: `String`
184+
- default: `'VueFinalModal'`
185+
186+
Changes component name from "VueFinalModal" to any other string value. It is useful when there is already a global "modal" component.
187+
188+
### `key`
189+
190+
- Type: `String`
191+
- default: `'$vfm'`
192+
193+
Changes API name from "$vfm" to any other string value. It is useful when you use `vue-final-modal` as spinner, toast, notify, etc.
194+
169195
## **API**
170196

171197
<badge>v0.15+</badge>

lib/Plugin.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { bindPrototype, registComponent } from './PluginCore'
22
import { DUPLICATE_PLUGIN_COMPONENT, DUPLICATE_COMPONENT } from './utils/errors'
33

44
const defaultOptions = {
5-
name: 'VueFinalModal',
6-
cmd: '$vfm'
5+
componentName: 'VueFinalModal',
6+
key: '$vfm'
77
}
88

99
const Plugin = () => ({
1010
install(Vue, options) {
1111
const _options = Object.assign({}, defaultOptions, options)
12-
const isDuplicateCmd = Vue.prototype[_options.cmd]
13-
const isDuplicateComponent = Vue.options.components[_options.name]
12+
const isDuplicateCmd = Vue.prototype[_options.key]
13+
const isDuplicateComponent = Vue.options.components[_options.componentName]
1414

1515
if (isDuplicateComponent) {
1616
console.warn(isDuplicateCmd ? DUPLICATE_PLUGIN_COMPONENT : DUPLICATE_COMPONENT)

lib/PluginCore.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ function createVfm() {
2929
}
3030
}
3131

32-
export function bindPrototype(Vue, { cmd }) {
32+
export function bindPrototype(Vue, { key }) {
3333
const vfm = createVfm()()
34-
Object.defineProperty(Vue.prototype, cmd, {
34+
Object.defineProperty(Vue.prototype, key, {
3535
get() {
3636
return vfm
3737
}
3838
})
3939
}
4040

41-
export function registComponent(Vue, { name, cmd }) {
42-
Vue.component(name, {
41+
export function registComponent(Vue, { componentName, key }) {
42+
Vue.component(componentName, {
4343
...VueFinalModal,
44-
props: { ...VueFinalModal.props, cmd: { type: String, default: cmd } }
44+
props: { ...VueFinalModal.props, $_key: { type: String, default: key } }
4545
})
4646
}

lib/VueFinalModal.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export default {
111111
}),
112112
computed: {
113113
api() {
114-
return this[this.cmd]
114+
return this[this.$_key]
115115
},
116116
isComponentReadyToBeDestroyed() {
117117
return (

lib/utils/errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const DUPLICATE_PLUGIN_COMPONENT =
2-
'[vue-final-modal] Duplicate registration plugin and component of VueFinalModal.'
2+
'[vue-final-modal] Duplicate registration API key and componentName of VueFinalModal.'
33

4-
export const DUPLICATE_COMPONENT = '[vue-final-modal] Duplicate registration component of VueFinalModal.'
4+
export const DUPLICATE_COMPONENT = '[vue-final-modal] Duplicate registration componentName of VueFinalModal.'

0 commit comments

Comments
 (0)