Skip to content

Commit 3a1d82a

Browse files
committed
docs: add locale zh-TW
1 parent 84514cc commit 3a1d82a

File tree

5 files changed

+1740
-0
lines changed

5 files changed

+1740
-0
lines changed

docs/content/tw/dynamic-modal.md

Lines changed: 296 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,296 @@
1+
---
2+
title: Dynamic Modal
3+
description: 'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
4+
position: 1
5+
category: Getting Start
6+
version: 2
7+
badge: v2.0.0+
8+
features:
9+
- Support Vue 3 and Vue 2
10+
- Tailwind CSS friendly
11+
- Renderless component
12+
- SSR support
13+
- Stackable
14+
- Detachable
15+
- Scrollable
16+
- Transition support
17+
- Mobile friendly
18+
- Tiny bundle size
19+
- Accessibility support
20+
---
21+
22+
This feature let you create modal dynamically.
23+
24+
## Add `ModalsContainer`
25+
26+
All dynamic modals will be displayed in ModalsContainer. You can get all dynamic modal instances by [$vfm.dynamicModals](#vfmdynamicmodals).
27+
28+
```html[App.vue]
29+
<template>
30+
<div>
31+
...
32+
<modals-container></modals-container>
33+
</div>
34+
</template>
35+
```
36+
37+
## API
38+
39+
### `$vfm.show(dynamicModalOptions, params)`
40+
41+
To show dynamic modal you can use the API `$vfm.show` function.
42+
43+
- Type: `Function`,
44+
- Arguments:
45+
- dynamicModalOptions: `Object`
46+
- params: same as [API $vfm.show](/#vfmshowname-params)
47+
48+
```ts
49+
type dynamicModalOptions = {
50+
component?: string | Component | AsyncComponent, // modal component
51+
bind?: { [key: string]: any}, // bind props and attrs to modal
52+
on?: { [key: string]: Function | Function[] }, // register events to modal
53+
slots?: {
54+
[key: string]: { // slot name
55+
component: string | Component | AsyncComponent // slot component
56+
bind: { [key: string]: any } // bind props and attrs to slot component
57+
}
58+
}
59+
}
60+
```
61+
62+
### `$vfm.dynamicModals`
63+
64+
- Return:
65+
- `Array`: returns dynamic modal instances.
66+
67+
## Examples
68+
69+
<modals-container></modals-container>
70+
71+
### Basic
72+
73+
<v-dynamic></v-dynamic>
74+
75+
<show-code class="pt-4">
76+
77+
```vue
78+
<template>
79+
<button class="vfm-btn mb-4" @click="dynamic">Open Dynamic Modal</button>
80+
</template>
81+
82+
<script>
83+
export default {
84+
methods: {
85+
dynamic() {
86+
this.$vfm.show({
87+
component: 'VDynamicModal'
88+
})
89+
}
90+
}
91+
}
92+
</script>
93+
```
94+
95+
</show-code>
96+
97+
#### VDynamicModal.vue
98+
99+
<show-code class="pt-4">
100+
101+
```vue
102+
<template>
103+
<vue-final-modal
104+
v-bind="$attrs"
105+
classes="modal-container"
106+
content-class="modal-content"
107+
v-on="$listeners"
108+
>
109+
<button class="modal__close" @click="close">
110+
<mdi-close></mdi-close>
111+
</button>
112+
<span class="modal__title">Hello, vue-final-modal</span>
113+
<div class="modal__content">
114+
<p>
115+
Vue Final Modal is a renderless, stackable, detachable and lightweight
116+
modal component.
117+
</p>
118+
</div>
119+
</vue-final-modal>
120+
</template>
121+
122+
<script>
123+
export default {
124+
inheritAttrs: false,
125+
methods: {
126+
close() {
127+
this.$emit('input', false)
128+
}
129+
}
130+
}
131+
</script>
132+
133+
<style scoped>
134+
::v-deep .modal-container {
135+
display: flex;
136+
justify-content: center;
137+
align-items: center;
138+
}
139+
::v-deep .modal-content {
140+
position: relative;
141+
display: flex;
142+
flex-direction: column;
143+
margin: 0 1rem;
144+
padding: 1rem;
145+
border: 1px solid #e2e8f0;
146+
border-radius: 0.25rem;
147+
background: #fff;
148+
}
149+
.modal__title {
150+
margin: 0 2rem 0 0;
151+
font-size: 1.5rem;
152+
font-weight: 700;
153+
}
154+
.modal__close {
155+
position: absolute;
156+
top: 0.5rem;
157+
right: 0.5rem;
158+
}
159+
</style>
160+
161+
<style scoped>
162+
.dark-mode div::v-deep .modal-content {
163+
border-color: #2d3748;
164+
background-color: #1a202c;
165+
}
166+
</style>
167+
168+
```
169+
170+
</show-code>
171+
172+
### Advanced
173+
174+
<v-dynamic-advanced></v-dynamic-advanced>
175+
176+
<show-code class="pt-4">
177+
178+
```vue
179+
<template>
180+
<button class="vfm-btn mb-4" @click="dynamic">Open Dynamic Modal</button>
181+
</template>
182+
183+
<script>
184+
import VContent from '../VContent.vue'
185+
186+
export default {
187+
methods: {
188+
dynamic() {
189+
this.$vfm.show({
190+
component: 'VModal',
191+
bind: {
192+
name: 'VDynamicAdvacedModal'
193+
},
194+
on: {
195+
// event by v-modal
196+
confirm(close) {
197+
console.log('confirm')
198+
close()
199+
},
200+
cancel(close) {
201+
console.log('cancel')
202+
close()
203+
},
204+
// event by vue-final-modal
205+
clickOutside() {
206+
console.log('@click-outside')
207+
},
208+
beforeOpen() {
209+
console.log('@before-open')
210+
},
211+
opened() {
212+
console.log('@opened')
213+
},
214+
beforeClose() {
215+
console.log('@before-close')
216+
},
217+
closed() {
218+
console.log('@closed')
219+
}
220+
},
221+
slots: {
222+
title: {
223+
component: 'VTitle',
224+
bind: {
225+
text: 'Hello, vue-final-modal'
226+
}
227+
},
228+
default: {
229+
component: VContent,
230+
bind: {
231+
content:
232+
'Vue Final Modal is a renderless, stackable, detachable and lightweight modal component.'
233+
}
234+
}
235+
}
236+
})
237+
}
238+
}
239+
}
240+
</script>
241+
```
242+
243+
</show-code>
244+
245+
#### VModal.vue
246+
247+
<alert>VModal is an HOC of vue-final-modal.</alert>
248+
249+
[Source code](/examples/recommended-use#vmodalvue)
250+
251+
#### VTitle.vue
252+
253+
<show-code class="pt-4">
254+
255+
```vue
256+
<template>
257+
<div>{{ text }}</div>
258+
</template>
259+
260+
<script>
261+
export default {
262+
props: {
263+
text: {
264+
type: String,
265+
default: ''
266+
}
267+
}
268+
}
269+
</script>
270+
```
271+
272+
</show-code>
273+
274+
#### VContent.vue
275+
276+
277+
<show-code class="pt-4">
278+
279+
```vue
280+
<template>
281+
<p>{{ content }}</p>
282+
</template>
283+
284+
<script>
285+
export default {
286+
props: {
287+
content: {
288+
type: String,
289+
default: ''
290+
}
291+
}
292+
}
293+
</script>
294+
```
295+
296+
</show-code>

0 commit comments

Comments
 (0)