tour.vue
2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<script setup>
import { useShepherd } from 'vue-shepherd'
const route = useRoute()
// 👉 Hotkey
// eslint-disable-next-line camelcase
const { ctrl_k, meta_k } = useMagicKeys()
// 👉 Tour initialization
let tour = null
// 👉 watch command palette and route change
/* eslint-disable camelcase */
watch([
ctrl_k,
meta_k,
() => route.path,
], () => {
if (tour.isActive())
tour.cancel()
})
/* eslint-enable */
onMounted(() => {
const navbar = document.querySelector('.layout-navbar')
tour = useShepherd({
useModalOverlay: true,
stepsContainer: document.querySelector('.layout-wrapper'),
modelContainer: document.querySelector('.layout-wrapper'),
defaultStepOptions: {
cancelIcon: { enabled: true },
modalOverlayOpeningPadding: 2,
modalOverlayOpeningRadius: 5,
},
})
// 👉 Tour steps
tour.addSteps([
{
id: 'welcome',
title: 'Welcome',
arrow: true,
attachTo: {
element: navbar,
on: 'bottom',
},
text: 'Welcome to our tour page, Guide users to the key features of the product.',
buttons: [
{
action: tour.cancel,
classes: 'backBtnClass',
text: 'Back',
},
{
action: tour.next,
text: 'Next',
classes: 'nextBtnClass',
},
],
},
{
id: 'notification',
title: 'Notifications',
arrow: true,
attachTo: {
element: document.querySelector('#notification-btn'),
on: 'bottom',
},
text: 'Manage your notifications and stay up-to-date with latest updates.',
buttons: [
{
label: 'Back',
text: 'Back',
action: tour.back,
classes: 'backBtnClass',
},
{
label: 'Next',
text: 'Next',
action: tour.next,
classes: 'nextBtnClass',
},
],
},
{
id: 'footer',
title: 'Footer',
arrow: true,
attachTo: {
element: document.querySelector('.layout-footer'),
on: 'bottom',
},
text: 'Footer section of the page.',
buttons: [
{
label: 'Back',
text: 'Back',
action: tour.back,
classes: 'backBtnClass',
},
{
label: 'Finish',
text: 'Finish',
action: tour.complete,
classes: 'nextBtnClass',
},
],
},
])
})
</script>
<template>
<div>
<VCard title="Tour">
<VCardText>
<VBtn
variant="outlined"
@click="() => { tour && tour.start() }"
>
Start Tour
</VBtn>
</VCardText>
</VCard>
</div>
</template>
<style lang="scss">
@use "@core/scss/template/libs/shepherd.scss";
</style>