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: Limit orders responsive designs #3718

Merged
merged 5 commits into from
Aug 9, 2024

Conversation

crnbarr93
Copy link
Contributor

What is the purpose of the change:

These changes are to improve the responsive design of the new trade modal and all of its relevant elements. The following components were made responsive:

  • New trade tool (including inputs)
  • Review order modal
  • Denom selection modal
  • Trade details

@crnbarr93 crnbarr93 requested a review from DavideSegullo August 9, 2024 16:17
Copy link

vercel bot commented Aug 9, 2024

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

Name Status Preview Comments Updated (UTC)
osmosis-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 9, 2024 4:30pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 4:30pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 4:30pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Aug 9, 2024 4:30pm
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Aug 9, 2024 4:30pm

@crnbarr93 crnbarr93 changed the title Connor/limit responsive changes feat: Limit orders responsive designs Aug 9, 2024
Copy link
Contributor

coderabbitai bot commented Aug 9, 2024

Walkthrough

The recent updates across various components focus on enhancing the responsiveness, visual consistency, and usability of the application. Key modifications include the integration of responsive design principles through new styling classes, improved rendering logic, and the introduction of feature flags. These changes aim to provide a better user experience, particularly on mobile devices, while maintaining the core functionality of the components.

Changes

File Path Change Summary
packages/web/components/complex/asset-fieldset.tsx Updated rendering logic, styling adjustments for responsiveness, refined font size calculation, and conditional rendering based on device type.
packages/web/components/place-limit-tool/*.tsx Modified rendering logic, improved asset amount display, and updated styling for consistency across different states.
packages/web/components/swap-tool/*.tsx Enhanced responsiveness and layout adjustments, with updates to class names for better visual presentation.
packages/web/components/transactions/*.tsx Adjusted HTML structure and styling to improve accessibility and visual consistency.
packages/web/modals/*.tsx Integrated feature flags to dynamically adjust styles based on feature availability and improved responsiveness.
packages/web/pages/index.tsx Adjusted layout and margin properties for better responsiveness.
packages/web/tailwind.config.js Modified color definitions to enhance the design palette with semi-transparent colors.
packages/web/utils/formatter.ts Refined font size calculation logic based on character count for improved readability, particularly on mobile.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ComponentA
    participant ComponentB

    User->>ComponentA: Interacts with UI
    ComponentA->>ComponentB: Sends data/request
    ComponentB->>ComponentA: Returns response
    ComponentA->>User: Updates UI
Loading

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 64943c6 and c221fc1.

Files ignored due to path filters (17)
  • packages/web/localizations/de.json is excluded by !**/*.json
  • packages/web/localizations/en.json is excluded by !**/*.json
  • packages/web/localizations/es.json is excluded by !**/*.json
  • packages/web/localizations/fa.json is excluded by !**/*.json
  • packages/web/localizations/fr.json is excluded by !**/*.json
  • packages/web/localizations/gu.json is excluded by !**/*.json
  • packages/web/localizations/hi.json is excluded by !**/*.json
  • packages/web/localizations/ja.json is excluded by !**/*.json
  • packages/web/localizations/ko.json is excluded by !**/*.json
  • packages/web/localizations/pl.json is excluded by !**/*.json
  • packages/web/localizations/pt-br.json is excluded by !**/*.json
  • packages/web/localizations/ro.json is excluded by !**/*.json
  • packages/web/localizations/ru.json is excluded by !**/*.json
  • packages/web/localizations/tr.json is excluded by !**/*.json
  • packages/web/localizations/zh-cn.json is excluded by !**/*.json
  • packages/web/localizations/zh-hk.json is excluded by !**/*.json
  • packages/web/localizations/zh-tw.json is excluded by !**/*.json
Files selected for processing (18)
  • packages/web/components/complex/asset-fieldset.tsx (7 hunks)
  • packages/web/components/place-limit-tool/index.tsx (7 hunks)
  • packages/web/components/place-limit-tool/limit-price-selector.tsx (6 hunks)
  • packages/web/components/swap-tool/alt.tsx (3 hunks)
  • packages/web/components/swap-tool/order-type-selector.tsx (2 hunks)
  • packages/web/components/swap-tool/price-selector.tsx (2 hunks)
  • packages/web/components/swap-tool/swap-tool-tabs.tsx (1 hunks)
  • packages/web/components/swap-tool/trade-details.tsx (6 hunks)
  • packages/web/components/trade-tool/index.tsx (1 hunks)
  • packages/web/components/transactions/transaction-content.tsx (1 hunks)
  • packages/web/components/transactions/transaction-details/transaction-details-content.tsx (2 hunks)
  • packages/web/components/ui/recap-row.tsx (1 hunks)
  • packages/web/modals/base.tsx (3 hunks)
  • packages/web/modals/review-order.tsx (19 hunks)
  • packages/web/modals/token-select-modal-limit.tsx (4 hunks)
  • packages/web/pages/index.tsx (1 hunks)
  • packages/web/tailwind.config.js (1 hunks)
  • packages/web/utils/formatter.ts (1 hunks)
