-
Notifications
You must be signed in to change notification settings - Fork 83
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
Add supporting code for Kolibri loaders #448
Conversation
- Extracts the logic for displaying loader for a minumum amount of time from KCircularLoader to a new useKShow composable to allow for usage in v-if/v-else blocks and with any component - Relatedly renames KCircularLoader's `show` prop to `shouldShow` to prevent from naming conflicts - Adds a documentation sidebar section for all composables and adds the documentation for useKShow there - Adds pieces of guidance to docs on when to use useKShow vs KCircularLoaders' minVisibleTime
@MisRob - can you think of an example that is not the circular loader where the new |
@marcellamaki One another example in Kolibri would be global linear loaders that have the same problem as circular ones. Even though I kept that in mind as well, the main motivation at this point was rather getting this code out of |
I have an assumption that showing any kind of loader very briefly, not just a circular one, is unhappy, but there are also different techniques to deal with loading the whole page than relying on liner loaders. So I believe we'd need more input from designers. I see two perspectives to consider here:
|
</ul> | ||
</DocsPageSection> | ||
|
||
<DocsPageSection title="Parameters" anchor="#parameters"> |
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.
"Parameters" and "Returns" would ideally get automatically generated from JSDoc comments of the composable function, similarly how "Props" are generated from components. I believe this would be helpful for the other two composables we have in KDS already. Will open an issue for this as soon as review of this PR is done.
@@ -170,6 +171,27 @@ export default [ | |||
}), | |||
], | |||
}), | |||
new Section({ | |||
title: 'Composables', |
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.
I imagine that we'd ideally move already existing composables (responsiveWindow and responsiveElement) to this section, rather than having them hidden in the components docs, and also move their code files to the same folder. In that way, we would have consistent imports in products.
I hope having this section above components will help with discoverability of KDS Composition API utilities (see learningequality/kolibri#11132 (comment)) cc @akolson
Can open follow-up.
Added some follow-up issues suggestions, Should be ready for review now. |
@marcellamaki By chance, I came across a different use-case today, that's even completely different from v-if/v-else blocks and shows that we might need to have this logic independent of the circular loader sooner than I thought. This will soon be
Notice If we will want to prevent jarring UX in the I think here we could apply two Perhaps there would be a different way how to refactor |
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.
I like this because it feels like a simple wrapper for the setTimeout
function built-to-purpose to be used in Vue for loading states (assuming I'm understanding everything as well as I think I am :-D)
I want to be sure I'm reading things right, so his the the gist of it, that beneath the registering w/ the keys and namespacing calls to show
, it really comes down to:
- Return true if
shouldShow
is true (no matter what) - Otherwise, return true until it's been longer than
minVisibleTime
- Then return false
Am I reading this right?
I'm having a hard time considering any use case for this outside of loaders because it kind of relies on a pattern of whoever is using this to be tracking a Boolean they pass in. I initially thought maybe we could use something like this for temporarily hiding/showing snackbars / errors but because those are more triggered than they are dependent on an ongoing process they work find as-is.
That said, are there any non-loader cases where we plan to use this? If this is pretty much specific to loading states it might be worth renaming it to live as part of the lib/loaders
namespace? Just a thought though.
@@ -95,7 +102,7 @@ | |||
/** | |||
* Whether the loader should be displayed or not. It needs to be used instead of `v-if/v-show` for `minVisibleTime` to work. | |||
*/ | |||
show: { | |||
shouldShow: { |
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.
Just noting that there is only once use of the show
prop in Kolibri in the LearningActivityBar
so when this merges we should target an issue in Kolibri for the next release that will use this change.
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.
Thank you. That's updated here learningequality/kolibri@44b92da#diff-acab644da93f15633de6bae4d5b1b3fe36ef427a8641ea305eb12e9aeb50b759R43. I agree it'd be good to regression test. Alternatively, we can revert this change if we renamed the new show
function to something else as mentioned in #448 (comment) and avoid this major API change.
<!-- eslint-enable --> | ||
</DocsPageSection> | ||
|
||
<DocsPageSection title="Example" anchor="#example"> |
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.
This example is excellent <3
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.
Thank you, playing around this was fun, glad that it feels useful
Almost, except of the first point. If If you have any idea how to make this clearer, I am glad to update documentation. |
I'm not aware of anything at this point. I don't see problem in applying it eventually to snackbars, but I'm not sure if I could understand exactly what you were saying in that regard so we'd need to chat more. So for now, the answer is no. The reason for putting this into
I an imagine that in this way, we wouldn't need to document usage for each composable separately with each having different location like we currently do:
But perhaps it'd better to document usage in that way anyways. An alternative approaches taking both these perspectives into account might be
In any case, if you can see more benefit of keeping composables directly in |
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.
This all looks great to me! One non-blocking thought -- perhaps it would be worth writing some unit tests for the useKShow
composable before release to outline some of the more complicated scenarios. Although... dealing with time can be difficult so maybe that'd be more work than it's worth?
Also - re: the location of the composable, I've thought a bit about it and I think that it probably makes more sense to have the composables
directory where we keep those kinds of utilities.
I think that when going to remember "where is the composable I need" it'll be so much nicer that I know it's in lib/composables
than if I had to consider "what context of KDS' directory structure would this live in?". Definitely open to follow-up discussion at a tactical or something but I think this is good to go.
Thank you for all of this I really look forward to using it in Kolibri
@nucleogenesis Heh, yes, I admit I was avoiding it in this case because of timing. There are ways to work with that in Jest though and it might not be that complicated. I will play around with at least some basic scenarios in a follow-up and we can see how it goes. Since this is something that is responsible for showing/hiding important data in tables, I agree it'd be good to have it tested. Thank you. |
@nucleogenesis Here are the tests #472. Also found quite an important bug thanks to it. Working with timing wasn't that bad. Waiting for your review. |
Description
KCircularLoader
to a newuseKShow
composable to allow for usage in v-if/v-else blocks and with any componentKCircularLoader
'sshow
prop toshouldShow
to prevent from naming conflictsuseKShow
thereuseKShow
vsKCircularLoader
'sminVisibleTime
KCircularLoader
's transition to prevent from glitches when using the loader in tandem with another component, both of them wrapped in a transitionKTransition
as a beginning of journey towards having a limited set of consistently used transitionsIssue addressed
This is all used in Kolibri's learningequality/kolibri#11201
Steps to test
Testing checklist
changelog
Reviewer guidance