Skip to content

Commit feba076

Browse files
WIP migrating example
1 parent 61aad4a commit feba076

File tree

3 files changed

+152
-52
lines changed

3 files changed

+152
-52
lines changed

example/App.vue

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,71 +6,48 @@
66
>
77
<div class="container ">
88

9-
<div class="row justify-content-center">
9+
<ul
10+
class="nav nav-tabs"
11+
role="tablist"
12+
>
13+
<li class="nav-item">
14+
<a
15+
class="nav-link active"
16+
data-toggle="tab"
17+
href="#simple"
18+
role="tab"
19+
aria-controls="profile"
20+
aria-selected="true"
21+
>Simple</a>
22+
</li>
23+
</ul>
24+
<div
25+
class="tab-content"
26+
id="tab-content"
27+
>
1028

11-
<div class="list-group col-8">
12-
<h2>Draggable</h2>
13-
<draggable
14-
:list="list"
15-
@start="dragging=true"
16-
@end="dragging=false"
17-
>
18-
<div
19-
class="list-group-item"
20-
v-for="element in list"
21-
:key="element.name"
22-
>{{element.name}}</div>
23-
</draggable>
24-
</div>
25-
26-
</div>
29+
<div
30+
class="tab-pane show active"
31+
id="simple"
32+
role="tabpanel"
33+
aria-labelledby="profile-tab"
34+
>
2735

28-
<div class="row justify-content-center">
36+
<simple />
2937

30-
<div class="list-group col-8">
31-
<h2>Normal v-for</h2>
32-
<div>
33-
<div
34-
class="list-group-item"
35-
v-for="element in list"
36-
:key="element.name"
37-
>{{element.name}}</div>
38-
</div>
3938
</div>
40-
</div>
41-
42-
<button @click="add">Add</button>
43-
<button @click="replace">Replace</button>
4439

40+
</div>
4541
</div>
4642
</div>
4743
</template>
4844

4945
<script>
50-
import draggable from "@/components/Vuedraggable";
51-
let id = 1;
46+
import simple from "./components/simple";
5247
export default {
5348
name: "app",
5449
components: {
55-
draggable
56-
},
57-
data() {
58-
return {
59-
list: [
60-
{ name: "John", id: 0 },
61-
{ name: "Joao", id: 1 },
62-
{ name: "Jean", id: 2 }
63-
],
64-
dragging: false
65-
};
66-
},
67-
methods: {
68-
add: function() {
69-
this.list.push({ name: "Juan " + id, id: id++ });
70-
},
71-
replace: function() {
72-
this.list = [{ name: "Edgard", id: id++ }];
73-
}
50+
simple
7451
}
7552
};
7653
</script>

example/components/raw-displayer.vue

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<template>
2+
<div>
3+
<h2>{{title}}</h2>
4+
<pre>{{valueString}}</pre>
5+
</div>
6+
</template>
7+
<script>
8+
const props = {
9+
title: {
10+
required: true,
11+
type: String
12+
},
13+
value: {
14+
required: true
15+
}
16+
};
17+
export default {
18+
props,
19+
computed: {
20+
valueString() {
21+
return JSON.stringify(this.value, null, 2);
22+
}
23+
}
24+
};
25+
</script>
26+
<style scoped>
27+
pre {
28+
text-align: start;
29+
}
30+
</style>

example/components/simple.vue

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<template>
2+
<div>
3+
<div class="row justify-content-center jumbotron">
4+
5+
<div class="col-2">
6+
<div
7+
class="btn-group-vertical buttons"
8+
role="group"
9+
aria-label="Basic example"
10+
>
11+
<button
12+
class="btn btn-secondary"
13+
@click="add"
14+
>Add</button>
15+
<button
16+
class="btn btn-secondary"
17+
@click="replace"
18+
>Replace</button>
19+
20+
</div>
21+
</div>
22+
23+
<div class="list-group col-6">
24+
<h2>Draggable {{draggingInfo}}</h2>
25+
26+
<draggable
27+
:list="list"
28+
@start="dragging=true"
29+
@end="dragging=false"
30+
>
31+
<div
32+
class="list-group-item"
33+
v-for="element in list"
34+
:key="element.name"
35+
>{{element.name}}</div>
36+
</draggable>
37+
</div>
38+
39+
<rawDisplayer
40+
class="col-3"
41+
:value="list"
42+
title="List"
43+
/>
44+
45+
</div>
46+
47+
</div>
48+
</template>
49+
50+
<script>
51+
import draggable from "@/components/Vuedraggable";
52+
import rawDisplayer from "./raw-displayer.vue";
53+
let id = 1;
54+
export default {
55+
name: "simple",
56+
components: {
57+
draggable,
58+
rawDisplayer
59+
},
60+
data() {
61+
return {
62+
list: [
63+
{ name: "John", id: 0 },
64+
{ name: "Joao", id: 1 },
65+
{ name: "Jean", id: 2 }
66+
],
67+
dragging: false
68+
};
69+
},
70+
computed: {
71+
draggingInfo() {
72+
return this.dragging ? "under drag" : "";
73+
},
74+
listString() {
75+
return JSON.stringify(this.list, null, 2);
76+
}
77+
},
78+
methods: {
79+
add: function() {
80+
this.list.push({ name: "Juan " + id, id: id++ });
81+
},
82+
replace: function() {
83+
this.list = [{ name: "Edgard", id: id++ }];
84+
}
85+
}
86+
};
87+
</script>
88+
<style scoped>
89+
.buttons {
90+
margin-top: 50px;
91+
}
92+
</style>
93+

0 commit comments

Comments
 (0)