Skip to content
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

Refactor and improve the Toast utility #198

Closed
endigo9740 opened this issue Sep 7, 2022 · 10 comments · Fixed by #510
Closed

Refactor and improve the Toast utility #198

endigo9740 opened this issue Sep 7, 2022 · 10 comments · Fixed by #510
Assignees
Labels
enhancement New feature or request ready to test Ready to be tested for quality assurance.
Milestone

Comments

@endigo9740
Copy link
Contributor

endigo9740 commented Sep 7, 2022

The store queue we have now fully supports this, we're just not taking advantage of it currently. The idea is toast messages would stack in some fashion, like so. Though I'm open to other suggestions!

NOTE: don't forget a11y when implementing this!

image

@endigo9740 endigo9740 added the enhancement New feature or request label Sep 7, 2022
@endigo9740 endigo9740 self-assigned this Sep 8, 2022
@salisshuaibu11
Copy link
Contributor

Why do you prefer it this way instead of stacking them on top of each other, though the UI is cool, in the end, the toast is still going to disappear after some time. But I think we can utilize the two by allowing the user to opt for the one he wants to use.

In the case of notifications, we can use the store queue just like the way this reminder is functioning, but for things like deleting, creating something e.t.c we can use normal toast. what do you think about it?

@endigo9740
Copy link
Contributor Author

I haven't settled on any particular UI or layout yet. I'll dive deeper into this once I get to this ticket, which should be later this week. Just wanted to show an example of what's possible.

in the end, the toast is still going to disappear after some time

The length of time they display can be adjusted, and there's setting to persist until dismissed. So it is possible for them to queue up. We need to handle that display when this occurs, or multiple come in at once.

@salisshuaibu11
Copy link
Contributor

@endigo9740
Copy link
Contributor Author

@salisshuaibu11 This is great! I like that a lot. It's more of what I had in mind for sure.

@endigo9740
Copy link
Contributor Author

I've made a bit of progress on this. It now allows for multiple to show vertically stacked, and also allows for custom background color per toast.

toast-queue

Still working on some timeout bugs and the 3D stacked effected. But will return to this later!

@salisshuaibu11
Copy link
Contributor

Nice work

@endigo9740 endigo9740 changed the title Provide better UI when multiple Toasts are queued Refactor and improve the Toast utility Sep 25, 2022
@endigo9740
Copy link
Contributor Author

Reference for myself: https://twitter.com/chriscoyier/status/1584564243814551552

@kimjunsung04
Copy link

Feature request: custom button text.

@endigo9740 endigo9740 pinned this issue Oct 31, 2022
@endigo9740 endigo9740 linked a pull request Nov 4, 2022 that will close this issue
@endigo9740
Copy link
Contributor Author

endigo9740 commented Nov 4, 2022

A draft PR has been started if anyone wishes to test this out:

This includes a number of improvements:

  • Allow for additional positions
  • Enter/leave animations are based on the position
  • Supports display of multiple toasts at once
  • However, there's a max number possible (configured via the max prop
  • Has more and better style adjustments

Still more to do, but here's some previews.

Screen Shot 2022-11-04 at 5 02 42 PM

toasts-all

toast-br

@endigo9740 endigo9740 added the ready to test Ready to be tested for quality assurance. label Nov 6, 2022
@endigo9740
Copy link
Contributor Author

I've also pushed a handful of updates to the Toasts PR:

  • Added support for HTML within message and action labels
  • I've rebuilt portions of the Toast store to better support autohide (this was broken with multiple shown)
  • Renamed the ToastSettings type and moved it to it's own types.ts file to follow convention
  • Updated all portions of the Doc where toasts are used, including updating index.ts
  • Added support for classes to customize one-off toast messages via the data object
  • I've wrote the Usage instructions, follow the simpler structure used for Dialogs
  • Updated the tests to get back in a working state

A couple notes of what's not present:

  1. We do not have a means to animate a particular toast on dismiss. out:transition works, but not as expected due to the fact that the queue isn't a normal array, but a store value that happens to be an array. Svelte is looking for an update to the individual array item, but when the store updates it replaces the ENTIRE array, which throws off the animation. I'd welcome suggestions to work around this.
  2. Ideally the toast should default to tertiary rather than accent color, but this doesn't work well due to the test color issues we're aware of with buttons, etc. When we introduce the on-{x} token styles for text color I'll look to change this.

@endigo9740 endigo9740 added this to the v1.0 milestone Nov 8, 2022
@endigo9740 endigo9740 unpinned this issue Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request ready to test Ready to be tested for quality assurance.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants