Skip to content

feat/PRO-3165/placeholders-tokens-no-logo#276

Merged
RanaBug merged 2 commits intostagingfrom
feat/PRO-3165/placeholders-tokens-no-logo
Mar 31, 2025
Merged

feat/PRO-3165/placeholders-tokens-no-logo#276
RanaBug merged 2 commits intostagingfrom
feat/PRO-3165/placeholders-tokens-no-logo

Conversation

@RanaBug
Copy link
Collaborator

@RanaBug RanaBug commented Mar 28, 2025

Description

  • Token logo placeholders updates
  • Chain logos update

How Has This Been Tested?

  • Existing 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

  • New Features / Enhancements
    • Improved media grid display now shows only collections with valid items.
    • Enhanced token components to showcase blockchain logo overlays and fallback initials when token images are unavailable.
    • Refined token card and result card layouts offer a more consistent and responsive visual presentation.

@RanaBug RanaBug requested a review from IAmKio March 28, 2025 16:03
@RanaBug RanaBug self-assigned this Mar 28, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 28, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • src/apps/pillarx-app/components/MediaGridCollection/tests/__snapshots__/DisplayCollectionImage.test.tsx.snap is excluded by !**/*.snap

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR introduces several improvements across multiple components. In the grid component, a new variable filters out invalid grid items before rendering. The token display components (HorizontalToken, TokenInfoHorizontal, TokensHorizontalTile, and TokensVerticalList) now accept an optional tokenChains prop and use a blockchain query hook to determine and display a blockchain logo overlay or a fallback text when necessary. Additionally, tests for these components have been updated to wrap rendered components with a Redux Provider and use @testing-library/react. Token logo components have been refactored for consistent responsive styling and overlay logic.

Changes

Files Change Summary
src/apps/pillarx-app/components/HighlightedMediaGridTile/HighlightedMediaGridTile.tsx Introduced validGridsItems to filter grids with items; updated conditional rendering to return null when there are no valid grid items.
src/apps/pillarx-app/components/HorizontalToken/HorizontalToken.tsx
src/apps/pillarx-app/components/TokenInfoHorizontal/TokenInfoHorizontal.tsx
src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx
src/apps/pillarx-app/components/TokensVerticalList/TokensVerticalList.tsx
Added optional tokenChains prop; integrated blockchain list query; updated rendering logic to include blockchain logo overlay or fallback text based on fetched data.
src/apps/pillarx-app/components/HorizontalToken/test/HorizontalToken.test.tsx
src/apps/pillarx-app/components/TokenInfoHorizontal/test/TokenInfoHorizontal.test.tsx
src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx
src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx
src/apps/the-exchange/components/TokenLogo/test/TokenLogo.test.tsx
src/apps/token-atlas/components/TokenCard/test/TokenCard.test.tsx
Updated tests to wrap components with a Redux Provider and MemoryRouter; transitioned from react-test-renderer to @testing-library/react with DOM-based assertions.
src/apps/the-exchange/components/TokenLogo/TokenLogo.tsx
src/apps/token-atlas/components/TokenCard/TokenCard.tsx
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx
src/apps/token-atlas/components/TokenResultCard/TokenResultCard.tsx
Refactored token logo rendering; added a relative wrapper with overlay text (first two characters of the token name) when a token logo is absent; updated CSS classes for responsive, full-width/height design.
src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx Simplified blockchain logo assignment logic by directly comparing token contracts (case-sensitive) when exactly one contract is present.

Sequence Diagram(s)

sequenceDiagram
    participant T as Token Component
    participant Q as Blockchain Query (useGetBlockchainsListQuery)
    participant E as Effect Hook
    participant S as State (blockchainLogo)
    
    T->>Q: Fetch blockchain list data
    Q-->>T: Return blockchain list
    T->>E: Trigger useEffect (if tokenChains length == 1)
    E->>S: Check for matching blockchain logo
    S-->>T: Update blockchainLogo state
    T->>T: Render token logo or overlay fallback text
Loading
sequenceDiagram
    participant Test as Test Runner
    participant P as Redux Provider
    participant R as MemoryRouter
    participant C as Component Under Test
    
    Test->>P: Wrap component with Redux Provider
    P->>R: Nest within MemoryRouter
    R->>C: Render component with Redux state context
    C-->>Test: Component renders with proper context
Loading

Possibly related PRs

  • fix/PRO-3155/empty-home-feed-tiles #268: Enhances conditional rendering logic in the grid component to prevent rendering when insufficient data is present, directly related to the validations added in HighlightedMediaGridTile.tsx.

Suggested reviewers

  • IAmKio

Poem

I’m a code rabbit, leaping through lines of code,
Hopping on new props where fresh logic is bestowed.
With blockchain logos shining and overlays so bright,
I nibble on bugs until everything’s just right.
In the garden of code, I celebrate this day—
A playful hop in progress, coding all the way!


🪧 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.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 28, 2025

Deploying x with  Cloudflare Pages  Cloudflare Pages

Latest commit: 39a9999
Status: ✅  Deploy successful!
Preview URL: https://2e6f4f6c.x-e62.pages.dev
Branch Preview URL: https://feat-pro-3165-placeholders-t.x-e62.pages.dev

View logs

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 (4)
src/apps/token-atlas/components/TokenCard/TokenCard.tsx (1)

46-46: Potential issue with RandomAvatar name prop

The fallback logic for the RandomAvatar component could be improved to handle undefined tokenName values more gracefully.

-            <RandomAvatar name={`${tokenName}-chain` || ''} />
+            <RandomAvatar name={tokenName ? `${tokenName}-chain` : ''} />
src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (1)

135-155: Enhanced token logo display with text fallback

The restructured component follows the same pattern as other token logo components, providing better visual consistency and a text fallback when no logo is available.

There appears to be conflicting text size classes on line 151: text-lg text-xs. Consider choosing one text size class to avoid potential styling conflicts.

-                  <span className="absolute inset-0 flex items-center justify-center text-lg text-xs font-bold">
+                  <span className="absolute inset-0 flex items-center justify-center text-xs font-bold">
src/apps/pillarx-app/components/TokenInfoHorizontal/test/TokenInfoHorizontal.test.tsx (1)

17-32: Tests properly updated for Redux integration.

The tests have been correctly modified to wrap components in Redux Provider, which is necessary for components that use Redux hooks.

However, there's some inconsistency in the testing approach - some tests use @testing-library/react methods while others still use direct renderer access. Consider standardizing on one approach for better maintainability.

Consider migrating all tests to use @testing-library/react methods for consistency:

- const tree = renderer.create(...).toJSON() as ReactTestRendererJSON;
- const tokenNameProp = tree.children?.find(...) as ReactTestRendererJSON;
- expect(tokenNameProp.children).toContain(tokenName);
+ render(<Provider store={store}><TokenInfoHorizontal ... /></Provider>);
+ expect(screen.getByText(tokenName)).toBeInTheDocument();

Also applies to: 34-50, 52-67, 69-89, 91-108, 110-131, 133-151, 153-171

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

25-43: Tests properly updated for Redux integration.

All tests have been correctly modified to wrap the HorizontalToken component in a Redux Provider, which is necessary for components that use Redux hooks like useGetBlockchainsListQuery.

However, similar to the TokenInfoHorizontal tests, there's inconsistency in the testing approach. Some tests use modern @testing-library/react methods while others still use direct renderer access.

Consider standardizing on @testing-library/react for all tests:

- const tree = renderer.create(...).toJSON() as ReactTestRendererJSON;
- const divElement = tree.children?.filter(...) as ReactTestRendererJSON[];
- const tokenValueProp = divElement[1].children?.find(...) as ReactTestRendererJSON;
- expect(tokenValueProp.children).toContain(`${tokenValue.toFixed(4)}`);
+ render(<Provider store={store}><HorizontalToken ... /></Provider>);
+ expect(screen.getByText(`$${tokenValue.toFixed(4)}`)).toBeInTheDocument();

Also applies to: 45-62, 64-82, 84-100, 102-129, 131-158, 160-180

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bc3491b and fe8134e.

⛔ Files ignored due to path filters (17)
  • src/apps/pillarx-app/components/HorizontalToken/test/__snapshots__/HorizontalToken.test.tsx.snap is excluded by !**/*.snap
  • 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/TokenInfoHorizontal/test/__snapshots__/TokenInfoHorizontal.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensHorizontalTile/test/__snapshots__/TokensHorizontalTile.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensVerticalList/test/__snapshots__/TokensVerticalList.test.tsx.snap is excluded by !**/*.snap
  • src/apps/pillarx-app/components/TokensVerticalTile/test/__snapshots__/TokensVerticalTile.test.tsx.snap is excluded by !**/*.snap
  • src/apps/the-exchange/components/CardsSwap/test/__snapshots__/CardSwap.test.tsx.snap is excluded by !**/*.snap
  • src/apps/the-exchange/components/DropdownTokensList/test/__snapshots__/DropdownTokensList.test.tsx.snap is excluded by !**/*.snap
  • src/apps/the-exchange/components/ExchangeAction/test/__snapshots__/ExchangeAction.test.tsx.snap is excluded by !**/*.snap
  • src/apps/the-exchange/components/SelectToken/test/__snapshots__/SelectToken.test.tsx.snap is excluded by !**/*.snap
  • src/apps/the-exchange/components/TokenListItem/test/__snapshots__/TokenListItem.test.tsx.snap is excluded by !**/*.snap
  • src/apps/the-exchange/components/TokenLogo/test/__snapshots__/TokenLogo.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokenCard/test/__snapshots__/TokenCard.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokenGraphColumn/test/__snapshots__/TokenGraphColumn.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokenResultCard/test/__snapshots__/TokenResultCard.test.tsx.snap is excluded by !**/*.snap
  • src/apps/token-atlas/components/TokensSearchResult/test/__snapshots__/TokensSearchResult.test.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (16)
  • src/apps/pillarx-app/components/HighlightedMediaGridTile/HighlightedMediaGridTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/HorizontalToken/HorizontalToken.tsx (4 hunks)
  • src/apps/pillarx-app/components/HorizontalToken/test/HorizontalToken.test.tsx (7 hunks)
  • src/apps/pillarx-app/components/TokenInfoHorizontal/TokenInfoHorizontal.tsx (3 hunks)
  • src/apps/pillarx-app/components/TokenInfoHorizontal/test/TokenInfoHorizontal.test.tsx (6 hunks)
  • src/apps/pillarx-app/components/TokensHorizontalTile/TokensHorizontalTile.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (4 hunks)
  • src/apps/pillarx-app/components/TokensVerticalList/TokensVerticalList.tsx (1 hunks)
  • src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (3 hunks)
  • src/apps/the-exchange/components/TokenLogo/TokenLogo.tsx (1 hunks)
  • src/apps/the-exchange/components/TokenLogo/test/TokenLogo.test.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenCard/TokenCard.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenCard/test/TokenCard.test.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenGraphColumn/TokenGraphColumn.tsx (1 hunks)
  • src/apps/token-atlas/components/TokenResultCard/TokenResultCard.tsx (1 hunks)
  • src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
