Skip to content

Commit 1c8e33b

Browse files
Yeveuvl
Yev
authored andcommitted
Added some docs
1 parent b4e3315 commit 1c8e33b

File tree

8 files changed

+169
-3
lines changed

8 files changed

+169
-3
lines changed

deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cd docs/.vuepress/dist
1111

1212
git init
1313
git add -A
14-
git commit -m 'deploy docs'
14+
git commit -m 'Deplying docs'
1515

1616
git push -f [email protected]:euvl/vue-js-modal.git master:gh-pages
1717

docs/.vuepress/config.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
1+
const sidebar = require('./sidebar')
2+
13
module.exports = {
24
base: '/vue-js-modal/',
35
title: 'Vue.js Modal',
4-
description: 'Simple, flexible, Vue.js modal plugin'
6+
description: 'Simple, flexible, Vue.js modal plugin',
7+
themeConfig: {
8+
displayAllHeaders: false,
9+
10+
sidebar,
11+
nav: [
12+
{
13+
text: 'Sponsorship',
14+
link: 'https://github.com/sponsors/euvl'
15+
},
16+
{ text: 'Github', link: 'https://github.com/euvl/vue-js-modal' },
17+
{ text: 'Examples', link: '/examples/' }
18+
]
19+
}
520
}

docs/.vuepress/sidebar.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = [
2+
{
3+
title: 'Guide',
4+
collapsable: false,
5+
children: ['/Installation', '/Usage', '/Properties']
6+
}
7+
]

docs/Installation.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
sidebarDepth: 0
3+
---
4+
5+
## Installation
6+
7+
```bash
8+
npm install vue-js-modal --save
9+
```
10+
11+
Import plugin in your main file:
12+
13+
```js
14+
import VModal from 'vue-js-modal'
15+
16+
Vue.use(VModal)
17+
```
18+
19+
Or as a Nuxt.js plugin:
20+
21+
```js
22+
import Vue from 'vue'
23+
import VModal from 'vue-js-modal/dist/ssr.nocss'
24+
25+
// import from 'vue-js-modal/dist/styles.css
26+
27+
Vue.use(VModal)
28+
29+
export default function(_, inject) {
30+
inject('modal', VModal)
31+
}
32+
```
33+
34+
::: tip Extracted CSS
35+
The `/dist` directory contains a version of the build with extracted CSS files. This is useful for SSR but also can be used with the purely client-side implementation when you need more flexibility in controlling your stylesheets.
36+
37+
* `ssr.index.js` - SSR build with inline CSS
38+
* `ssr.nocss.js` - SSR build without inline CSS
39+
* `styles.css` - File with required styles
40+
:::

docs/Properties.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
sidebarDepth: 0
3+
---
4+
5+
### Properties

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# This is readme
1+
# Guide

docs/Usage.md

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
sidebarDepth: 0
3+
---
4+
5+
## Usage
6+
7+
There are 2 types of modals, static and dynamic. **Static** are defined explicitly though the template and **dynamic** are generated based on the configuration passed into the "show modal" function.
8+
9+
### Static modals
10+
11+
Modals are defined by simply using the `<modal />` component. To control it's visibility - use `$modal.show` / `$modal.hide` functions, for example:
12+
13+
```html
14+
<template>
15+
<modal name="my-first-modal">
16+
This is my first modal
17+
</modal>
18+
</template>
19+
```
20+
```js{5,8}
21+
export default {
22+
name: 'MyComponent',
23+
methods: {
24+
show () {
25+
this.$modal.show('my-first-modal');
26+
},
27+
hide () {
28+
this.$modal.hide('my-first-modal');
29+
}
30+
},
31+
mount () {
32+
this.show()
33+
}
34+
}
35+
```
36+
37+
### Dynamic modals
38+
39+
In order to instantiate modals at runtime (for lazy-loading or de-cluttering templates), it is possible to create modals dynamically.
40+
41+
42+
To show dynamic modal you can use the same `$modal.show` function with extended API:
43+
44+
```js
45+
this.$modal.show(
46+
component_definition,
47+
component_properties,
48+
modal_properties,
49+
modal_events
50+
)
51+
```
52+
53+
* `component_definition` - either inline or imported Vue component definition
54+
* `component_properties` - any properties that are used within the `component_definition`
55+
* `modal_properties` -modal component properties (see Properties section)
56+
* `modal_events` - modal event handlers (see Events section)
57+
58+
Examples:
59+
60+
Using inline component definition:
61+
62+
```js
63+
export default {
64+
name: 'App',
65+
mount () {
66+
this.$modal.show(
67+
{
68+
template: `
69+
<div>
70+
<h1>This is created inline</h1>
71+
<p>{{ text }}</p>
72+
</div>
73+
`,
74+
props: ['text']
75+
},
76+
{ text: 'This text is passed as a property' },
77+
{ height: 'auto' },
78+
{ 'before-close': (event) => {} }
79+
)
80+
}
81+
}
82+
```
83+
84+
Using imported component definition:
85+
86+
```js
87+
import MyComponent from './MyComponent.vue'
88+
89+
export default {
90+
name: 'App',
91+
mount () {
92+
this.$modal.show(
93+
MyComponent,
94+
{ text: 'This text is passed as a property' },
95+
{ draggable: true }
96+
)
97+
}
98+
}
99+
```

docs/examples/.gkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)