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
feat(useStepper): new function #1754
Conversation
All done, thanks for the review! |
'terms', | ||
'payment', | ||
]) | ||
``` |
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.
Should we also have a short example of object usage?
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.
Added it 👍
Using an object relies on the key order being maintained. From that second link:
I'm not sure if the possibility that this doesn't work in various older/less-major browsers is an issue? One of the gotchas that could affect this composable is the sorting of different property types. A potential fix is to rather pass an array of objects, with each an extra property in each object to specify the name. |
What do you think of disallowing mixed object keys instead, as a compromise? That might prove easier to type. |
Even if it proves easier to type (I doubt it), it is still a compromise, disallowing real use cases. Any reasons the potential fix I suggested would not work? |
It might work, but I have no clue how to type that, it's more boilerplate and it removes one potential key from the object too. |
useStepper
Note
This is an improved version of #1679, with which I was not happy. I've continued building wizards (steppers) in my application, and this composable is the result of what feels to me is perfect and flexible for most use cases.
This new implementation has better types and support both array and objects as steps.
Description
This new utility helps building step-based wizard user interfaces. This is something that I did repeatedly in one of our applications, and this is the actual composable I'm using.
The declaration of the steps is done via an array of strings, which serve as identifiers, or via an object, which keys serve as identifiers. The composable returns a set of computed values and functions that are very useful to navigate through the steps.
For instance, the
goToPrevious
andgoToNext
function move. Computed variables likeisFirst
,isLast
orcurrent
help determining what to display. To display the component for the current step, one can useisCurrent('step name')
.Example
The demo is a full example, and tests cover all functionalities, but here is what it looks like at a glance.
What is the purpose of this pull request?