-
Notifications
You must be signed in to change notification settings - Fork 39
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
Onborda PR #29
base: main
Are you sure you want to change the base?
Onborda PR #29
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! |
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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!
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[]
.OnbordaContext
has access to every tour and its steps to allow a newuseOnborda
function ofsetStep
which can switch to any step in the current tour, not just the previous or next.Step.prevRoute
andStep.nextRoute
have been deprecated in favour of a singleStep.route
defined 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[]
completedSteps
is 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()
isCompleteConditions
is 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 thecompletedSteps
Set. EG if the focused element is an input field, theisCompleteConditions
function can check the value is valid before marking it as complete.Added optional Step.onComplete() callback
onComplete
is 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()
initialCompletedStepsState
is 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
activeTour
is way to set an initial active tour on load without having to callstartOnborda
orsetTour
. 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