Uh oh!
There was an error while loading. Please reload this page.
feat(nuxt): add <NuxtLoadingIndicator> component - #5121
Conversation
✅ Deploy Preview for nuxt3-docs canceled.
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Damian <48835293+DamianGlowala@users.noreply.github.com>
Co-authored-by: Damian <48835293+DamianGlowala@users.noreply.github.com>
Co-authored-by: Damian <48835293+DamianGlowala@users.noreply.github.com>
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/>atinux
commented
May 25, 2022
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 |
atinux
commented
May 25, 2022
I agree. I prefer the Would love also your feedback on naming @danielroe |
pi0
commented
May 27, 2022
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:
|
atinux
commented
May 30, 2022
I agree in the long term vision for sure! For naming, I would vote for |
atinux
commented
May 31, 2022
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. |
atinux
commented
Jun 3, 2022
|
To have the ability to do full customization, maybe we could use slot? Something like: <NuxtLoadingIndicatorv-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> componentshiva-prasad-reddy
commented
Jun 18, 2022
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. |
atinux
commented
Jun 19, 2022
I believe we should also update to make sure the |
danielroe
commented
Jun 19, 2022
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 |
atinux
commented
Jun 21, 2022
Makes sense, can we expose |
danielroe
commented
Jun 21, 2022
They will need to be added in:
|
atinux
commented
Jun 21, 2022
@antfu can you add them? 😊 |
antfu
commented
Jun 21, 2022
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? |
atinux
commented
Jun 22, 2022
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. |
pi0
commented
Jun 22, 2022
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 ( |
atinux
commented
Jun 22, 2022
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 |
atinux
commented
Jun 22, 2022
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. |
pi0
commented
Jun 22, 2022
Nothing is blocking if middleware is not concern :) Already plan to locally test and merge for RC.5. |
🔗 Linked issue
resolves https://github.com/nuxt/framework/discussions/2100
Based on @atinux's implementation.
❓ Type of change