Skip to content

Conversation

kushagrasarathe
Copy link
Contributor

@kushagrasarathe kushagrasarathe commented May 30, 2025

  • contributes to TASK-11475

Copy link

vercel bot commented May 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
peanut-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 30, 2025 3:59pm

Copy link
Contributor

coderabbitai bot commented May 30, 2025

Walkthrough

This change refactors the color assignment logic for avatar components throughout the codebase. It introduces a new color mapping structure that provides both light and dark shades for each color, updates the getColorForUsername utility to return both shades, and adjusts all avatar-related components to use the new color scheme for backgrounds, borders, and text.

Changes

Files/Globs Change Summary
src/utils/color.utils.ts Refactored color mapping to provide light/dark shades; updated getColorForUsername signature and return type; changed avatar color constants.
src/components/Profile/AvatarWithBadge.tsx Updated avatar styling logic to use light/dark shades for background, border, and text; consolidated conditional logic.
src/components/AddWithdraw/components/AddWithdrawCountriesList.tsx Modified avatar background color logic to use lightShade; set text color to black.
src/components/Global/PeanutActionDetailsCard/index.tsx Refined avatar background/text color logic to use new color shades and conditions; imported AVATAR_TEXT_DARK.
src/components/TransactionDetails/TransactionAvatarBadge.tsx Changed avatar background and text color assignment to use lightShade and darkShade.
src/components/User/UserCard.tsx Adjusted avatar background/text color logic to use lightShade and darkShade; imported AVATAR_TEXT_DARK.
src/components/Payment/PaymentForm/index.tsx Simplified balance formatting logic; adjusted numeric conversions and validation using formatted values.

Suggested labels

enhancement

Suggested reviewers

  • Hugo0
  • jjramirezn
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai bot added the enhancement New feature or request label May 30, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🔭 Outside diff range comments (1)
src/components/Global/PeanutActionDetailsCard/index.tsx (1)

84-101: ⚠️ Potential issue

Fix color contrast issue - background and text using same color.

There's a critical accessibility and usability issue in the color logic. For the fallback case (lines 92 and 100), both backgroundColor and color use getColorForUsername(recipientName).darkShade, which would make the text invisible against the background.

Apply this diff to fix the contrast issue:

                        backgroundColor:
                            viewType === 'SUCCESS'
                                ? '#29CC6A'
                                : transactionType === 'ADD_MONEY' ||
                                    recipientType === 'ADDRESS' ||
                                    recipientType === 'ENS'
                                  ? '#FFC900'
-                                  : getColorForUsername(recipientName).darkShade,
+                                  : getColorForUsername(recipientName).lightShade,
                        color:
                            viewType === 'SUCCESS'
                                ? AVATAR_TEXT_DARK
                                : transactionType === 'ADD_MONEY' ||
                                    recipientType === 'ADDRESS' ||
                                    recipientType === 'ENS'
                                  ? AVATAR_TEXT_DARK
                                  : getColorForUsername(recipientName).darkShade,

This ensures proper contrast by using lightShade for background and darkShade for text color, consistent with other avatar components.

🧹 Nitpick comments (1)
src/components/AddWithdraw/components/AddWithdrawCountriesList.tsx (1)

64-65: Simplify redundant ternary and verify text contrast.

The ternary operator for color is redundant since both branches return 'black'. Also, using black text on all lightShade backgrounds might not provide adequate contrast for all color combinations.

Consider simplifying to:

 backgroundColor:
     method.icon === ('bank' as IconName)
         ? '#FFC900'
         : getColorForUsername(method.title).lightShade,
-color: method.icon === ('bank' as IconName) ? 'black' : 'black',
+color: 'black',

Alternatively, consider using getColorForUsername(method.title).darkShade for better contrast:

-color: method.icon === ('bank' as IconName) ? 'black' : 'black',
+color: method.icon === ('bank' as IconName) ? 'black' : getColorForUsername(method.title).darkShade,
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba77c23 and e7f6e12.

