bigshortbets / market-frontend

BigShortBet$ P2P Market is a cutting-edge peer-to-peer marketplace built on the principles of decentralization that allows direct P2P trading on unique & event-based markets. Enjoy ultra-low fees and no swaps. Powered by $BigSB.
https://app.bigsb.io
GNU General Public License v3.0
2 stars 5 forks source link

Define constants for toast durations #121

Open coderabbitai[bot] opened 1 month ago

coderabbitai[bot] commented 1 month ago

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.

kacpergumieniuk commented 1 month 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?

Klapeyron commented 1 month ago

@coderabbitai full review

coderabbitai[bot] commented 1 month ago

[!TIP] For best results, initiate chat on the files or code changes.

@Klapeyron, here's the full review:

Refactoring Toast Durations

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,
});

UX Best Practices for Toast Durations

Based on UX best practices, here are some general guidelines for using short and long toast durations:

Would you like to proceed with these changes, or should we handle this enhancement separately via a GitHub issue as per your previous preference?

Analysis chain
Scripts executed The following scripts were executed for the analysis: Script: ```shell #!/bin/bash # Find all occurrences of toast durations in the codebase to understand where and how they are used. rg 'toast' -A 5 ``` Length of output: 12537

Learnings added ``` Learnt from: Klapeyron URL: https://github.com/bigshortbets/market-frontend/issues/121 Timestamp: 2024-08-02T07:48:17.610Z Learning: When suggesting the use of constants for toast durations, the user prefers to push the current changes as they are and handle the enhancement separately via a GitHub issue. ``` > Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure [review instructions](https://docs.coderabbit.ai/guides/review-instructions). You can manage existing learnings in the [app](https://app.coderabbit.ai/learnings).

Learnings used ``` Learnt from: kacpergumieniuk PR: bigshortbets/market-frontend#120 File: components/Leaderboard/LeaderboardItem.tsx:29-40 Timestamp: 2024-07-16T07:03:25.610Z Learning: When suggesting the use of constants for toast durations, the user prefers to push the current changes as they are and handle the enhancement separately via a GitHub issue. ```