Files skipped from review due to trivial changes (1)
  • packages/web/components/place-limit-tool/limit-price-selector.tsx
Additional context used
Biome
packages/web/components/complex/asset-fieldset.tsx

[error] 125-125: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

packages/web/modals/review-order.tsx

[error] 196-196: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

Additional comments not posted (37)
packages/web/components/ui/recap-row.tsx (2)

16-16: Enhance responsiveness with updated CSS classes.

The updated CSS classes improve the component's adaptability to different screen sizes by replacing a fixed height with a minimum height and adding responsive text styling.


20-20: Improve text readability on smaller screens.

The change to the span class enhances text readability on smaller screens by applying a responsive caption style.

packages/web/components/swap-tool/swap-tool-tabs.tsx (2)

49-49: Improve visual spacing with gap-px.

The addition of gap-px between tab buttons enhances the visual spacing and layout, improving the overall aesthetics.


56-62: Enhance button responsiveness and styling.

The updated button classes improve responsiveness by adjusting padding and adding responsive text styling, contributing to a more adaptable layout.

packages/web/modals/base.tsx (3)

9-9: Integrate feature flags for dynamic styling.

The addition of useFeatureFlags enables conditional styling based on feature flags, enhancing the component's flexibility.


43-43: Retrieve feature flags for conditional rendering.

The featureFlags constant is used to conditionally apply styles, allowing for dynamic changes based on the application's state.


62-67: Apply conditional styling based on feature flags.

The conditional application of background classes based on the limitOrders feature flag allows for dynamic styling, improving the component's adaptability.

packages/web/components/swap-tool/order-type-selector.tsx (2)

90-90: Improved visual separation with gap-px.

The addition of the gap-px class enhances the spacing between elements, improving the visual layout for better responsiveness.


104-104: Responsive design improvements for buttons.

The updated class names sm:body2, sm:px-3, and sm:py-1.5 enhance the button's appearance on smaller screens, contributing to a more responsive design.

packages/web/pages/index.tsx (1)

48-49: Enhanced responsiveness with updated positioning and margin.

The changes to the top property (md:top-0) and margin-top (md:mt-5) improve the layout's adaptability to different screen sizes.

packages/web/components/trade-tool/index.tsx (1)

67-68: Improved responsiveness with updated padding and gap.

The addition of sm:px-4 sm:pt-4 sm:pb-2 for the outer div and md:gap-2 for the inner div enhances the component's adaptability to different screen sizes.

packages/web/components/transactions/transaction-content.tsx (1)

94-100: Consider the semantic implications of replacing <h5> with <span>.

Replacing a heading element with a span might affect accessibility, as headings provide important structural information for screen readers. Ensure that the new styling ("sm:subtitle1 sm:subtitle1 text-h5 font-h5") maintains the intended visual hierarchy and consider using ARIA roles if semantic meaning is important.

packages/web/components/complex/asset-fieldset.tsx (4)

81-96: Styling changes enhance responsiveness and usability.

The updated class names for the button and text span improve the component's adaptability to different screen sizes, enhancing usability and appearance.


119-125: Responsive logic effectively adapts font size.

The use of useWindowSize with Breakpoint.sm and conditional font size setting enhances readability on different devices.

Tools
Biome

[error] 125-125: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)


147-147: Styling changes improve layout consistency.

The updated styling for the footer aligns with the design goals, enhancing layout consistency and visual hierarchy.


Line range hint 182-239:
Responsive logic enhances visual hierarchy and usability.

The conditional rendering based on isMobile for image size and button styling improves the component's responsiveness and usability.

packages/web/components/transactions/transaction-details/transaction-details-content.tsx (1)

84-93: Feature flag implementation enhances user experience.

The use of the limitOrders feature flag to conditionally change the background color provides visual feedback, improving the user interface.

packages/web/tailwind.config.js (2)

63-63: Addition of new color shade 700.

The addition of 700: "rgba(107, 98, 173, 0.47)" in the osmoverse-alpha color palette provides a semi-transparent color option, which can be useful for overlay effects or subtle UI elements. Ensure this new color is used consistently across the application.


