Skip to content

Commit 56dc7b5

Browse files
adding slots examples
1 parent 7875220 commit 56dc7b5

File tree

3 files changed

+184
-1
lines changed

3 files changed

+184
-1
lines changed

example/App.vue

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,32 @@
3838
>Clone</a
3939
>
4040
</li>
41+
42+
<li class="nav-item">
43+
<a
44+
class="nav-link"
45+
data-toggle="tab"
46+
href="#footerslot"
47+
role="tab"
48+
aria-controls="profile"
49+
aria-selected="false"
50+
>Footer slot</a
51+
>
52+
</li>
53+
54+
<li class="nav-item">
55+
<a
56+
class="nav-link"
57+
data-toggle="tab"
58+
href="#headerlot"
59+
role="tab"
60+
aria-controls="profile"
61+
aria-selected="false"
62+
>Header slot</a
63+
>
64+
</li>
4165
</ul>
66+
4267
<div class="tab-content" id="tab-content">
4368
<div
4469
class="tab-pane show active"
@@ -66,6 +91,24 @@
6691
>
6792
<clone />
6893
</div>
94+
95+
<div
96+
class="tab-pane show"
97+
id="footerslot"
98+
role="tabpanel"
99+
aria-labelledby="profile-tab"
100+
>
101+
<footerslot />
102+
</div>
103+
104+
<div
105+
class="tab-pane show"
106+
id="headerlot"
107+
role="tabpanel"
108+
aria-labelledby="profile-tab"
109+
>
110+
<headerslot />
111+
</div>
69112
</div>
70113
</div>
71114
</div>
@@ -75,13 +118,17 @@
75118
import simple from "./components/simple";
76119
import twoLists from "./components/two-lists";
77120
import clone from "./components/clone";
121+
import footerslot from "./components/footerslot";
122+
import headerslot from "./components/headerslot";
78123
79124
export default {
80125
name: "app",
81126
components: {
82127
simple,
83128
twoLists,
84-
clone
129+
clone,
130+
footerslot,
131+
headerslot
85132
}
86133
};
87134
</script>

example/components/footerslot.vue

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<div class="justify-content-center jumbotron">
3+
<div class="row">
4+
<div class="col-8">
5+
<h3>Draggable with footer</h3>
6+
7+
<draggable
8+
:list="list"
9+
class="list-group"
10+
@start="dragging = true"
11+
@end="dragging = false"
12+
>
13+
<div
14+
class="list-group-item"
15+
v-for="element in list"
16+
:key="element.name"
17+
>
18+
{{ element.name }}
19+
</div>
20+
21+
<div
22+
slot="footer"
23+
class="btn-group list-group-item"
24+
role="group"
25+
aria-label="Basic example"
26+
>
27+
<button class="btn btn-secondary" @click="add">Add</button>
28+
<button class="btn btn-secondary" @click="replace">Replace</button>
29+
</div>
30+
</draggable>
31+
</div>
32+
33+
<rawDisplayer class="col-3" :value="list" title="List" />
34+
</div>
35+
</div>
36+
</template>
37+
38+
<script>
39+
import draggable from "@/vuedraggable";
40+
import rawDisplayer from "./raw-displayer.vue";
41+
let id = 1;
42+
export default {
43+
name: "footer",
44+
components: {
45+
draggable,
46+
rawDisplayer
47+
},
48+
data() {
49+
return {
50+
list: [
51+
{ name: "John", id: 0 },
52+
{ name: "Joao", id: 1 },
53+
{ name: "Jean", id: 2 }
54+
],
55+
dragging: false
56+
};
57+
},
58+
methods: {
59+
add: function() {
60+
this.list.push({ name: "Juan " + id, id: id++ });
61+
},
62+
replace: function() {
63+
this.list = [{ name: "Edgard", id: id++ }];
64+
}
65+
}
66+
};
67+
</script>
68+
<style scoped></style>

example/components/headerslot.vue

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<template>
2+
<div class="justify-content-center jumbotron">
3+
<div class="row">
4+
<div class="col-8">
5+
<h3>Draggable with header</h3>
6+
7+
<draggable
8+
:list="list"
9+
class="list-group"
10+
@start="dragging = true"
11+
@end="dragging = false"
12+
>
13+
<div
14+
class="list-group-item"
15+
v-for="element in list"
16+
:key="element.name"
17+
>
18+
{{ element.name }}
19+
</div>
20+
21+
<div
22+
slot="header"
23+
class="btn-group list-group-item"
24+
role="group"
25+
aria-label="Basic example"
26+
>
27+
<button class="btn btn-secondary" @click="add">Add</button>
28+
<button class="btn btn-secondary" @click="replace">Replace</button>
29+
</div>
30+
</draggable>
31+
</div>
32+
33+
<rawDisplayer class="col-3" :value="list" title="List" />
34+
</div>
35+
</div>
36+
</template>
37+
38+
<script>
39+
import draggable from "@/vuedraggable";
40+
import rawDisplayer from "./raw-displayer.vue";
41+
let id = 1;
42+
export default {
43+
name: "simple",
44+
components: {
45+
draggable,
46+
rawDisplayer
47+
},
48+
data() {
49+
return {
50+
list: [
51+
{ name: "John", id: 0 },
52+
{ name: "Joao", id: 1 },
53+
{ name: "Jean", id: 2 }
54+
],
55+
dragging: false
56+
};
57+
},
58+
methods: {
59+
add: function() {
60+
this.list.push({ name: "Juan " + id, id: id++ });
61+
},
62+
replace: function() {
63+
this.list = [{ name: "Edgard", id: id++ }];
64+
}
65+
}
66+
};
67+
</script>
68+
<style scoped></style>

0 commit comments

Comments
 (0)