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

feat: toast #5063

Merged
merged 2 commits into from
Mar 13, 2024
Merged

feat: toast #5063

merged 2 commits into from
Mar 13, 2024

Conversation

fbwoolf
Copy link
Contributor

@fbwoolf fbwoolf commented Mar 12, 2024

Try out this version of Leather — Extension build, Test report

This PR implements a new Toast using a Radix primitive and a reference implementation from them to manage toast notifications: example codesandbox

I am proposing here we abandon react-hot-toast bc the library is outdated, ref their Github repo here. There are lots of outstanding issues and only one commit in 2024.

The Radix implementation, using React Context, allowed me to simply swap out our current implementation with a new context hook, toast = useToast(). As an example, our implementation is still, toast.success('Message'). The context also includes: info, error, and promise. The implementation here allows multiple toasts to occur, but we can customize that if we want. There is a lot we can do with this in the future.

The only place I wasn't able to use the hook was in the debug code, but I don't think it is necessary to show a toast there bc a user is already in the console. I switched that one to a logger message.

Stories included...
Screenshot 2024-03-12 at 12 05 27 PM

@fbwoolf fbwoolf linked an issue Mar 12, 2024 that may be closed by this pull request
Copy link
Contributor

@pete-watters pete-watters left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @fbwoolf . I tested this and its working well and cleaner than the previous implementation. I think it's a good idea to use as much styled primitives as we can to keep our library consistent

Copy link
Collaborator

@kyranjamie kyranjamie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice improvement.

Must admit I preferred the API of react-hot-toast, was nice being able to trigger it outside a react context. All good removing it though.

Appreciate the separation you've gone for putting the global provider level code in a feature, and only the dumb components in the ui folder.

src/app/features/toasts/toasts.tsx Outdated Show resolved Hide resolved
src/app/features/toasts/use-toast-handlers.ts Outdated Show resolved Hide resolved
src/app/features/toasts/use-toast.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@fabric-8 fabric-8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great @fbwoolf!

Not a blocker, but maybe s.th. we can look into later: I think the tick animation for the success toast was a nice touch, would be nice if we can bring it back.

@markmhendrickson
Copy link
Collaborator

@fabric-8 @mica000 I'm curious if we have (or should create) design guidance for whether to show the toast always at the top or bottom of the viewport? We seem to show in both places without consistently, though I suspect we should decide just one so the user can rely on it there.

@fabric-8
Copy link
Contributor

@markmhendrickson It's actually supposed to alway appear on top

@markmhendrickson
Copy link
Collaborator

Thanks, got it. @fbwoolf could we do a general audit of placement as part of this work stream or a new separate issue?

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Mar 13, 2024

Thanks, got it. @fbwoolf could we do a general audit of placement as part of this work stream or a new separate issue?

The changes here position it only at the top for all instances. It was refactored based on the design spec which only positioned the toast now at the top center.

@fbwoolf
Copy link
Contributor Author

fbwoolf commented Mar 13, 2024

Not a blocker, but maybe s.th. we can look into later: I think the tick animation for the success toast was a nice touch, would be nice if we can bring it back.

Do you mean with the old checkmark icon? This is the old one to ref: https://github.com/timolins/react-hot-toast/blob/main/src/components/checkmark.tsx

@fbwoolf fbwoolf force-pushed the feat/toast branch 2 times, most recently from 87a0275 to fc4e2be Compare March 13, 2024 15:33
@fbwoolf fbwoolf mentioned this pull request Mar 13, 2024
@fbwoolf fbwoolf added this pull request to the merge queue Mar 13, 2024
Merged via the queue into dev with commit ea4b71a Mar 13, 2024
28 checks passed
@fbwoolf fbwoolf deleted the feat/toast branch March 13, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Design System: Add toast
5 participants