65-65: Modification of color shade 850.

The change from 850: "#3C356D4A" to 850: "rgba(60, 53, 109, 0.29)" updates the color to a more transparent RGBA format. This could affect the appearance of components using this color. Verify that the visual changes align with the design requirements.

packages/web/utils/formatter.ts (2)

382-384: Update mobile font size mappings.

The updated mappings for mobile contexts (7: "30px", 12: "18px", 16: "16px") provide a more constrained selection, which may improve readability on smaller screens. Ensure these changes are tested on various devices to confirm the intended effect.


398-398: Change default return value for font size.

The default return value has been changed from "48px" to "16px". This is a significant change that could affect text rendering where no specific size mapping is found. Verify that this change does not negatively impact the UI.

packages/web/components/swap-tool/price-selector.tsx (3)

192-193: Integration of useWindowSize hook.

The addition of the useWindowSize hook to determine if the view is mobile is a good approach for responsive design. Ensure this logic is consistent across similar components for uniformity.


200-203: Responsive layout adjustments.

The updated class names and layout adjustments enhance responsiveness. Ensure these changes are consistent with the overall design system and test on various screen sizes to confirm the intended user experience.


210-218: Conditional rendering of asset logos.

The conditional rendering of asset logos based on the isMobile state ensures appropriate sizing for different devices. This change should be tested on various screen sizes to verify the correct display of logos.

Verification successful

Conditional rendering logic verified; manual testing recommended.

The isMobile variable is correctly used in price-selector.tsx to conditionally render asset logos based on screen size. However, please ensure to manually test the display of logos on various screen sizes to verify the visual correctness.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the rendering of asset logos for different screen sizes.

# Test: Check the usage of `isMobile` in the component to ensure correct conditional rendering.
rg --type tsx "isMobile"

Length of output: 52


Script:

#!/bin/bash
# Description: Verify the rendering of asset logos for different screen sizes.

# Test: Check the usage of `isMobile` in .tsx files to ensure correct conditional rendering.
rg "isMobile" --glob "*.tsx" -A 5

Length of output: 87438

packages/web/modals/token-select-modal-limit.tsx (3)

205-205: Enhance responsiveness with class names.

The addition of responsive class names to the modal's container improves adaptability across different screen sizes. This aligns with the PR's objective to enhance responsiveness. Ensure that these changes are consistent with other components for a unified user experience.


336-336: Ensure text visibility with class names.

The use of truncate and gap classes helps manage overflow and spacing, improving text visibility. This is a good practice for maintaining visual clarity in responsive designs.


367-383: Use of formatFiatPrice for clarity.

The introduction of formatFiatPrice ensures that fiat prices are displayed consistently and clearly. This change enhances the readability of financial data.

packages/web/components/swap-tool/trade-details.tsx (4)

90-90: Improve layout flexibility with min-h.

Changing the height to a minimum height (min-h) enhances layout flexibility, allowing the component to adapt better to different content sizes. This is a good practice for responsive design.


104-109: Conditional styling for loading states.

Using animate-pulse for loading states provides a visual cue to users, enhancing the user experience by indicating that data is being loaded.


181-181: Conditional tilde for price impact.

The conditional display of a tilde ("~") for non-zero price impacts improves clarity for users, indicating an approximation. This is a thoughtful addition for user experience.


Line range hint 280-303: Responsive text handling in Disclosure.Button.

The use of responsive classes ensures that text is appropriately sized across different devices, enhancing readability and consistency.

packages/web/components/place-limit-tool/index.tsx (3)

42-42: Consistent fiat price formatting with formatFiatPrice.

Replacing formatPretty with formatFiatPrice for fiat values ensures consistency and clarity in price displays, aligning with the goal of improving user interface clarity.


Line range hint 418-431: Responsive text adjustments for order direction.

The conditional display of "toBuy" and "toSell" within a hidden span on small screens is a smart adjustment for responsive design, ensuring that important information is not lost on smaller devices.


440-440: Ensure balance display consistency.

Using formatFiatPrice for displaying the available balance ensures that all fiat values are formatted consistently, enhancing the overall user experience.

packages/web/components/swap-tool/alt.tsx (1)

Line range hint 434-468:
Semantic and logic change approved.

The change from <h3> to <span> is a semantic adjustment that might affect styling. Ensure that this change does not negatively impact the styling or accessibility of the component. The updated logic for calculating the length of the formatted output value is appropriate for numeric values.

Verification successful

No specific styling impacts found for <h3> to <span> change.

