feat: Add KSnackbar component and useKSnackbar composable#1205
feat: Add KSnackbar component and useKSnackbar composable#1205Prashant-thakur77 wants to merge 36 commits intolearningequality:developfrom
Conversation
|
👋 Thanks for contributing! We will assign a reviewer within the next two weeks. In the meantime, please ensure that:
We'll be in touch! 😊 |
| queue.value = []; | ||
| } | ||
|
|
||
| function initVuexBridge(store) { |
There was a problem hiding this comment.
What was the reason for this logic?
Asking because I wouldn't expect Vuex-compatibility to be needed ~ the idea is to migrate both Studio and Kolibri to KSnackbar + useKSnackbar where useKSnacbkar is the place which will keep the state rather than relying on Vuex. During migration, we'll cleanup all obsolete Vuex code from Kolibri and Studio.
There was a problem hiding this comment.
Here's an example of a composable acting as global store
You may need to tweak to fit all features of this KDS implementation, but the main idea is same.
lib/KSnackbar/KSnackbar.vue
Outdated
| ref="snackbarElement" | ||
| class="k-snackbar" | ||
| :class="$computedClass(focusStyles)" | ||
| role="alert" |
There was a problem hiding this comment.
Can you please remove alert role and aria-live from everywhere here and instead use https://design-system.learningequality.org/usekliveregion?
You can see 'The Value Add' section of #668 to understand its benefit over having multiple live regions on a page.
There was a problem hiding this comment.
To explain, this role would create a live region too
Alerts are assertive live regions. Setting role="alert" is equivalent to setting aria-live="assertive" and aria-atomic="true".
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/alert_role
lib/KSnackbar/KSnackbar.vue
Outdated
| }, | ||
| }, | ||
|
|
||
| computed: { |
There was a problem hiding this comment.
Since most of the logic already is placed in setup, it may make more sense to also move computed + methods there.
And generally we're trying to move towards Composition API setup in all new features, even though I admit we're not always diligent in that regard, myself included :)
|
Hi @Prashant-thakur77, wonderful work as always & I enjoyed watching the recording. I left a few higher-level notes. We'll proceed as discussed here ~ let me know any time you're ready. Thanks a lot. |
|
@MisRob Sure, currently working on it and will also work on your review.;) |
- Move snackbars.vue to design guidelines only (like buttons.vue) - Create new ksnackbar.vue for component-specific documentation - Remove KSnackbar example and useKSnackbar logic from snackbars.vue - Add complete props, events, and usage examples to ksnackbar.vue - Update related section to link to both KSnackbar component and useKSnackbar composable
- Add KSnackbar to Code library components section - Add useKSnackbar to Composables section - Both sections use autoSort, so entries will be alphabetically sorted
eb4588a to
5e4d4db
Compare
|
@AlexVelezLl @MisRob I have created the visual tests and documentation and pushed it,the talk on slack related to specifications i have currently used the one given by kds (and took care for the colors --used the one mentioned in kds color section). I have also tried implementing the ksnackbar in studio and it is working as expected.I think the review can be started after the specifications are confirmed.do tell if any other changes are needed to be addressed. |
Description
Part Of learningequality/studio#5445
This PR implements the core KSnackbar component and the useKSnackbar composable. This is Part 1 of the migration strategy, focusing on logic, accessibility, and unit testing. (Visual tests and documentation will follow in a subsequent PR).
I have followed the design descriptions given in https://design-system.learningequality.org/snackbars/
Key Features
Before/after screenshots
This is the testing that i have done in Playground.
Screencast From 2026-02-14 23-41-29.webm
Changelog
(optional) Implementation notes
At a high level, how did you implement this?
Does this introduce any tech-debt items?
Testing checklist
Reviewer guidance
Comments