Skip to content

Commit 8311bba

Browse files
committed
update docs
1 parent 5ace892 commit 8311bba

File tree

11 files changed

+154
-0
lines changed

11 files changed

+154
-0
lines changed

docs-src/components/Examples-openOn/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div id="examples">
2+
<h2>Setting panel openOn</h2>
23
<p>
34
Open panels on the left, right, top or bottom side using the <code>openOn</code> option:
45
</p>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<template src="./template.html">
2+
</template>
3+
4+
<script>
5+
export default {
6+
name: 'examples-passing-data',
7+
data() {
8+
return {
9+
name: null,
10+
age: null
11+
}
12+
},
13+
methods: {
14+
showPanel() {
15+
const panelResult = this.$showPanel({
16+
component: 'panel-2',
17+
width: 600,
18+
openOn: 'right',
19+
props: {
20+
age: this.age
21+
}
22+
});
23+
24+
panelResult.promise
25+
.then(result => {
26+
this.name = result;
27+
});
28+
}
29+
}
30+
};
31+
</script>
32+
33+
<style lang="less">
34+
</style>
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<div id="examples">
2+
<h2>Passing Data</h2>
3+
<p>
4+
You can pass data to your components by using the <code>props</code> property:
5+
</p>
6+
<pre class="highlight">
7+
const panelResult = this.$showPanel({
8+
component: "panel-2",
9+
props: {
10+
age: {{ age }}
11+
}
12+
});</pre>
13+
<p>
14+
And you can receive data from your panel by using the <code>promise</code> property of the <code>PanelResult</code> object:
15+
</p>
16+
<pre class="highlight">
17+
const panelResult = this.$showPanel({
18+
component: "panel-2",
19+
props: {
20+
age: {{ age }}
21+
}
22+
});
23+
24+
panelResult.promise
25+
.then(result => {
26+
//result is the value passed from your component calling <strong>this.$emit('close-panel', //some value);</strong>
27+
});</pre>
28+
<p>
29+
In your panel component you just need to call <code>this.$emit('close-panel')</code> to close your panel:
30+
</p>
31+
<pre class="highlight">
32+
//in your component's code ("panel-2" in this example)
33+
34+
{
35+
props: {
36+
age: {
37+
type: String,
38+
required: true
39+
}
40+
},
41+
data() {
42+
name : null
43+
},
44+
methods: {
45+
closePanel() {
46+
this.$emit('closePanel', {});
47+
}
48+
}
49+
}</pre>
50+
<h2>Example</h2>
51+
<div class="form-group">
52+
<label>What's your age?</label>
53+
<input type="number" class="form-control" v-model="age" />
54+
</div>
55+
<div class="form-group" v-if="name">
56+
Your name is {{ name }}
57+
</div>
58+
<button @click.prevent="showPanel">
59+
Show Panel
60+
</button>
61+
</div>

docs-src/components/Examples-width/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<div id="examples">
2+
<h2>Setting panel width</h2>
23
<p>
34
Open panels on the left, right, top or bottom side using the <code>openOn</code> option:
45
</p>

docs-src/components/Panel2/index.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template src="./template.html">
2+
</template>
3+
4+
<script>
5+
export default {
6+
name: 'panel-2',
7+
props: {
8+
age: {
9+
type: String,
10+
required: true
11+
}
12+
},
13+
data() {
14+
return {
15+
name: null
16+
}
17+
},
18+
methods: {
19+
closePanel() {
20+
this.$emit('closePanel', this.name);
21+
}
22+
}
23+
};
24+
</script>
25+
26+
<style lang="less">
27+
#panel-2 {
28+
padding: 45px;
29+
}
30+
</style>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<div id="panel-2">
2+
You are {{ age }} years old!
3+
4+
<div class="form-group">
5+
<label>What's your name?</label>
6+
<input type="text" class="form-control" v-model="name" />
7+
</div>
8+
<button @click.prevent="closePanel">
9+
Close Panel
10+
</button>
11+
</div>

docs-src/components/PanelResult/template.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,7 @@ <h2>Panel Result</h2>
6464
});
6565
}
6666
}</pre>
67+
<p>
68+
<router-link :to="{ name : 'ExamplesPassingData' }">Learn more about the passing data here.</router-link>
69+
</p>
6770
</div>

docs-src/components/Sidebar/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export default {
2121
padding-top: 20px;
2222
position: sticky;
2323
top: 0;
24+
height: 300px;
2425
2526
ul {
2627
margin: 0;

docs-src/components/Sidebar/template.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@
3535
Width
3636
</router-link>
3737
</li>
38+
<li>
39+
<router-link activeClass="active" :to="{ name : 'ExamplesPassingData' }">
40+
Passing Data
41+
</router-link>
42+
</li>
3843
</ul>
3944
</li>
4045
</ul>

docs-src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import VueFriendlyIframe from '../src/index';
44
import App from './components/App';
55
import Sidebar from './components/Sidebar';
66
import Panel1 from './components/Panel1';
7+
import Panel2 from './components/Panel2';
78
import router from './router';
89

910
Vue.use(VueFriendlyIframe);
1011

1112
Vue.component('sidebar', Sidebar);
1213
Vue.component('panel-1', Panel1);
14+
Vue.component('panel-2', Panel2);
1315

1416
new Vue({
1517
template: '<App></App>',

docs-src/router.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import PanelResult from './components/PanelResult';
88
import Examples from './components/Examples';
99
import ExamplesOpenOn from './components/Examples-openOn';
1010
import ExamplesWidth from './components/Examples-width';
11+
import ExamplesPassingData from './components/Examples-passingData';
1112

1213
Vue.use(VueRouter);
1314

@@ -46,6 +47,10 @@ const routes = [{
4647
name: 'ExamplesWidth',
4748
path: '/examples/width',
4849
component: ExamplesWidth,
50+
}, {
51+
name: 'ExamplesPassingData',
52+
path: '/examples/passing-data',
53+
component: ExamplesPassingData,
4954
}]
5055
}];
5156

0 commit comments

Comments
 (0)