Skip to content
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

Feat/swap UI feat #6488

Merged
merged 6 commits into from
Jan 13, 2025
Merged

Feat/swap UI feat #6488

merged 6 commits into from
Jan 13, 2025

Conversation

Kahnchan
Copy link
Contributor

@Kahnchan Kahnchan commented Jan 10, 2025

image image

Summary by CodeRabbit

  • UI Improvements

    • Updated styling for swap-related components
    • Refined visual elements in swap input and header sections
    • Adjusted component spacing, colors, and layout
    • Enhanced button and badge visual properties
    • Refined image and input container styles
  • Visual Updates

    • Modified background colors for selected tabs
    • Adjusted component padding and spacing
    • Updated icon button interactions and sizing

These changes focus on improving the visual consistency and user experience of the swap interface without altering core functionality.

Copy link

codesandbox bot commented Jan 10, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link
Contributor

coderabbitai bot commented Jan 10, 2025

Walkthrough

The pull request introduces visual and styling modifications across several components in the Swap module. The changes primarily focus on adjusting layout, spacing, colors, and component properties without altering core functionality. Modifications include updates to badge text styling, image sizes, tab item backgrounds, input container designs, and quote input layout.

Changes

File Change Summary
packages/kit/src/views/Swap/components/SwapPercentageStageBadge.tsx Added size and color attributes to Badge.Text
packages/kit/src/views/Swap/pages/components/SwapAccountAddressContainer.tsx Reduced Image component size from 18x18 to 16x16, removed bottom padding
packages/kit/src/views/Swap/pages/components/SwapHeaderContainer.tsx Changed selected tab background from $bgActive to $bgSubdued
packages/kit/src/views/Swap/pages/components/SwapInputActions.tsx Reduced gap between elements, removed alignment and padding properties
packages/kit/src/views/Swap/pages/components/SwapInputContainer.tsx Added border radius, background color, and padding to YStack and XStack components
packages/kit/src/views/Swap/pages/components/SwapQuoteInput.tsx Replaced YStack with Stack, updated IconButton styling and layout

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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 or 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.

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: 3

🔭 Outside diff range comments (2)
packages/kit/src/views/Swap/pages/components/SwapQuoteInput.tsx (1)

Line range hint 60-93: Extract complex balance calculation logic

Move the maxAmount calculation logic into a separate utility function. This will improve readability and make the code easier to test.

+ const calculateMaxAmount = (balance: string, reservationValue?: string) => {
+   if (!reservationValue) return balance;
+   const balanceBN = new BigNumber(balance ?? 0);
+   const reservationBN = new BigNumber(reservationValue);
+   return balanceBN.minus(reservationBN).isGreaterThan(0)
+     ? balanceBN.minus(reservationBN).toFixed()
+     : '0';
+ };

  onBalanceMaxPress={() => {
-   let maxAmount = fromTokenBalance;
-   if (fromToken?.reservationValue) {
-     const fromTokenBalanceBN = new BigNumber(fromTokenBalance ?? 0);
-     const fromTokenReservationValueBN = new BigNumber(
-       fromToken.reservationValue,
-     );
-     if (
-       fromTokenBalanceBN
-         .minus(fromTokenReservationValueBN)
-         .isGreaterThan(0)
-     ) {
-       maxAmount = fromTokenBalanceBN
-         .minus(fromTokenReservationValueBN)
-         .toFixed();
-     }
-   }
+   const maxAmount = calculateMaxAmount(fromTokenBalance, fromToken?.reservationValue);
    setFromInputAmount(maxAmount);
  }}
packages/kit/src/views/Swap/pages/components/SwapInputContainer.tsx (1)

Add missing accessibility attributes to input elements

The component needs these accessibility improvements:

  • Add aria-label to identify the amount input field
  • Include aria-invalid and aria-errormessage for error states
  • Make balance and price information available to screen readers
  • Add role="spinbutton" with aria-valuemin/max for numeric input

