Skip to content

Commit

Permalink
Merge 895a3b7 into 408603f
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterliu1003 committed May 3, 2021
2 parents 408603f + 895a3b7 commit 7c0ca5f
Show file tree
Hide file tree
Showing 68 changed files with 3,262 additions and 14,675 deletions.
11 changes: 9 additions & 2 deletions .babelrc
@@ -1,3 +1,10 @@
{
"presets": ["@babel/preset-env"]
}
"presets": [
[
"@babel/preset-env",
{
"exclude": ["@babel/plugin-transform-regenerator"]
}
]
]
}
3 changes: 0 additions & 3 deletions .browserslistrc

This file was deleted.

10 changes: 9 additions & 1 deletion .eslintignore
@@ -1,3 +1,11 @@
# default
dist
types/**/*.d.ts
docs

# docs
docs/.nuxt
docs/docs
docs/static

# example
example/dist
16 changes: 3 additions & 13 deletions .eslintrc.js
@@ -1,7 +1,8 @@
module.exports = {
root: true,
env: {
node: true
node: true,
jest: true
},
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/prettier'],
parserOptions: {
Expand All @@ -10,16 +11,5 @@ module.exports = {
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
},
overrides: [
{
files: [
'**/__tests__/*.{j,t}s?(x)',
'**/tests/unit/**/*.spec.{j,t}s?(x)'
],
env: {
jest: true
}
}
]
}
}
2 changes: 1 addition & 1 deletion dist/VueFinalModal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/VueFinalModal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/VueFinalModal.umd.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/VueFinalModal.umd.js.map

Large diffs are not rendered by default.

File renamed without changes.
4 changes: 2 additions & 2 deletions docs/components/examples/basic/VDynamicAdvanced.vue
Expand Up @@ -3,7 +3,7 @@
</template>

