Giter Site home page Giter Site logo

pulsardev / vue-tour Goto Github PK

View Code? Open in Web Editor NEW
2.4K 27.0 279.0 8.56 MB

Vue Tour is a lightweight, simple and customizable guided tour plugin for use with Vue.js. It provides a quick and easy way to guide your users through your application.

Home Page: https://pulsardev.github.io/vue-tour

License: MIT License

HTML 31.60% Vue 44.71% JavaScript 23.69%
vue javascript tour

vue-tour's Introduction

Vue Tour

CircleCI

Vue Tour is a lightweight, simple and customizable tour plugin for use with Vue.js. It provides a quick and easy way to guide your users through your application.

Vue Tour

Table of Contents

Getting Started

You can install vue-tour using npm or by downloading the minified build on GitHub.

npm install vue-tour

Then import the plugin in your application entry point (typically main.js if you used vue-cli to scaffold your project) and tell Vue to use it. Also don't forget to include the styles. You can add the styles provided by default or customize them to your own liking.

import Vue from 'vue'
import App from './App.vue'
import VueTour from 'vue-tour'

require('vue-tour/dist/vue-tour.css')

Vue.use(VueTour)

new Vue({
  render: h => h(App)
}).$mount('#app')

Finally put a v-tour component in your template anywhere in your app (usually in App.vue) and pass it an array of steps. The target property of each step can target a DOM element in any component of your app (as long as it exists in the DOM when the concerned step pops up).

<template>
  <div>
    <div id="v-step-0">A DOM element on your page. The first step will pop on this element because its ID is 'v-step-0'.</div>
    <div class="v-step-1">A DOM element on your page. The second step will pop on this element because its ID is 'v-step-1'.</div>
    <div data-v-step="2">A DOM element on your page. The third and final step will pop on this element because its ID is 'v-step-2'.</div>

    <v-tour name="myTour" :steps="steps"></v-tour>
  </div>
</template>

<script>
  export default {
    name: 'my-tour',
    data () {
      return {
        steps: [
          {
            target: '#v-step-0',  // We're using document.querySelector() under the hood
            header: {
              title: 'Get Started',
            },
            content: `Discover <strong>Vue Tour</strong>!`
          },
          {
            target: '.v-step-1',
            content: 'An awesome plugin made with Vue.js!'
          },
          {
            target: '[data-v-step="2"]',
            content: 'Try it, you\'ll love it!<br>You can put HTML in the steps and completely customize the DOM to suit your needs.',
            params: {
              placement: 'top' // Any valid Popper.js placement. See https://popper.js.org/popper-documentation.html#Popper.placements
            }
          }
        ]
      }
    },
    mounted: function () {
      this.$tours['myTour'].start()
    }
  }
</script>

For all individual elements you want to add a step on, make sure it can be retrieved with document.querySelector(). You can use any selector, an ID, a CSS class, data attributes, etc. Once this is done and your steps correctly target some DOM elements of your application, you can start the tour by calling the following method.

this.$tours['myTour'].start()

For a more detailed documentation, checkout the docs for vue-tour.

before() UI step functions

If you need to do UI setup work before a step, there's a before function you may include in any/each of your steps. This function will get invoked before the start/next/previous step is rendered. The function must return a promise. The function is invoked when start, nextStep, and previousStep are triggered. When the promise is rejected, it will not move to the next or previous step. If the promise is resolved then it will move in the direction specified.

It's used when you need to change what's shown on the screen between steps. For example, you may want to hide one set of menus and open a screen or you want to perform an async operation. This is especially useful in single-page applications.

steps: [
  {
    target: '#v-step-0',  // We're using document.querySelector() under the hood
    content: `Discover <strong>Vue Tour</strong>!`,
    before: type => new Promise((resolve, reject) => {
      // Time-consuming UI/async operation here
      resolve('foo')
    })
  }
]

Something Missing?

If you have a feature request or found a bug, let us know by submitting an issue.

vue-tour's People

Contributors

