shepherd icon indicating copy to clipboard operation
shepherd copied to clipboard

Could be useful to have a helper class to build steps/tours?

Open mlorenzog opened this issue 1 year ago • 1 comments

Hi,

I've just started to use the library and I'm really happy with the results so far. At our specific use case, we have a high variability at which steps should we show (based on user type, device, etc). A first approach could be to just define all the tours, and load the proper one based on the user/device, but it feels like it would become hard to maintain.

Another options I've just started testing is using a builder pattern to define the steps, and so far I'm finding it useful and flexible enough to cover all our scenarios.

Something like this (just an example):

const stepBuilder = new StepBuilder()
  .setId('my-element')
  .setText('My step description')
  .setAnchorPosition(isMobile ? 'bottom' : 'left')

if (isUserType1) {
  stepBuilder.addButton({
    text: 'Read more',
    action: () => {}
  })
}

stepBuilder.addButton({
    text: 'Next',
    action: tour.next
})

tour.addStep(stepBuilder.build())

My question is , could be useful to have helper classes to build steps/tours included within the library?

mlorenzog avatar Jan 19 '24 10:01 mlorenzog

@mlorenzog for Steps, you have the addStep and addSteps methods for building dynamic tours in this way, is there something else you had in mind?

chuckcarpenter avatar Feb 28 '24 23:02 chuckcarpenter