Skip to content

Commit 2ead09e

Browse files
committed
feat(steps): add the possibility to change the text of the buttons through the tour options
1 parent f5f3e00 commit 2ead09e

File tree

5 files changed

+25
-20
lines changed

5 files changed

+25
-20
lines changed

demo/src/components/MyTour.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
:stop="tour.stop"
1818
:is-first="tour.isFirst"
1919
:is-last="tour.isLast"
20+
:labels="tour.labels"
2021
>
2122
<template v-if="tour.currentStep === 2">
2223
<div slot="actions">
@@ -77,7 +78,7 @@ export default {
7778
7879
// A dynamically added onStop callback
7980
this.callbacks.onStop = () => {
80-
document.querySelector('#v-step-0').scrollIntoView({behavior: 'smooth'})
81+
document.querySelector('#v-step-0').scrollIntoView({ behavior: 'smooth' })
8182
}
8283
},
8384
methods: {

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/VStep.vue

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515

1616
<slot name="actions">
1717
<div class="v-step__buttons">
18-
<button @click.prevent="stop" v-if="!isLast" class="v-step__button" v-text="textSkip"></button>
19-
<button @click.prevent="previousStep" v-if="!isFirst" class="v-step__button" v-text="textPrevious"></button>
20-
<button @click.prevent="nextStep" v-if="!isLast" class="v-step__button" v-text="textNext"></button>
21-
<button @click.prevent="stop" v-if="isLast" class="v-step__button" v-text="textEnd"></button>
18+
<button @click.prevent="stop" v-if="!isLast" class="v-step__button">{{ labels.buttonSkip }}</button>
19+
<button @click.prevent="previousStep" v-if="!isFirst" class="v-step__button">{{ labels.buttonPrevious }}</button>
20+
<button @click.prevent="nextStep" v-if="!isLast" class="v-step__button">{{ labels.buttonNext }}</button>
21+
<button @click.prevent="stop" v-if="isLast" class="v-step__button">{{ labels.buttonStop }}</button>
2222
</div>
2323
</slot>
2424

@@ -52,13 +52,14 @@ export default {
5252
},
5353
isLast: {
5454
type: Boolean
55+
},
56+
labels: {
57+
type: Object
5558
}
5659
},
5760
data () {
5861
return {
59-
hash: sum(this.step.target),
60-
/* eslint-disable vue/no-reserved-keys */
61-
_popper: null
62+
hash: sum(this.step.target)
6263
}
6364
},
6465
computed: {
@@ -77,7 +78,7 @@ export default {
7778
// console.log('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] is:', targetElement)
7879
7980
if (targetElement) {
80-
if (this.params.scroll) {
81+
if (this.params.enableScrolling) {
8182
let jumpOptions = {
8283
duration: this.step.duration || 1000,
8384
offset: this.step.offset || 0,
@@ -89,7 +90,7 @@ export default {
8990
}
9091
9192
/* eslint-disable no-new */
92-
this._data._popper = new Popper(
93+
new Popper(
9394
targetElement,
9495
this.$refs['v-step-' + this.hash],
9596
this.params

src/components/VTour.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
:stop="stop"
99
:is-first="isFirst"
1010
:is-last="isLast"
11+
:labels="customOptions.labels"
1112
>
1213
<!--Default slot {{ currentStep }}-->
1314
<v-step
@@ -20,10 +21,7 @@
2021
:stop="stop"
2122
:is-first="isFirst"
2223
:is-last="isLast"
23-
:text-skip="customOptions.text.skip"
24-
:text-previous="customOptions.text.previous"
25-
:text-next="customOptions.text.next"
26-
:text-end="customOptions.text.end"
24+
:labels="customOptions.labels"
2725
>
2826
<!--<div v-if="index === 2" slot="actions">
2927
<a @click="nextStep">Next step</a>

src/shared/constants.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ export const DEFAULT_CALLBACKS = {
88
export const DEFAULT_OPTIONS = {
99
useKeyboardNavigation: true,
1010
startTimeout: 0,
11-
text: {
12-
skip: 'Skip tour',
13-
previous: 'Previous',
14-
next: 'Next',
15-
end: 'Finish'
11+
labels: {
12+
buttonSkip: 'Skip tour',
13+
buttonPrevious: 'Previous',
14+
buttonNext: 'Next',
15+
buttonStop: 'Finish'
1616
}
1717
}
1818

1919
export const DEFAULT_STEP_OPTIONS = {
2020
placement: 'bottom',
21-
scroll: true,
21+
enableScrolling: true,
2222
modifiers: {
2323
arrow: {
2424
element: '.v-step__arrow'

0 commit comments

Comments
 (0)