<script>
import VContent from '../VContent.vue'
import VDescription from '../VDescription.vue'
export default {
methods: {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default {
}
},
default: {
component: VContent,
component: VDescription,
bind: {
content: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
}
Expand Down
25 changes: 24 additions & 1 deletion docs/content/en/api.md
Expand Up @@ -31,13 +31,18 @@ export default {
- Arguments:
- name: `String` - Name of the modal
- params: `?: object` - Any data that you want to pass into the modal, checkout the guide [params](/guide/params).
- Returns: Promise<Object> | Promise<Array>


<show-code text="Example">

<v-api-show class="py-4"></v-api-show>

```js
this.$vfm.show('example', { userName: 'vue-final-modal' })
.then(() => {
// do something on modal opened
})
```

```html[Modal.vue]
Expand Down Expand Up @@ -67,6 +72,7 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
- Type: `Function`
- Arguments:
- names: `String` - The names to hide
- Returns: Promise<Object> | Promise<Array>

<show-code text="Example">

Expand All @@ -83,7 +89,9 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
show2: true
}),
mounted() {
this.$vfm.hide('example', 'example2')
this.$vfm.hide('example', 'example2').then(() => {
// do something on modal closed
})
}
}
</script>
Expand All @@ -93,18 +101,33 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })

### `hideAll()`

- Returns: Promise<Object> | Promise<Array>

hide all modals.

```js
this.$vfm.hideAll().then(() => {
// do something on all modals closed
})
```

### `toggle(name, show, params)`

- Type: `Function`
- Arguments:
- name: [`String` | `Array`] - The names of the modal
- show: `?: Boolean` - Show modal or not
- params: `?: object` - Any data that you want to pass into the modal, checkout the guide [params](/guide/params).
- Returns: Promise<Object> | Promise<Array>

toggle modals by name.

```js
this.$vfm.toggle('myModal').then(() => {
// do something on modals opened or closed, it depends on params `show` is true or false
})
```

### `get([names])`

- Type: `Function`
Expand Down
1 change: 1 addition & 0 deletions docs/content/en/dynamic-modal.md
Expand Up @@ -42,6 +42,7 @@ To show dynamic modal you can use the API `$vfm.show` function.
- Arguments:
- dynamicModalOptions: `Object`
- params: same as [API $vfm.show](/api#showname-params)
- Returns: Promise<Object> | Promise<Array>

```ts
type dynamicModalOptions = {
Expand Down
42 changes: 42 additions & 0 deletions docs/content/en/guide/scoped-slots.md
@@ -0,0 +1,42 @@
---
title: Scoped Slots
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
position: 6
category: Guide
fullscreen: true
---

## close

- type: `Function`

When you are using vue-final-modal as a HOC. you can `close` modal with scoped-slot:

```vue
<template>
<vue-final-modal v-slot="{ close }" v-bind="$attrs" v-on="$listeners">
<div>Hello Vue Final Modal</div>
<button @click="close">close modal</button>
</vue-final-modal>
</template>
<script>
export default {
name: 'VModal',
inheritAttrs: false
}
</script>
```

## params

- type: `Any`
- default: `{}`

When you open a modal though the [API](/api) `$vfm.show(name, params)`, you can get `params` with scoped-slot:

```html
<template v-slot="{ params }">
<!-- modal content -->
</template>
```
24 changes: 23 additions & 1 deletion docs/content/zh-Hant/api.md
Expand Up @@ -31,13 +31,17 @@ export default {
- 參數:
- name: `String` - 指定 modal 的名字。
- params: `?: object` - Any data that you want to pass into the modal, checkout the guide [params](/zh-Hant/guide/params).
- 回傳: Promise<Object> | Promise<Array>

<show-code text="Example">

<v-api-show class="py-4"></v-api-show>

```js
this.$vfm.show('example', { userName: 'vue-final-modal' })
.then(() => {
// 當 modal 開啟後,做一些事
})
```

```html[Modal.vue]
Expand Down Expand Up @@ -67,6 +71,7 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
- 型別: `Function`
- 參數:
- names: `String` - 指定要隱藏 modal 名稱。
- 回傳: Promise<Object> | Promise<Array>

<show-code text="Example">

Expand All @@ -83,7 +88,9 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })
show2: true
}),
mounted() {
this.$vfm.hide('example', 'example2')
this.$vfm.hide('example', 'example2').then(() => {
// 當 modal 關閉後,做一些事
})
}
}
</script>
Expand All @@ -93,18 +100,33 @@ this.$vfm.show('example', { userName: 'vue-final-modal' })

### `hideAll()`

- 回傳: Promise<Object> | Promise<Array>

關閉所有的 modal。

```js
this.$vfm.hideAll().then(() => {
// 當所有 modal 關閉後,做一些事
})
```

### `toggle(name, show, params)`

- 型別: `Function`
- 參數:
- name: [`String` | `Array`] - modal 的名稱。
- show: `?: Boolean` - 打開或隱藏這個 modal。
- params: `?: object` - 任何你想要傳入 modal 的資料,詳閱 [參數(params)](/zh-Hant/guide/params)
- 回傳: Promise<Object> | Promise<Array>

根據名字(name)切換 modals 的狀態。

```js
this.$vfm.toggle('myModal').then(() => {
// 當多個 modal 被開啟或被關閉時,做一些事,開啟或關閉取決於 show 參數給的是 true 或 false
})
```

### `get([names])`

- 型別: `Function`
Expand Down
1 change: 1 addition & 0 deletions docs/content/zh-Hant/dynamic-modal.md
Expand Up @@ -42,6 +42,7 @@ features:
- 參數:
- dynamicModalOptions: `Object`
- params: 與 [API $vfm.show](/zh-Hant/api#showname-params) 相同
- 回傳: Promise<Object> | Promise<Array>

```ts
type dynamicModalOptions = {
Expand Down
42 changes: 42 additions & 0 deletions docs/content/zh-Hant/guide/scoped-slots.md
@@ -0,0 +1,42 @@
---
title: 作用域插槽 (Scoped Slots)
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
position: 6
category: Guide
fullscreen: true
---

## close

- 型別: `Function`

當你以 HOC 的方式使用 vue-final-modal 時. 你可以以 scoped-slot 關閉(close) modal:

```vue
<template>
<vue-final-modal v-slot="{ close }" v-bind="$attrs" v-on="$listeners">
<div>哈囉,Vue Final Modal</div>
<button @click="close">close modal</button>
</vue-final-modal>
</template>
<script>
export default {
name: 'VModal',
inheritAttrs: false
}
</script>
```

## params

- 型別: `Any`
- 預設: `{}`

當你透過 [API](/zh-Hant/api) `$vfm.show(name, params)` 開啟 modal,你可以使用 scoped-slot 取得 params:

```html
<template v-slot="{ params }">
<!-- modal content -->
</template>
```
2 changes: 1 addition & 1 deletion docs/package.json
Expand Up @@ -9,7 +9,7 @@
"generate": "nuxt generate"
},
"dependencies": {
"@nuxt/content-theme-docs": "^0.8.2",
"@nuxt/content-theme-docs": "0.10.0",
"nuxt": "^2.14.12",
"vue-final-modal": "^2.1.0"
},
Expand Down

0 comments on commit 7c0ca5f

Please sign in to comment.