src/apps/pillarx-app/components/HorizontalToken/HorizontalToken.tsx (1)
src/types/api.ts (1)
  • TokenContract (150-155)
src/apps/pillarx-app/components/TokenInfoHorizontal/TokenInfoHorizontal.tsx (1)
src/types/api.ts (1)
  • TokenContract (150-155)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (27)
src/apps/token-atlas/components/TokenCard/test/TokenCard.test.tsx (1)

58-58: Test expectations updated correctly.

The test now expects 1 random avatar instead of 2, matching the updated component behavior for rendering when no logos are provided.

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

35-35: New tokenChains prop enhances the token display.

The addition of the tokenChains prop to the HorizontalToken component enables blockchain information to be passed through, allowing for the display of chain logos as mentioned in the PR objectives.

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

78-78: TokenInfoHorizontal now includes chain information.

The addition of the tokenChains prop is consistent with the PR objectives to update token logo placeholders and chain logos. This change enables the component to display blockchain information.

src/apps/pillarx-app/components/HighlightedMediaGridTile/HighlightedMediaGridTile.tsx (2)

55-58: Improved filtering logic for grid items.

The new validGridsItems variable filters out grids with no valid items, enhancing the validation logic before rendering.


64-68: Enhanced rendering conditions improve component robustness.