Example locations:

  • packages/kit/src/components/AmountInput/index.tsx
  • packages/components/src/forms/Input/Input.android.tsx
  • packages/components/src/forms/Input/index.tsx
🔗 Analysis chain

Line range hint 1-228: Verify accessibility for input elements.

The component handles complex input interactions. Ensure it meets accessibility standards:

  1. Color contrast for error states
  2. Screen reader support for balance and price information
  3. Clear focus indicators
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for accessibility-related props in the codebase
rg -i "aria-|role=|accessib" packages/kit/src/views/Swap/

Length of output: 602


Script:

#!/bin/bash
# Check AmountInput implementation and accessibility features
ast-grep --pattern 'export const AmountInput = $$$'

# Search for accessibility-related props in components
rg -i "aria-|role=|accessib" packages/kit/src/components/AmountInput/
rg -i "aria-|role=|accessib" packages/components/src/

Length of output: 66051


Script:

#!/bin/bash
# Check AmountInput implementation for accessibility features
ast-grep --pattern 'export const AmountInput = $$$'

# Search for accessibility attributes in AmountInput
rg -i "aria-|role=|accessib" packages/kit/src/components/AmountInput/

# Check base components for built-in accessibility
rg -i "aria-|role=|accessib" packages/components/src/primitives/Stack/

Length of output: 198


Script:

#!/bin/bash
# Search for input-related accessibility attributes in AmountInput
rg -A 5 -B 5 "input|Input" packages/kit/src/components/AmountInput/

# Search for ARIA attributes and roles in the component
rg -i "aria-|role=|label|description|errormessage" packages/kit/src/components/AmountInput/

# Check for error state handling
rg -A 5 "hasError|error|invalid" packages/kit/src/components/AmountInput/

Length of output: 9323


Script:

#!/bin/bash
# Check base Input component implementation
rg -A 10 "export (const|function) Input" packages/components/src/forms/Input/
rg -i "aria-|role=|label|description" packages/components/src/forms/Input/

Length of output: 4035

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 713b283 and 4f8119d.

📒 Files selected for processing (6)
  • packages/kit/src/views/Swap/components/SwapPercentageStageBadge.tsx (1 hunks)
  • packages/kit/src/views/Swap/pages/components/SwapAccountAddressContainer.tsx (2 hunks)
  • packages/kit/src/views/Swap/pages/components/SwapHeaderContainer.tsx (1 hunks)
  • packages/kit/src/views/Swap/pages/components/SwapInputActions.tsx (1 hunks)
  • packages/kit/src/views/Swap/pages/components/SwapInputContainer.tsx (2 hunks)
  • packages/kit/src/views/Swap/pages/components/SwapQuoteInput.tsx (3 hunks)
🔇 Additional comments (7)
packages/kit/src/views/Swap/components/SwapPercentageStageBadge.tsx (1)

35-37: Nice styling improvements!

The new text properties enhance readability and maintain visual hierarchy.

packages/kit/src/views/Swap/pages/components/SwapInputActions.tsx (1)

52-52: Tighter spacing improves visual density

The reduced gap creates a more compact layout without compromising readability.

packages/kit/src/views/Swap/pages/components/SwapAccountAddressContainer.tsx (2)

68-68: Better image proportions

The smaller 16x16 image size creates better visual balance with the text.


86-86: Clean layout structure

The simplified XStack props maintain proper alignment while removing unnecessary padding.

packages/kit/src/views/Swap/pages/components/SwapHeaderContainer.tsx (1)

47-47: Improved selected state visibility

The subdued background creates better contrast for the selected tab while maintaining the interactive states.

packages/kit/src/views/Swap/pages/components/SwapInputContainer.tsx (2)

159-159: LGTM! Clean styling update.

The YStack styling changes improve visual consistency with a subtle background and rounded corners.


160-160: LGTM! Good spacing adjustment.

The padding changes create better visual balance between elements.

@sidmorizon sidmorizon enabled auto-merge (squash) January 13, 2025 03:32
@sidmorizon sidmorizon merged commit 3dd32bb into OneKeyHQ:x Jan 13, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants