Open coderabbitai[bot] opened 4 months ago
Any ideas , for what kind of actions should be short toast be used, and for what long toast? Are there any good ux practices for this?
@coderabbitai full review
[!TIP] For best results, initiate chat on the files or code changes.
@Klapeyron, here's the full review:
To improve maintainability and consistency, I recommend defining constants for toast durations in a constants.ts
file and using these constants throughout the codebase. For example:
// constants.ts
export const TOAST_DURATION_SHORT = 1500;
export const TOAST_DURATION_LONG = 4000;
You can then replace the hardcoded durations in your code with these constants. For instance:
import { TOAST_DURATION_SHORT, TOAST_DURATION_LONG } from '@/constants';
// Example usage
toast.success('Address copied to clipboard', {
duration: TOAST_DURATION_SHORT,
});
toast.error('User rejected the transaction.', {
duration: TOAST_DURATION_LONG,
});
Based on UX best practices, here are some general guidelines for using short and long toast durations:
Short Toast (e.g., 1500ms): Use for simple, non-critical notifications that do not require user action. Examples include:
Long Toast (e.g., 4000ms): Use for more important messages that the user needs to read but do not require immediate action. Examples include:
Would you like to proceed with these changes, or should we handle this enhancement separately via a GitHub issue as per your previous preference?
It's suggested to define constants for toast durations in the constants.ts file, for example, short toast: 1500ms and long toast: 3000ms, and use these constants across the app. This will help maintain consistency and ease of maintenance.