The updated conditional check now includes verification for empty validGridsItems, preventing attempts to render with invalid data structures.

src/apps/pillarx-app/components/TokensVerticalTile/test/TokensVerticalTile.test.tsx (3)

4-6: Proper Redux Provider setup added

The addition of Redux Provider imports is appropriate and follows best practices for testing components that rely on Redux state.


52-57: Correctly wrapped component with Redux Provider

The component is now properly wrapped with the Redux Provider, ensuring it has access to the Redux store during testing. This change aligns with the PR's focus on enhancing token display components that need store access.


77-81: Consistent Redux Provider wrapping across tests

The empty data test case now consistently uses the same Provider wrapping pattern, ensuring reliable test behavior.

src/apps/pillarx-app/components/TokensHorizontalTile/test/TokensHorizontalTile.test.tsx (4)

4-6: Proper Redux Provider setup added

The addition of Redux Provider imports is appropriate and follows best practices for testing components that rely on Redux state.


53-57: Correctly wrapped component with Redux Provider

The component is now properly wrapped with the Redux Provider, ensuring it has access to the Redux store during testing, which is necessary for blockchain logo overlay functionality mentioned in the PR.


67-71: Redux Provider added to loading state test

The loading state test now correctly includes the Redux Provider wrapper, maintaining consistency across test cases.