📒 Files selected for processing (7)
  • src/components/AddWithdraw/components/AddWithdrawCountriesList.tsx (1 hunks)
  • src/components/Global/PeanutActionDetailsCard/index.tsx (2 hunks)
  • src/components/Payment/PaymentForm/index.tsx (5 hunks)
  • src/components/Profile/AvatarWithBadge.tsx (1 hunks)
  • src/components/TransactionDetails/TransactionAvatarBadge.tsx (1 hunks)
  • src/components/User/UserCard.tsx (2 hunks)
  • src/utils/color.utils.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
src/components/AddWithdraw/components/AddWithdrawCountriesList.tsx (2)
src/utils/color.utils.ts (1)
  • getColorForUsername (51-69)
src/components/Global/Icons/Icon.tsx (1)
  • IconName (51-98)
src/components/Profile/AvatarWithBadge.tsx (1)
src/utils/color.utils.ts (1)
  • getColorForUsername (51-69)
src/components/User/UserCard.tsx (1)
src/utils/color.utils.ts (2)
  • getColorForUsername (51-69)
  • AVATAR_TEXT_DARK (44-44)
src/components/Global/PeanutActionDetailsCard/index.tsx (1)
src/utils/color.utils.ts (2)
  • getColorForUsername (51-69)
  • AVATAR_TEXT_DARK (44-44)
src/components/Payment/PaymentForm/index.tsx (2)
src/utils/general.utils.ts (1)
  • formatAmount (300-340)
src/constants/zerodev.consts.ts (1)
  • PEANUT_WALLET_TOKEN_DECIMALS (19-19)
🔇 Additional comments (11)
src/utils/color.utils.ts (3)

7-35: LGTM! Well-structured refactor to dual-shade color system.

The refactoring from single color strings to objects with lightShade and darkShade properties provides better flexibility for avatar styling across the application.


38-38: Verify the hardcoded AVATAR_LINK_BG color value.

The AVATAR_LINK_BG is now hardcoded to '#FF90E8' instead of referencing peanut_pink. This value doesn't match either peanut_pink.lightShade ('#FFD5F6') or peanut_pink.darkShade ('#FF74E2'). Please confirm this is intentional.


51-69: Excellent function refactor with proper type safety.

The function now returns both color shades which provides more styling flexibility. The updated JSDoc and consistent return structure are well-implemented.

src/components/Profile/AvatarWithBadge.tsx (1)

73-77: Excellent implementation of the new dual-shade color system.

The conditional styling logic properly utilizes both lightShade for backgrounds and darkShade for borders and text colors. The implementation maintains good visual hierarchy and contrast.

src/components/TransactionDetails/TransactionAvatarBadge.tsx (1)

83-84: Consistent implementation of new color scheme.

The changes properly utilize lightShade for background and darkShade for text color, maintaining consistency with the refactored color utility and other components.

src/components/User/UserCard.tsx (2)

2-2: Good addition of the new color constant.

The import of AVATAR_TEXT_DARK aligns with the avatar color refactoring.


53-60: Excellent implementation of the new color scheme.

The avatar styling correctly implements the new dual-shade color system:

  • Uses lightShade for background and darkShade for text color when dealing with usernames (ensures good contrast)
  • Applies fixed gold background with dark text for non-username recipients
  • Maintains consistent styling patterns across the codebase
src/components/Global/PeanutActionDetailsCard/index.tsx (1)

5-5: Good addition of the new color constant.

The import of AVATAR_TEXT_DARK aligns with the avatar color refactoring.

src/components/Payment/PaymentForm/index.tsx (3)

33-33: Good refactoring of balance formatting logic.

The removal of floorFixed and direct use of formatAmount simplifies the code while maintaining the same formatting behavior.

Also applies to: 86-88


182-183: Correct approach for parsing formatted balance.

The logic correctly handles the formatted balance string by removing commas and parsing to float for numeric comparison. This aligns well with the formatAmount usage.


224-224: Good dependency array update.

Using peanutWalletBalance instead of raw balance in the dependency array is correct since the effect logic depends on the formatted balance value.

Copy link

💻 Change PFPs colors

@jjramirezn jjramirezn merged commit a826c75 into peanut-wallet-dev Jun 2, 2025
5 checks passed
@jjramirezn jjramirezn deleted the feat/new-pfp-colors branch June 2, 2025 18:44
@coderabbitai coderabbitai bot mentioned this pull request Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants