-
Notifications
You must be signed in to change notification settings - Fork 0
Toast Refactor #61
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
Toast Refactor #61
Conversation
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.
Pull Request Overview
This PR refactors the toast notification system to consolidate multiple toast component types into a single BaseToast component with configurable styles and icons. The refactoring improves code maintainability by eliminating duplication and adds a new "copy" toast type alongside existing "error" and "success" types.
Key changes:
- Consolidated
ErrorToastandSuccessToastcomponents into a singleBaseToastcomponent - Added new CSS animation
slideOutfor improved exit transitions - Updated toast data model to include an
openstate property for better animation control - Renamed
CopyToastcomponent toCopyToastButtonfor clarity
Reviewed Changes
Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/styles/tailwind.css | Added slideOut animation and fixed syntax error in slideDownAndFade keyframe; updated swipeOut timing function |
| src/features/toast/type.ts | Created new file with ToastData type definition, moved from context file |
| src/features/toast/provider.tsx | Refactored to use BaseToast component with helper functions for icons and styles; updated toast removal logic to support exit animations |
| src/features/toast/context.ts | Moved ToastData type to separate type file |
| src/features/toast/components/success.tsx | Deleted file - functionality consolidated into BaseToast |
| src/features/toast/components/error.tsx | Deleted file - functionality consolidated into BaseToast |
| src/features/toast/base.tsx | Created new unified toast component with configurable styles, icons, and close button |
| src/components/copy-toast-button.tsx | Renamed from CopyToast to CopyToastButton; changed toast type to "copy" |
| src/app/(event)/[event-code]/painting/page-client.tsx | Updated import to use renamed CopyToastButton component |
| src/app/(event)/[event-code]/page-client.tsx | Updated import to use renamed CopyToastButton component |
| package.json | Updated @radix-ui/react-toast from ^1.2.14 to ^1.2.15 |
| package-lock.json | Updated dependency lockfile for @radix-ui/react-toast upgrade |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Miranda Zheng <[email protected]>
Co-Authored-By: Miranda Zheng <[email protected]>
Co-Authored-By: Miranda Zheng <[email protected]>
This pull request refactors the toast notification system to use a single, unified
BaseToastcomponent instead of separate components for each toast type. It also introduces a more flexible toast data structure, centralizes icon and style logic, and updates the copy-to-clipboard toast to use a new type. Some minor dependency and animation improvements are also included.Toast system refactor and improvements:
BaseToastcomponent that handles rendering and styling for all toast types, replacing the previousSuccessToastandErrorToastcomponents. This centralizes toast presentation logic and makes it easier to add new toast types. [1] [2] [3]ToastDatatype, now supporting anopenstate and a generictypefield. Toast icon and style are now determined by helper functions based on the toast type, allowing for easy extension. [1] [2] [3]openstate to false, then remove it after a short delay, enabling smoother exit animations.ToastDatatype from a dedicated type file for consistency.Copy-to-clipboard toast updates:
CopyToasttoCopyToastButtonand changed the toast type from"success"to"copy", which now uses a distinct icon and style. Updated all usages accordingly. [1] [2] src/app/(event)/[event-code]/page-client.tsxL8-R8, src/app/(event)/[event-code]/page-client.tsxL63-R63, src/app/(event)/[event-code]/painting/page-client.tsxL7-R7, src/app/(event)/[event-code]/painting/page-client.tsxL112-R112)Styling and animation improvements:
slideOutkeyframe and updating animation timing for a smoother user experience. [1] [2] [3]Dependency update:
@radix-ui/react-toastto version1.2.15.