92-99: Consistent test structure maintained

The empty data test case properly maintains the Provider wrapping pattern while preserving the component's props structure.

src/apps/the-exchange/components/TokenLogo/test/TokenLogo.test.tsx (2)

50-50: Updated class expectations to match responsive styling

The test expectations have been updated to match the component's shift from fixed dimensions to responsive styling, which is more maintainable and aligned with modern CSS practices.


58-58: Consistent class expectations across test cases

This test case has been similarly updated to maintain consistency with the new responsive styling approach used in the component.

src/apps/token-atlas/components/TokenCard/TokenCard.tsx (3)

27-34: Simplified conditional rendering for blockchain logo

The conditional rendering for the blockchain logo has been appropriately simplified using a logical AND operator, which is cleaner and more readable than the previous approach.


36-48: Improved token logo rendering structure

The token logo rendering has been enhanced with a proper container and conditional rendering between the actual logo and fallback. This structure allows for better styling control and visual consistency.


50-55: Great addition of text overlay for missing logos

The addition of text overlay showing the first two characters of the token name when no logo is available is an excellent fallback mechanism that improves the user experience.

src/apps/token-atlas/components/TokensSlider/TokensSlider.tsx (1)

143-148: Improved logic for blockchain logo determination

The change properly handles cases where tokens have multiple contracts by only showing a blockchain logo when exactly one contract exists. This ensures we don't arbitrarily display a logo for multi-chain tokens.

src/apps/the-exchange/components/TokenLogo/TokenLogo.tsx (1)

23-46: Enhanced token logo rendering with fallback text

The restructured component provides better visual consistency by maintaining a fixed-size container and adding a text overlay that displays the first two characters of the token name when no logo is available. The use of responsive sizing classes (w-full h-full) is also a good practice.

src/apps/pillarx-app/components/TokenInfoHorizontal/TokenInfoHorizontal.tsx (2)

1-45: Added blockchain logo support with proper data fetching

The addition of the tokenChains prop and blockchain data fetching is well-implemented. The effect correctly sets the blockchain logo when there's exactly one token chain and the data is successfully loaded.


51-82: Enhanced token display with blockchain overlay

The restructured token logo rendering now includes both a text fallback for missing logos and a blockchain logo overlay when the token exists on exactly one blockchain. The implementation is clean and visually consistent with other token components.

src/apps/token-atlas/components/TokenResultCard/TokenResultCard.tsx (1)

33-52: Improved token logo display with fallback text!

The updated implementation enhances the token logo display by:

  1. Using a responsive container with proper positioning
  2. Providing an organized structure for both the logo and random avatar
  3. Adding an overlay text showing the first two characters of the token name when no logo is available

This change improves user experience by ensuring there's always a visual identifier for tokens.

src/apps/pillarx-app/components/HorizontalToken/HorizontalToken.tsx (3)

1-8: LGTM: New imports and props for blockchain integration.

The additions of React hooks, TokenContract type, and the blockchain query hook provide the necessary foundation for displaying blockchain information alongside tokens.

Also applies to: 21-21, 33-33


38-50: Well-implemented blockchain logo fetching logic.

The state management implementation correctly:

  1. Initializes the blockchain logo state
  2. Fetches blockchain data
  3. Updates the logo only when there's exactly one blockchain for the token
  4. Includes all necessary dependencies in the useEffect

This ensures efficient rendering and proper blockchain logo display.


61-92: Excellent responsive token and blockchain logo implementation.

The token logo display has been enhanced with:

  1. A responsive container using relative positioning
  2. Proper fallback to RandomAvatar when no logo is available
  3. Text overlay showing the first two characters of the token name as a visual identifier
  4. Blockchain logo overlay with appropriate positioning when a single blockchain is associated

This implementation improves the visual representation of tokens and provides users with more context.

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

1-1: LGTM: Updated imports for Redux integration in tests.

Proper imports for testing library and Redux provider components.

Also applies to: 4-7

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

1-1: LGTM: Updated imports for Redux integration in tests.

Proper imports for testing library and Redux provider components.

Also applies to: 4-7

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!

@github-actions github-actions bot temporarily deployed to Preview (feat/PRO-3165/placeholders-tokens-no-logo) March 31, 2025 10:24 Inactive
@RanaBug RanaBug merged commit 603e5d5 into staging Mar 31, 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