Skip to content

Commit 3633756

Browse files
Improving templates
1 parent bc47438 commit 3633756

File tree

5 files changed

+67
-45
lines changed

5 files changed

+67
-45
lines changed

Diff for: example/App.vue

-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ const components = requireContext.keys().reduce((acc, key) => {
132132
}, {});
133133
134134
const showAll = process.env.VUE_APP_SHOW_ALL_EXAMPLES === "true";
135-
window.console.log(process.env.VUE_APP_SHOW_ALL_EXAMPLES);
136135
if (showAll) {
137136
const order = Object.keys(components);
138137
const requireContextDebug = require.context(

Diff for: example/components/headerslot.vue

+18-16
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
{{ element.name }}
1919
</div>
2020

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>
21+
<template v-slot:header>
22+
<div
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+
</template>
31+
3032
</draggable>
3133
</div>
3234

@@ -42,26 +44,26 @@ export default {
4244
display: "Header slot",
4345
order: 13,
4446
components: {
45-
draggable
47+
draggable,
4648
},
4749
data() {
4850
return {
4951
list: [
5052
{ name: "John 1", id: 0 },
5153
{ name: "Joao 2", id: 1 },
52-
{ name: "Jean 3", id: 2 }
54+
{ name: "Jean 3", id: 2 },
5355
],
54-
dragging: false
56+
dragging: false,
5557
};
5658
},
5759
methods: {
58-
add: function() {
60+
add: function () {
5961
this.list.push({ name: "Juan " + id, id: id++ });
6062
},
61-
replace: function() {
63+
replace: function () {
6264
this.list = [{ name: "Edgard", id: id++ }];
63-
}
64-
}
65+
},
66+
},
6567
};
6668
</script>
6769
<style scoped></style>

Diff for: example/components/two-list-headerslots.vue

+24-19
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,16 @@
1919
{{ element.name }}
2020
</div>
2121

22-
<div
23-
slot="footer"
24-
class="btn-group list-group-item"
25-
role="group"
26-
aria-label="Basic example"
27-
>
28-
<button class="btn btn-secondary" @click="add">Add</button>
29-
<button class="btn btn-secondary" @click="replace">Replace</button>
30-
</div>
22+
<template v-slot:footer>
23+
<div
24+
class="btn-group list-group-item"
25+
role="group"
26+
aria-label="Basic example"
27+
>
28+
<button class="btn btn-secondary" @click="add">Add</button>
29+
<button class="btn btn-secondary" @click="replace">Replace</button>
30+
</div>
31+
</template>
3132
</draggable>
3233
</div>
3334

@@ -43,15 +44,16 @@
4344
{{ element.name }}
4445
</div>
4546

46-
<div
47-
slot="footer"
48-
class="btn-group list-group-item"
49-
role="group"
50-
aria-label="Basic example"
51-
>
52-
<button class="btn btn-secondary" @click="add2">Add</button>
53-
<button class="btn btn-secondary" @click="replace2">Replace</button>
54-
</div>
47+
<template v-slot:footer>
48+
<div
49+
class="btn-group list-group-item"
50+
role="group"
51+
aria-label="Basic example"
52+
>
53+
<button class="btn btn-secondary" @click="add2">Add</button>
54+
<button class="btn btn-secondary" @click="replace2">Replace</button>
55+
</div>
56+
</template>
5557
</draggable>
5658
</div>
5759

@@ -78,7 +80,10 @@ export default {
7880
{ name: "Joao 2", id: 1 },
7981
{ name: "Jean 3", id: 2 }
8082
],
81-
list2: [{ name: "Jonny 4", id: 3 }, { name: "Guisepe 5", id: 4 }]
83+
list2: [
84+
{ name: "Jonny 4", id: 3 },
85+
{ name: "Guisepe 5", id: 4 }
86+
]
8287
};
8388
},
8489
methods: {

Diff for: example/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ const app = createApp(App);
1919
app.use(store);
2020
app.use(router);
2121
app.component("rawDisplayer", rawDisplayer);
22-
app.mount("#app");
22+
router.isReady().then(() => app.mount('#app'));

Diff for: example/route.js

+24-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,27 @@
1-
const ctx = require.context("./components/", false, /\.vue$/);
1+
function getRouteFromDirectory(ctx) {
2+
return ctx.keys().map(key => ({
3+
path: key.substring(1).replace(".vue", ""),
4+
component: ctx(key).default,
5+
}));
6+
}
7+
8+
const showAll = process.env.VUE_APP_SHOW_ALL_EXAMPLES === "true";
9+
window.console.log(process.env.VUE_APP_SHOW_ALL_EXAMPLES);
10+
11+
const routes = [
12+
...getRouteFromDirectory(require.context("./components/", false, /\.vue$/)),
13+
...(!showAll
14+
? []
15+
: getRouteFromDirectory(
16+
require.context("./debug-components/", false, /\.vue$/)
17+
)),
18+
{
19+
path: "/",
20+
redirect: "/simple",
21+
},
22+
];
23+
24+
window.console.log(routes);
225

3-
const routes = ctx.keys().map(key => ({
4-
path: key.substring(1).replace(".vue", "")
5-
}));
626

7-
routes.push({
8-
path: "/",
9-
redirect: "/simple"
10-
});
1127
export default routes;

0 commit comments

Comments
 (0)