Skip to content

UI minor fixes on new tokens tile#294

Merged
RanaBug merged 1 commit intostagingfrom
feat/PRO-3225/new-token-tiles
May 1, 2025
Merged

UI minor fixes on new tokens tile#294
RanaBug merged 1 commit intostagingfrom
feat/PRO-3225/new-token-tiles

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented May 1, 2025

Description

  • Alignment of tokens number
  • Truncate Token symbol when token name has truncated enough
  • Remove tile background in tablet and mobile

How Has This Been Tested?

  • Unit tests and manual testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Summary by CodeRabbit

  • Style
    • Improved text truncation and overflow handling for token market data rows, ensuring better readability when space is limited.
    • Adjusted number display widths for consistency across desktop, tablet, and mobile devices.
    • Updated background styling for market data tiles to use transparent backgrounds on mobile and tablet screens for a cleaner look.

@RanaBug RanaBug requested a review from IAmKio May 1, 2025 10:24
@RanaBug RanaBug self-assigned this May 1, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented May 1, 2025

Walkthrough

This update introduces responsive and conditional styling adjustments across several UI components related to token market data display. The LeftColumnTokenMarketDataRow component now measures the width of a text element and applies truncation styles when its width is below a threshold. The TokenMarketDataRow component receives explicit width classes for the number display to ensure consistent layout across breakpoints. The TokensWithMarketDataTile component updates its background styling to be transparent on mobile and tablet devices, replacing a fixed background color.

Changes

File(s) Change Summary
src/apps/pillarx-app/components/TokenMarketDataRow/LeftColumnTokenMarketDataRow.tsx Added dynamic width measurement for a text element, conditional truncation styling, and refactoring of overflow handling.
src/apps/pillarx-app/components/TokenMarketDataRow/TokenMarketDataRow.tsx Applied fixed width classes to the number display for consistent sizing across device breakpoints.
src/apps/pillarx-app/components/TokensWithMarketDataTile/TokensWithMarketDataTile.tsx Changed the background color to be transparent on mobile and tablet, replacing the fixed dark background.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant LeftColumnTokenMarketDataRow

    User->>LeftColumnTokenMarketDataRow: Render component
    LeftColumnTokenMarketDataRow->>LeftColumnTokenMarketDataRow: Measure width of text2 div
    alt width < 50px
        LeftColumnTokenMarketDataRow->>LeftColumnTokenMarketDataRow: Apply truncation & overflow styles to text1
    else width >= 50px
        LeftColumnTokenMarketDataRow->>LeftColumnTokenMarketDataRow: Render text1 normally
    end
    User->>LeftColumnTokenMarketDataRow: Resize window
    LeftColumnTokenMarketDataRow->>LeftColumnTokenMarketDataRow: Re-measure width and update styles if needed
Loading

Possibly related PRs

  • pillarwallet/x#290: Introduces the initial creation of the LeftColumnTokenMarketDataRow component, which is directly modified in this PR.
  • pillarwallet/x#292: Modifies conditional rendering and truncation in LeftColumnTokenMarketDataRow, overlapping with this PR's focus on text overflow handling.
  • pillarwallet/x#293: Adds copy-to-clipboard feedback and styling adjustments to LeftColumnTokenMarketDataRow, sharing a focus on UI improvements.

Suggested reviewers

  • IAmKio

Poem

In the meadow of code, the UI grows bright,
With widths measured swiftly, and styles set right.
Tokens now shimmer on backgrounds so clear,
While numbers align, both far and near.
A hop and a skip, the rabbit delights—
Overflow tamed, through long days and nights!
🐇✨

✨ 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.
    • 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.

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.

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

🧹 Nitpick comments (1)
src/apps/pillarx-app/components/TokenMarketDataRow/LeftColumnTokenMarketDataRow.tsx (1)

57-70: Width measurement logic looks good, consider minor improvements.

The implementation correctly measures the width of the token symbol container and handles window resizing.

Consider these minor improvements:

  1. Extract the magic number 50 to a named constant for better readability
  2. Add a debounce to the resize event listener for better performance
+ // Threshold width in pixels below which we truncate the token symbol
+ const TOKEN_SYMBOL_TRUNCATION_THRESHOLD = 50;

  useEffect(() => {
+   const debouncedUpdateWidth = debounce(() => {
      if (divRef.current) {
-       setWidth(divRef.current.getBoundingClientRect().width);
+       setWidth(divRef.current.getBoundingClientRect().width);
      }
-   };
+   }, 100);

-   window.addEventListener('resize', updateWidth);
+   window.addEventListener('resize', debouncedUpdateWidth);
    updateWidth();

    return () => {
-     window.removeEventListener('resize', updateWidth);
+     window.removeEventListener('resize', debouncedUpdateWidth);
    };
  }, []);

You'll need to add the debounce utility function or use a library like lodash.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 47e6dfb and f3ad3a9.

⛔ Files ignored due to path filters (4)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/PointsTile/test/__snapshots__/PointsTile.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokenMarketDataRow/tests/__snapshots__/LeftColumnTokenMarketDataRow.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensWithMarketDataTile/test/__snapshots__/TokensWithMarketDataTile.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (3)
  • src/apps/pillarx-app/components/TokenMarketDataRow/LeftColumnTokenMarketDataRow.tsx (3 hunks)
  • src/apps/pillarx-app/components/TokenMarketDataRow/TokenMarketDataRow.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensWithMarketDataTile/TokensWithMarketDataTile.tsx (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: lint
  • GitHub Check: unit-tests
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (6)
src/apps/pillarx-app/components/TokenMarketDataRow/TokenMarketDataRow.tsx (1)

34-34: LGTM: Consistent number width across breakpoints.

Adding explicit width classes ensures the list numbers maintain consistent alignment across desktop, tablet, and mobile views, which improves the UI consistency.

src/apps/pillarx-app/components/TokensWithMarketDataTile/TokensWithMarketDataTile.tsx (1)

33-33: LGTM: Transparent background for mobile and tablet views.

Making the background transparent on mobile and tablet devices as requested in the PR objectives. This matches the UI design requirements for responsive views.

src/apps/pillarx-app/components/TokenMarketDataRow/LeftColumnTokenMarketDataRow.tsx (4)

4-4: LGTM: Added required React hooks.

The import now includes the necessary hooks for the width measurement implementation.


30-31: LGTM: Added state and ref for width measurement.

Adding state and ref for tracking token text width is a good approach for conditional styling.


77-78: LGTM: Conditional truncation based on width.

The conditional styling based on measured width implements the requirement to truncate the token symbol when space is limited.


83-90: LGTM: Improved markup structure with ref.

The div structure with ref implementation cleanly separates concerns between measurement and styling.

@cloudflare-workers-and-pages
Copy link

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: f3ad3a9
Status: ✅  Deploy successful!
Preview URL: https://db411129.x-e62.pages.dev
Branch Preview URL: https://feat-pro-3225-new-token-tile.x-e62.pages.dev

View logs

Copy link
Collaborator

@IAmKio IAmKio left a comment

Choose a reason for hiding this comment

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

LGTM!

@RanaBug RanaBug merged commit 1bc8ab1 into staging May 1, 2025
7 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.

2 participants