anoff avatar bsl333 avatar buwilliams avatar chaotic-stump avatar cromonms avatar dependabot[bot] avatar glorat avatar guastallaigor avatar hzooly avatar mattgreenfield avatar mmorainville avatar outpox avatar rebotak avatar reidjs avatar smitpatelx avatar sylver-john avatar zikolach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-tour's Issues

[Question] How can I show a step content after user performs an action(like open a dropdown menu)

Use Case:
While user goes through each step, at some point I want the user to open a dropdown menu. After user opens the dropdown menu, the tutorial will explain the menu options.

Sandbox link: https://codesandbox.io/s/4jpnjqw8z9

Issue:
Using the onNextStep callback, I am able to open the dropdown menu using javascript. But, since, the menu was not open when the page loaded, vue-tour does not show the step 3 popper.
How can I force vue-tour to show the next step content after the dropdown menu is opened?

vue-tour compatible with es2015 transpilation

I redacted this issue in stackoverflow,
i have a problem with my project .babelrc es2015 transpilation, if i import the vue-tour as is, i get this erro message:

error  in ./~/vue-tour/dist/vue-tour.umd.js

Module build failed: Error: Couldn't find preset "@vue/app" relative to directory "C:\\xampp\\htdocs\\avanttia\\node_modules\\vue-tour"
    at C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:293:19
    at Array.map (<anonymous>)
    at OptionManager.resolvePresets (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
    at OptionManager.mergePresets (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
    at OptionManager.mergeOptions (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
    at OptionManager.init (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
    at File.initOptions (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\index.js:212:65)
    at new File (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\file\index.js:135:24)
    at Pipeline.transform (C:\xampp\htdocs\avanttia\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
    at transpile (C:\xampp\htdocs\avanttia\node_modules\babel-loader\lib\index.js:46:20)
    at Object.module.exports (C:\xampp\htdocs\avanttia\node_modules\babel-loader\lib\index.js:163:20)

 @ ./resources/assets/js/wizard/main.js 49:15-34
 @ multi ./resources/assets/js/wizard/main.js

If in the node_modules/vue-tour library i change the .babelrc file to this:

"presets": [
        "es2015"
      ]

it works as expected, but this is undesired as i have to change everywhere i have to deploy this project.
Can you make a fix for this issue please?

Handling targets in corners

I ran into an issue while attempting to target elements at corners. The .v-step__arrow seems to always be in the middle of the tour step which, in turn, ends up pointing away from the actual target.

Here's a pen describing the issue. The example has 3 tour steps, the third of which highlights a different issue (the whole screen moves to accomodate the step and it doesn't move back), but I suspect this might just be an issue on my machine.

In short, this could probably be solved with placement values of top-left, top-right and so on. I strongly feel that this is something that's absolutely necessary for mobile since things tend to get pushed to corners a lot on small screens.

Missing posibbility to translate texts

Hi, can you add a possibility to translate texts in the app, please? Right now all the texts are hardcoded and it is not possible to easily use this lib in a different language.

Provide own labels

How can I in general provide custom labels for the general labels of next prev etc. ?

Hack-ish way to add highlight to active element

I know this feature is something you guys are/will work on, but I can't wait so i found an easy hack that works for me and I think it might help others as well so i'm sharing this here.
More about this feature in here: #11

Code

You can find the full code here:
https://gist.github.com/Art3miX/88fc3a56353ca8045f49bc8f7cc6543f

I use it as a mixin because i do several tours (1 per specific route), so its an easy way for me to add it quickly, but you can simply take the code from the functions and add it to the place you need it.
The css is in a comment at the end of the page.

Support

The code use CSS pointer-events and JS classList add and remove functions, you can find the support table here:
https://caniuse.com/#feat=pointer-events
https://caniuse.com/#feat=classlist

Only tested on chrome for now, but should work for all major versions.

What it does?

Highlight

It basically adds a shadow around the active step element with 0.6 opacity which gives a nice background above the rest of the page.

Disable clicks

It uses pointer-events: none on the body to disable all click events, and the active step element uses pointer-events: auto, to enables clicks only on that active element.
You can disable events for all of the page including the active element if wanted, simply remove the class from the rule, BUT don't forget to leave pointer-events: auto; on the v-tour class so the tour will be clickable.

Responsive

I added few media queries to make the shadow smaller for smaller devices simply because we don't need 10kpx around the div for devices that are 700px wide.
The size of the shadow is still larger from the size of the screen just in case, this can be modified to be smaller if you want to.

Notes

I built it for my self and it has everything I need, i will most likely upgrade it a bit for my needs and will keep the file updated, but this is a simple hack-ish way to get it done, make sure to test it before using it.

I'm not working on this project in any way, this is simply how i implemented this feature for my own use, so take the code and play with it for your use, i know the guys are working on this feature in a more stable and better way.

Suggestions / bugs

Any suggestions to make it better will be appreciated, and if you found a bug let me know please.

Postion of cards

One issue arises about the position of the cards not able to change for particular step.
cross component tour implementation

Popper options

Would be nice if we could specify all the popper.js options if needed. Why not just ferry them along to popper if they are defined? Currently it appears to only allow specifying the placement option.

scrollIntoView options

It would be useful if we were able to pass in the options we want to when the scrollIntoView method is triggered. It could be just props on the component scrollIntoViewOptions or something.

Optional Start Step

Hello again,

I have added a simple tweak to the start() function (locally) where you can optionally add a step number and start from that step, if you omit the start step then it starts from 0 as normal:

start (step) {
  // Wait for the DOM to be loaded, then start the tour
  setTimeout(() => {
    this.customCallbacks.onStart()
    this.currentStep = step || 0
  }, this.customOptions.startTimeout)
},

A neat trick this allows is to be able to have a tooltip type effect on particular steps you desire.

<label class="label">Label <a @click="tourStep1"><i class="fa fa-info-circle"></i></a></label>
tourStep1 () {
  this.$tours['releaseFormTour'].start(1)
}

vue-tour-tooltip-effect

Custom Button Text / i18n support

Hello guys,
it would be nice to have the static texts like
Skip tour
Previous
Next
Finish
configuratable. That would be nice for tours on non english pages ;)

.v-step z-index

Hi,

Really glad to have found this, it's helping me a lot! Thanks.

Found a bug, I am using Bulma.io for styles, so not sure if it's a compatibility issue or not.

Basically I get a display problem with the steps, and it's fixed after adding z-index: 10000 to .v-step[data-v-570be51d] see pics.

Without z-index

vue-tour-no-z-index

With z-index

vue-tour-z-index-10000

Not sure if this is something you'd like to add to the css in the library. But thought I'd let you know.

Option for "no target element"

It would be great to have an option that just does a center-screen pop-up by specifying no target element. This would allow for, for example, an introduction or closing statement.

Keyboard events firing all tours custom callbacks

The keyboard events are registered globally so if you have multiple tours in your app, it will fire the custom events for every tour. I ran into this with the stop callback, I was running some custom logic specific to each tour on the stop callback and it was running every single tour's stop logic when I hit the escape key instead of the running tour's stop callback.

I worked around it for now by checking that the current tour is running first in the callback:
if (this.$tours[this.tourName].isRunning)....

Possible fix: namespace the events or only register/unload them when a tour is in progress rather than on mount?

.v-step z-index

Sometimes, it's blocked by higher levels of parent elements.

I've changed " .v-step's z-index to 999" in Source code

Async inclusion/import

Hi,

First off - great component! :)

Is there a way to not use the Vue.use() pattern and to load in the component on-demand?
Even though the component is 10kB gzipped (according to Bundlephobia), that's still 10kB
that every reoccurring user would need to download and 30kB for the browser to parse.

Cheers,
Andreas

Usage with Quasar components

Hi there,
Great plugin.
I encountered a problem with using this plugin with Quasar layout.
Here is a sample FerrielMelarpis/repro#2
I'm not sure why the Popper does not get attached properly to the component.
screenshot_20180319_184358

I'm not entirely sure if this is an issue with vue-tour or in Popper.
Would be a great help if someone can help me with this issue.
Thanks!

Manually Trigger next step and prev step?

First of all, thank you so much for this beautiful component. It's exactly what i needed. But i have few questions.

  1. How can we turn off automatic next step and prev step events?
    i want to stop user to stay in current step until he/she finishes some task and after that he/she can go to next step. I used callback methods. But it just giving me indication, that user clicked next/prev button and proceeds with next/prev step. what i want is i dont want the user to go to next step. i can trigger it manually.

EDIT: i looked into this issue #12 . it seems in my vue methods i get myTour of undefined. i have excatly the same name as in the example.

  1. I followed this #3 to get the current index to highlight the current step block. but the problem is, when i reload i get currentStep is undefined. i dont know what i am doing wrong.

  2. How can i reference a remote component?
    Say i have a navigation bar. i included it in app.vue and now i am in some route. after user finished the current steps. i want to let user know that he/she can go to "particular" page to continue.

i already searched issues and docs for these issues. but couldnt find one.

thanks in advance.

Support querySelectorAll

Would be great if there was a way to use querySelectorAll, e.g. to select the second span via:

span:nth-child(2)

Maybe something like this:

target: 'span:nth-child(2)',
content: `This is the second span`,
params: {
  selectionMethod: 'querySelectorAll',
},

If the result of the selection is an array, it could just use the first element.

Translate buttons action

Can i have possibility to translate buttons "Skip tour", "Previous", "Next" and "Finish" ?

thx !

Skip Tour button persistence

hello and thank you for this nice component. Is there a possibility to make the hook on the skip tour and persist it in the localstorage so the next time it remembers the user preference.
maybe there is another way.
if you can point to the right direction would be great.

Getting lots of errors when using custom template example from docs

Hey Guys,

We're following the example from the docs...

<v-tour name="myTour" :steps="steps">
  <template slot-scope="tour">
    <transition name="fade">
      <v-step
        v-if="tour.currentStep === index"
        v-for="(step, index) of tour.steps"
        :key="index"
        :step="step"
        :previous-step="tour.previousStep"
        :next-step="tour.nextStep"
        :stop="tour.stop"
        :isFirst="tour.isFirst"
        :isLast="tour.isLast"
      >
        <template v-if="tour.currentStep === 2">
          <div slot="actions">
            <button @click="tour.previousStep" class="btn btn-primary">Previous step</button>
            <button @click="tour.nextStep" class="btn btn-primary">Next step</button>
          </div>
        </template>
      </v-step>
    </transition>
  </template>
</v-tour>

But getting the following errors...

Error in render: "TypeError: Cannot read property 'buttonSkip' of undefined"

TypeError: Cannot read property 'buttonSkip' of undefined at Proxy.VStepvue_type_template_id_aa0cbe42_scoped_true_render

Error in mounted hook: "TypeError: Cannot read property 'setAttribute' of undefined"

vue.common.js:1743 TypeError: Cannot read property 'setAttribute' of undefined

Any ideas?

Change Event

Helllo,
i seach for a easy way to highlight the item for the current step.
I think a change method could be a nice improvment for that, e.g.:

<v-tour name="myTour" :steps="steps" @change="(step, active) => console.log(active ? 'activate step' : 'deactivate step', step)" ></v-tour>

As workaround i could do this, but there is maybe a better way also:

startTour () {
      let tour=this.$tours['myTour']
      if(tour.modified){
        tour.start()
        return
      }
      tour.modified=true

      
      let stepChange = (step, active) => ( active ? document.querySelector(step.target).classList.add('highlight') : document.querySelector(step.target).classList.remove('highlight'))

      let orgNextStep=tour.nextStep
      tour.nextStep=function(){
        stepChange(tour.steps[tour.currentStep], false)
        orgNextStep()
        stepChange(tour.steps[tour.currentStep], true)
      }
      // ...wrapp all other Methods
      tour.start()
    }

Thank you!

E2E not working in demo

Cypress before fails CypressError: cy.visit() must be called with a string as its 1st argument.

Cypress.env('VUE_DEV_SERVER_URL') is undefined.

Perhaps you missed to commit your env files ?

Next step not showing

Hi,

I'm experiencing some problems regarding having the next step of my tour working. The second step of my tour isn't appearing wherein its target element is hidden via v-show statement.

When i clikc on Esc the function this.callbackTour.onStop is called ..

In my example, i have lot of IView selects, when i want to quit this select i click on esc but this function : callbackTour.onStop is called..

i have a condition on this function, when the client click on stop vue tour, i have a message who indicated to the client where he had to relaunch the tour.

so this message appear when the client click on esc.. it's weird

Do you have an idea ?

Uncontrollable behaviour with scroll and x-placement

Hey,
I'm having an issue with auto scrolling. If an element that the next step is attached to is lower in the page, the auto scroll will adjust the 'x-position' attribute making it flicker from 'x-position=bottom' to my set placement parameter.
I assume this is a feature that always keeps the step in view, but it makes navigating through steps look glitchy.
Not sure if you're aware of this issue, or if there's a way of hiding the step when scrolling and then showing it again?

onUpdate callback

Hello, thank you too for wrapper but i have a problem.
data(){ return { anyData: false, steps: [ { target: '.registration', content: 'Discover <strong>Vue Tour</strong>!', params: { onUpdate(data) { this.anyData = true; } } }, ] } }

if i trying change data status to anyData, anyData is not changing.
or if i call method there, returning error " the methodName() is not function."

How can i vue method, props or data in that like event?

next element not visible

I have a question, when I have a form that varies with the information that the customer provides, there are not all the fields provided in the tour, how do I advance to the next visible field of the tour, and back to the previous visible field.
And if you change an option in the middle of the form, you should go back to the previous visible option.

I was updating the fields with the callbacks (onPreviousStep, onNextStep) but this does not solve the problem if I delete half a form in half.

How can I resolve this?

thank you

Support for title slot in options

Feature request: It's really common to have a title in addition to content. Maybe provide a slot for title also and allow passing in as options?

I'm getting around this for now by changing step.content to an object and doing the following but concerned it might break in future if not a baked in option.

<span v-if="step.content.title" v-html="step.content.title"></span>
<span v-if="step.content.text" v-html="step.content.text"></span>

(btw i'm under release crunch so I can't contribute at the moment but certainly can in the future)

Adding tour steps across components

I want to create tours based on what components are on a page, potentially through many layers of nesting. Is it possible to add steps across multiple components, or to add a step to an actual component?

If I were to add child steps would I need to (for instance) return them through a callback on my component and merge them into a computed “steps” property?

What would be the best way to achieve this?

Difference between skip and stop callback

Hi, it would be great to find a way to know if the user clicked on "Finish" or on "Skip".
Proposal:

  • if click on skip: Call a method skip() with a custom callback onSkip and call after stop()

  • if click on finish: Call a method finish() with a custom callback onFinish and call after stop()

Usage of @click on Steps breaks forms.

As per previous issue I am using this is a way of explaining a form in detail.

Clicking on Skip Tour submits my

and refreshes the page with the form on effectively adding a very long string to the address bar.

I propose to use @click.prevent on the buttons to stop this behaviour.

<button @click.prevent="stop" v-if="!isLast" class="v-step__button">Skip tour</button>
<button @click.prevent="previousStep" v-if="!isFirst" class="v-step__button">Previous</button>
<button @click.prevent="nextStep" v-if="!isLast" class="v-step__button">Next</button>
<button @click.prevent="stop" v-if="isLast" class="v-step__button">Finish</button>

blurry text

Hello, thanks for the great component, really useful.

for some reason my text is blurry on chrome on ubuntu, with the default colors the text doesn't look so blurry, but if you change the background color to white and text to black, you can easily see this blurry text.

This is a known issue: https://stackoverflow.com/questions/32034574/font-looks-blurry-after-translate-in-chrome

but none of the fixes helped for me, any ideas how this can be fixed?

image

PS. playing with the pixel values in the transform: translate3d field of the v-step does help, but we don't have access to it.

Cannot access parent component element

Hi, it's working on my pages component, but how can i call parent component element like header or sidebar ? i tried to call parent element id but that step it's not working.

Add support for calling a function or raising an event when a step loads

Is it possible to raise a vue event or call a function when a step is run? I don't see it in the documentation and after a quick read through the source code I'm not sure what the best approach would be... but we would like to execute some javascript code when reaching a particular step.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.