Project-Chirp / chirp-frontend

Frontend of Chirp
2 stars 3 forks source link

T95, T124: Sharing posts, adding toasts #125

Closed Dennull closed 1 month ago

Dennull commented 1 month ago

Related Issues

Closes #95 and #124

Summary

Now when users click the share post button on either the post actions or the post menu, the post URL gets copied to their clipboard

Additionally, toasts were added to the app to give the user feedback on various actions such as copying links to their clipboard and deleting posts. Toasts can be queued by using the new enqueueToast action. If more than 1 toast is queued at a time, any previous toasts will be immediately dequeued until the latest toast is shown

Changes Made

For sharing posts, we simply used the navigator.clipboard.writeText() function

For toasts, a new slice in the redux store was added along with a global Toast component. This makes it so that we don't have to manually render toasts everywhere; a single toast component in the app is shown or hidden. To queue a toast, simply dispatch the enqueueToast action. There are also few other actions, which the global Toast component uses to manage the toast state and queue under the hood

Screenshots

image

image

Testing Instructions

No additional testing instructions

Special Notes for Your Reviewer(s)

No additional notes

christopherkinyua commented 1 month ago

Besides Nasih's comments, I can't think of anything else. I just need to understand the setToastOpen reducer in the ToastSlice file. This is some good work!