-
-
Notifications
You must be signed in to change notification settings - Fork 1k
feat(nuxt): add <NuxtLoadingIndicator>
component
#5121
Conversation
β Deploy Preview for nuxt3-docs canceled.
|
Co-authored-by: Damian <[email protected]>
Co-authored-by: Damian <[email protected]>
Co-authored-by: Damian <[email protected]>
Thanks for the PR @antfu. As we discussed in discord earlier, it might worth to pend this addition to base component based on a stable API for progress handling (Old discussions why needed: nuxt-community/axios-module#247, nuxt/http#105) Also we would probably rename component to something more generic such as |
<NuxtLoadingBar/>
So what are the next steps? I believe this is still a good improvements in term of UX and is completely optional. I think we can also see progressively about the usage and feedback from users for improving it step by step without breaking it. |
We could use provide / inject and a wrapper utility |
I agree. I prefer the Would love also your feedback on naming @danielroe |
In order to progress on this PR, we have to finalize naming at least. Introducing core API for loading state can be in a follow-up PR but we should consider it changes the usage scope of the component as the current component depends on Regarding naming, while progress and bar represent built-in default behavior, the bar isn't essentially a representation of a customized indicator such as a rotating circle and Nuxt should be open to that or even provide customizable built-ins of different indicators! Using bar in the name prevents progress on this. API could be open to that and we had this chance only during v2 to v3 migration for improvement. As summary:
|
I agree in the long term vision for sure! For naming, I would vote for |
I believe also that we need to change the place of Some apps may use middleware for some data fetching. |
I love the Regarding ordering, for sure. We can either do the improvement here or later PR. I'm fine with both :) Anyway, the whole hooking system of the component needs to be changed once we migrate to the core API. |
|
To have the ability to do full customization, maybe we could use slot? Something like: <NuxtLoadingIndicator v-slot="{ percent, show, color }">
<div>Custom rendering</div>
</NuxtLoadingIndicator> So users could have the freedom to now present as a bar, without the need to handle the timers themselves. |
<NuxtLoadingIndicator>
component
<NuxtLoadingIndicator>
component<NuxtLoadingIndicator>
component
In SPA, i have auth-middleware which does a onetime auth on a page reload, so i have added a loading indicator using page:start and page:finish hooks, i found that the page hooks are being called after the middleware is run so facing a white-screen delay. |
I believe we should also update to make sure the |
It does make sense to start this before middleware but I don't think we can move that hook. What about adding another one before middleware, and then finish loading on |
Makes sense, can we expose |
They will need to be added in:
|
@antfu can you add them? π |
I talked with @pi0 once, we were discuss about using something like One other thing is that I am a bit concerned about more runtime hooks added to the bundle will cause the payload size to increase for every app? |
What do you mean by the payload size to increase for every app? It will be the JS bundle growing, not the payload size ( I rather see the Also, the devtools will be able to get some time mesurements between thoses hooks to help users speed up their apps. |
I think Anthony refers to the bundle size for adding more bundle code (and also there is a slight runtime overhead of calling them) Having As of for controlling progress it might be trickier to depend state on multiple hooks ( |
Well so far in both Nuxt 3 we have between two routes: Middleware -> Suspense(Pages + Components) By using What you suggest is then to have the component listening to both |
[for the future] Yes. We render components based on
Makes sense. I think for this PR to move forward, if you like to also include progress for middleware, we can start with |
What we can do is to move forward by merging this PR, few people use middleware to fetch data at the moment anyway. Then introducing the middleware PR and add support for it for our loadingIndicator component. |
Nothing is blocking if middleware is not concern :) Already plan to locally test and merge for RC.5. |
5402cd4
to
eac0b61
Compare
π Linked issue
resolves https://github.com/nuxt/framework/discussions/2100
Based on @atinux's implementation.
β Type of change