Skip to content

Commit 1354557

Browse files
committed
feat: add enabledButtons new props (all true by default) which can
enable or disable the buttons of vue tour
1 parent c704b5e commit 1354557

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/components/VStep.vue

+10-4
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">{{ 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>
18+
<button @click.prevent="stop" v-if="!isLast && checkEnabledButtons('buttonSkip')" class="v-step__button">{{ labels.buttonSkip }}</button>
19+
<button @click.prevent="previousStep" v-if="!isFirst && checkEnabledButtons('buttonPrevious')" class="v-step__button">{{ labels.buttonPrevious }}</button>
20+
<button @click.prevent="nextStep" v-if="!isLast && checkEnabledButtons('buttonNext')" class="v-step__button">{{ labels.buttonNext }}</button>
21+
<button @click.prevent="stop" v-if="isLast && checkEnabledButtons('buttonStop')" class="v-step__button">{{ labels.buttonStop }}</button>
2222
</div>
2323
</slot>
2424

@@ -55,6 +55,9 @@ export default {
5555
},
5656
labels: {
5757
type: Object
58+
},
59+
enabledButtons: {
60+
type: Object
5861
}
5962
},
6063
data () {
@@ -104,6 +107,9 @@ export default {
104107
console.error('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] does not exist!')
105108
this.$emit('targetNotFound', this.step)
106109
}
110+
},
111+
checkEnabledButtons (name) {
112+
return this.enabledButtons.hasOwnProperty(name) ? this.enabledButtons[name] : true
107113
}
108114
},
109115
mounted () {

src/components/VTour.vue

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
:is-first="isFirst"
1010
:is-last="isLast"
1111
:labels="customOptions.labels"
12+
:enabled-buttons="customOptions.enabledButtons"
1213
>
1314
<!--Default slot {{ currentStep }}-->
1415
<v-step
@@ -22,6 +23,7 @@
2223
:is-first="isFirst"
2324
:is-last="isLast"
2425
:labels="customOptions.labels"
26+
:enabled-buttons="customOptions.enabledButtons"
2527
>
2628
<!--<div v-if="index === 2" slot="actions">
2729
<a @click="nextStep">Next step</a>

src/shared/constants.js

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export const DEFAULT_OPTIONS = {
1313
buttonPrevious: 'Previous',
1414
buttonNext: 'Next',
1515
buttonStop: 'Finish'
16+
},
17+
enabledButtons: {
18+
buttonSkip: true,
19+
buttonPrevious: true,
20+
buttonNext: true,
21+
buttonStop: true
1622
}
1723
}
1824

0 commit comments

Comments
 (0)