Open
Conversation
Its now possible to have a second element on the page while a tour is active, displaying information about the current Tour.
…inter is centered to the page and arrow is hidden for a generic modal step.
…ector function per step for setting the pointer to more complex elements, eg call .closest
…d router.prefetch. Updated README
…nto <Portal/>. Added timout to MutationObserver
…t the next step by user-provided condidtions
Deprecated .nextRoute and .prevRoute in favour of .route Deprecated Onborda.steps in favor of OnbordaProvider.tours. currentTourSteps now stored in useState within useOnborda.
Each step can now have an initialCompletedState via async function. This will be called when the tour starts via a Promise.all on every step. User will start tour on the first incomplete step. Handling of routing and finding element to focus has been consolidated into the main useEffect to reduce repeated code. nextStep, prevState and setStep now just change the currentStep useState, triggering the useEffect to change route and find the element if set.
Added onComplete callbacks to the Step object. Merged useEffects to improve route change awareness ensuring onComplete is called after the route has updated to prevent potential serverActions revalidation on the previous route blocking router.push.
…p states in one call rather than one per step
… TourCard.closeOnborda()
|
Is adding a global context the best way out ? |
|
this is great, thanks for putting this together! |
Owner
|
Hey @alexc-harrap - thanks so much for all your work here, some really good changes! I'm sorry for such a slow response speed, i've just started working at Prisma with no time-off between so its been a hectic couple of months! I'm implementing some of the changes bit by bit right now! |
uixmat
reviewed
Dec 22, 2024
Owner
There was a problem hiding this comment.
@alexc-harrap I'm making some updates today and i really like this update but would like to give you full credit and have you marked as a collaborator on the package. After i've made a release i'd love you to submit a PR with the onComplete and path changes (2b32a4c) if you have the time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @uixmat
I have been building off of your package (thanks for this!) to add some features that we needed for our use case. It is a large PR and does contain some breaking changes so not expecting it to be approved, but creating a PR in case you would like to copy some of the enhancements I have added even if you reject the PR.
Breaking Changes
<Onborda />no longer hassteps : Tour[]. This has been moved up to<OnbordaProvider />and calledtours: Tours[].OnbordaContexthas access to every tour and its steps to allow a newuseOnbordafunction ofsetStepwhich can switch to any step in the current tour, not just the previous or next.Step.prevRouteandStep.nextRoutehave been deprecated in favour of a singleStep.routedefined per step. This is to ensure when switching to any step, the correct route can be navigated to.Added new optional TourCard
The TourCard is a secondary card displayed in addition of the StepCard on the overlay. The TourCard is intended to show details of the current tour. Eg the todo list of steps.
Added optional Step.interactable = false
Each step can now block or allow interaction with the focused element on a step-by-step basis. EG if the step is part of a setup tour and you point the user to an input for setting their organisation name for example, they can fill that in while the overlay is still active. But if you want to just show them around the site without them changing the current route, then it can be set to false.
Added useOnborda.completedSteps[]
completedStepsis a Set of indexes. Once a step is shown or conditions met (see below), it is added to this Set automatically. This allows the TourCard to keep track of which steps have been 'completed' and allow showing a checkmark against the step for example.Added optional Step.isCompleteConditions()
isCompleteConditionsis a client function that is bound to an event listener on the focussed element onclick, input and change. The Element is then passed to this function for custom conditions to be applied before the step is added to thecompletedStepsSet. EG if the focused element is an input field, theisCompleteConditionsfunction can check the value is valid before marking it as complete.Added optional Step.onComplete() callback
onCompleteis a callback called whenever the step is marked as completed. This can be used to store the state of the step server side.Added optional Step.customQuerySelector()
I found while using Step.selector that sometimes with UI libraries, the element you can set the ID on is within other divs, causing the pointer to be offset. This allows for getting the selectors parent Element for example.
Added optional Tour.initialCompletedStepsState()
initialCompletedStepsStateis aPromise<boolean[]>that is called when a tour is started. This allows fetching the initial completed steps state from a server action. It should return a boolean array the same size as the Tour.Steps array.Added
[key: string]to Tour and Step Objects[key: string]is a way to allow the user to provide any additional data or flags they wish to use in their TourCard or StepCard making it easier to customise per step or per tour.Added optional OnbordaProvider.activeTour
activeTouris way to set an initial active tour on load without having to callstartOnbordaorsetTour. This can be useful for Setup tours where you would want the tour to be forced on until the user has completed it.I have created a demo codespace on my github showcasing the TourCard:
https://github.com/alexc-harrap/Libresoft-Onborda-Demo