Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for vue sfc & target element click to next step #201

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/components/VStep.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

<slot name="content">
<div class="v-step__content">
<div v-if="step.content" v-html="step.content"></div>
<component v-if="step.component" :is="step.component.vue" v-bind="step.component.data" v-on="step.component.listeners">
<template v-if="step.component.content"> {{ step.component.content }} </template>
<template v-else-if="step.component.html" v-html="step.component.html"/>
</component>
<div v-else-if="step.content" v-html="step.content"></div>
<div v-else>This is a demo step! The id of this step is {{ hash }} and it targets {{ step.target }}.</div>
</div>
</slot>
Expand Down Expand Up @@ -121,6 +125,11 @@ export default {
this.$refs['v-step-' + this.hash],
this.params
)

if (this.step.targetIsBtn) {
this.attachClickListener()
}

} else {
if (this.debug) {
console.error('[Vue Tour] The target element ' + this.step.target + ' of .v-step[id="' + this.hash + '"] does not exist!')
Expand Down Expand Up @@ -190,6 +199,11 @@ export default {
},
isButtonEnabled (name) {
return this.params.enabledButtons.hasOwnProperty(name) ? this.params.enabledButtons[name] : true
},
attachClickListener() {
this.targetElement.addEventListener("click", () => {
typeof this.step.targetIsBtn === "function" ? this.step.targetIsBtn() : this.nextStep();
})
}
},
mounted () {
Expand Down