The change from <h3> to <span> in the AltSwapTool component does not appear to affect styling through CSS or framework-specific styles. It is likely that styling is handled through utility classes or inline styles within the component. Ensure that any utility classes or inline styles are correctly applied to maintain the intended appearance.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the impact of changing <h3> to <span> on styling and functionality.

# Test: Search for the usage of the AltSwapTool component and ensure it is styled correctly.
rg --type tsx -A 5 'AltSwapTool'

Length of output: 60


Script:

#!/bin/bash
# Description: Locate .tsx files and search for the usage of the AltSwapTool component.

# Find all .tsx files and search for AltSwapTool within them
fd --extension tsx --exec rg 'AltSwapTool' {}

Length of output: 286


Script:

#!/bin/bash
# Description: Search for CSS or styling rules related to <h3> and <span> in the AltSwapTool component and its usage.

# Search for styling rules in the component file
rg --type tsx -A 10 '<h3>|<span>' packages/web/components/swap-tool/alt.tsx

# Search for styling rules in related CSS or styled-components files
fd --extension css --exec rg '<h3>|<span>' {}
fd --extension tsx --exec rg 'styled' {}

Length of output: 966


Script:

#!/bin/bash
# Description: Search for global CSS rules or framework-specific styles affecting <h3> and <span>.

# Search for global CSS rules in any CSS files
fd --extension css --exec rg '<h3>|<span>' {}

# Search for framework-specific styles in any JavaScript or TypeScript files
fd --extension js --exec rg '<h3>|<span>' {}
fd --extension ts --exec rg '<h3>|<span>' {}

Length of output: 389

packages/web/modals/review-order.tsx (2)

Line range hint 178-199:
Responsive design classes in GasEstimation approved.

The inclusion of responsive design classes in the GasEstimation component enhances its adaptability to different screen sizes. Ensure that these changes do not affect the component's functionality.

Verification successful

Responsive design changes to GasEstimation are localized.

The GasEstimation component is defined and used within packages/web/modals/review-order.tsx, with no external dependencies or usages identified. The responsive design changes are self-contained and should not affect other parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the functionality of `GasEstimation` with responsive design classes.

# Test: Search for the usage of the GasEstimation component and ensure it functions correctly across different screen sizes.
rg --type tsx -A 5 'GasEstimation'

Length of output: 62


Script:

#!/bin/bash
# Description: Verify the functionality of `GasEstimation` with responsive design classes.

# Test: Search for the usage of the GasEstimation component in .tsx files.
rg 'GasEstimation' --glob '**/*.tsx' -A 5

Length of output: 847

Tools
Biome

[error] 196-196: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)


23-27: Responsive design enhancement approved.

The use of the useWindowSize hook to adjust UI elements based on screen size is a positive change for responsiveness. Ensure that this change does not introduce any regression in UI behavior across different devices.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

style={{
fontSize,
fontSize: !!inputValue ? fontSize : undefined,
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove redundant double-negation.

The double-negation in the font size condition is unnecessary and can be removed for cleaner code.

-        fontSize: !!inputValue ? fontSize : undefined,
+        fontSize: inputValue ? fontSize : undefined,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
fontSize: !!inputValue ? fontSize : undefined,
fontSize: inputValue ? fontSize : undefined,
Tools
Biome

[error] 125-125: Avoid redundant double-negation.

It is not necessary to use double-negation when a value will already be coerced to a boolean.
Unsafe fix: Remove redundant double-negation

(lint/complexity/noExtraBooleanCast)

@@ -186,22 +188,22 @@ export function ReviewOrder({
) : (
<span
className={classNames(
"inline-flex items-center gap-1 text-osmoverse-100",
"sm:caption inline-flex items-center gap-1 text-osmoverse-100",
{ "animate-pulse": isGasLoading }
)}
>
<Icon id="gas" width={16} height={16} />
{gasAmount && gasAmount.toString()}
Copy link
Contributor

Choose a reason for hiding this comment

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

Use optional chaining for safety.

Consider using optional chaining to avoid potential runtime errors when accessing properties that might be undefined.

- {gasAmount && gasAmount.toString()}
+ {gasAmount?.toString()}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{gasAmount && gasAmount.toString()}
{gasAmount?.toString()}
Tools
Biome

[error] 196-196: Change to an optional chain.

Unsafe fix: Change to an optional chain.

(lint/complexity/useOptionalChain)

@crnbarr93 crnbarr93 merged commit 7dd6395 into stage Aug 9, 2024
29 of 31 checks passed
@crnbarr93 crnbarr93 deleted the connor/limit-responsive-changes branch August 9, 2024 16:45
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.

2 participants