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

Request: Introduce target hierarchy #220

Open
regexj opened this issue Feb 11, 2022 · 0 comments
Open

Request: Introduce target hierarchy #220

regexj opened this issue Feb 11, 2022 · 0 comments

Comments

@regexj
Copy link

regexj commented Feb 11, 2022

Please allow target to be a string or an array of strings.

If array of strings is passed please iterate over those attempting to target each one in order till a target is found. Once target is found continue. Only stop the tour if all targets fail.

In making things mobile friendly we have components that are visible or not depending on whether user is on a desktop, tablet or mobile. Menu's appear different on mobile vs desktop. The UX for a user logging in for the very first time is different to a person triggering the tour after returning to the site and so we load different components accordingly. The vue-tour could naturally just allow us to pass a hierarchy of targets to attempt.

My current workaround is this:

{
  target: '.not-found-wrapper',
  content: this.$t('vueTour.welcome.page.home.step2') as string,
  params: {
    placement: VueTourPlacement.Top
  },
  before: () => new Promise((resolve) => {
    // set target to collection container if new member box doesn't exists
    const step = this.getCurrentStep() + 1; //+1 as we're in the before
    if (!document.querySelector('.not-found-wrapper')) {
      this.vueTour.steps[step].target = '.vue-virtual-collection-container';
    }
    resolve(true);
  })
},

I have to do this for every step where the target may be different according to device or user state. A much more elegant solution would be to pass an array of strings and then the tour could iterate over those targets and continue when the first target is found:

{
  target: ['.not-found-wrapper', '.vue-virtual-collection-container'],
  content: this.$t('vueTour.welcome.page.home.step2') as string,
  params: {
    placement: VueTourPlacement.Top
  }
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant