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

add favorites to portfolio #3853

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Conversation

mattupham
Copy link
Contributor

@mattupham mattupham commented Sep 24, 2024

What is the purpose of the change:

  • add favorites functionality to portfolio

Linear Task

https://linear.app/osmosis/issue/FE-1045/portfolio-v3-favorites

Brief Changelog

  • update to use outlined star based on figma
  • add favorites logic
  • takes into consideration favorites assets from the assets page

Testing and Verifying

Screen.Recording.2024-09-24.at.10.49.25.AM.mov
Screenshot 2024-09-24 at 10 56 33 AM

Copy link

vercel bot commented Sep 24, 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 Sep 24, 2024 6:11pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
osmosis-frontend-datadog ⬜️ Ignored (Inspect) Visit Preview Sep 24, 2024 6:11pm
osmosis-frontend-dev ⬜️ Ignored (Inspect) Visit Preview Sep 24, 2024 6:11pm
osmosis-frontend-edgenet ⬜️ Ignored (Inspect) Sep 24, 2024 6:11pm
osmosis-testnet ⬜️ Ignored (Inspect) Visit Preview Sep 24, 2024 6:11pm

@mattupham mattupham changed the title [draft] add favorites to portfolio add favorites to portfolio Sep 24, 2024
@mattupham mattupham marked this pull request as ready for review September 24, 2024 17:58
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes introduce functionality for managing a user watchlist and a favorites list within the AssetBalancesTable component. A new state variable, favoritesList, is initialized using the useLocalStorageState hook, allowing persistence of user favorites across sessions. The AssetCell component is updated to handle new props for watchlist management, enabling users to add or remove assets from their watchlist. The rendering logic of the AssetCell is also modified to reflect the asset's status in the watchlist.

Changes

File Change Summary
packages/web/components/table/asset-balances.tsx Added functionality for user watchlist and favorites; introduced watchListDenoms and toggleWatchAssetDenom; modified AssetCell to accept new props for managing watchlist status.

Possibly related PRs

Suggested reviewers

  • yury-dubinin
  • MaxMillington

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c6d498b and f5a3f31.

Files selected for processing (1)
  • packages/web/components/table/asset-balances.tsx (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/web/components/table/asset-balances.tsx

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

Outside diff range and nitpick comments (4)
packages/web/components/table/cells/asset.tsx (1)

43-43: LGTM! Consider a minor optimization.

The conditional id for the star icon is correctly implemented, aligning with the PR objective of adding favorites functionality. This change allows for different icon representations based on the watchlist status, which is great.

For a minor optimization, consider moving the condition outside the JSX:

+ const starIconId = isInUserWatchlist ? "star" : "star-outlined";
  <Icon
    onClick={(e) => {
      e.stopPropagation();
      e.preventDefault();
      onClickWatchlist();
    }}
    className={classNames(
      "cursor-pointer transition-colors duration-150 ease-out hover:text-wosmongton-300",
      isInUserWatchlist ? "text-wosmongton-400" : "text-osmoverse-600"
    )}
-   id={isInUserWatchlist ? "star" : "star-outlined"}
+   id={starIconId}
  />

This change would slightly improve readability and prevent the condition from being re-evaluated on each render.

packages/web/components/table/asset-balances.tsx (3)

173-176: Consider initializing favoritesList with an empty array

Initializing favoritesList with default values ["OSMO", "ATOM", "TIA"] may not align with user expectations. It might be better to start with an empty list and allow users to add their own favorites.


174-175: Namespace the localStorage key to avoid conflicts

Using a generic key like "favoritesList" in localStorage may lead to potential conflicts with other applications or components. Consider namespacing the key, for example, "osmosisFavoritesList", to prevent collisions.


244-252: Review dependency array in useMemo hook

Including onSetFavoritesList in the dependency array may not be necessary. Setter functions from state hooks are generally stable and can be excluded to prevent unnecessary re-renders.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ca647f1 and c6d498b.

Files ignored due to path filters (1)
  • packages/web/public/icons/sprite.svg is excluded by !**/*.svg, !**/*.svg
Files selected for processing (2)
  • packages/web/components/table/asset-balances.tsx (4 hunks)
  • packages/web/components/table/cells/asset.tsx (1 hunks)
Additional comments not posted (2)
packages/web/components/table/cells/asset.tsx (1)

Line range hint 1-89: Excellent component structure and implementation!

The AssetCell component is well-designed and follows React best practices. Here are some notable points:

  1. Proper TypeScript typing for enhanced type safety.
  2. Flexible prop structure allowing partial props.
  3. Responsive design with different styles for mobile and desktop.
  4. Use of Next.js Image component for optimized image loading.
  5. Internationalization support via the useTranslation hook.
  6. Proper handling of accessibility concerns (e.g., alt text for images).
  7. Efficient use of classNames for conditional styling.

The component effectively implements the favorites functionality while maintaining a clean and maintainable structure. Great job!

packages/web/components/table/asset-balances.tsx (1)

189-198: Ensure coinDenom uniquely identifies assets

Using coinDenom to identify assets in favoritesList may lead to issues if multiple assets share the same coinDenom. Verify that coinDenom uniquely identifies each asset, or consider using a more unique identifier like coinMinimalDenom or an asset ID.

@mattupham mattupham merged commit e9e896a into stage Sep 24, 2024
32 of 33 checks passed
@mattupham mattupham deleted the mattupham/fe-1045-portfolio-v3-favorites branch September 24, 2024 18:46
mattupham added a commit that referenced this pull request Sep 25, 2024
* Amplitude: prevent outlier value usd logs (#3825)

* prevent outlier value usd logs

* usd const

* forgot one

* format

* Mattupham/fe 726 porfolio v3 alloyed convert button deposit withdraw dropdown (#3841)

* Add convert button

* Add convert button

* Clean up

* Handle feature via flag

* Update icons

* Clean up

* Clean up

* i18n

* Extract functionality

* Extract type

* Clean up comments

* Refactor icon

* Clean up styles

* Update types

* fix: amino signing for withdraw position message (#3852)

* add favorites to portfolio (#3853)

* Update sprite

* Clean up

* Update to useUserWatchlist

---------

Co-authored-by: Jon Ator <jonathanator0@gmail.com>
Co-authored-by: Matt Upham <30577966+mattupham@users.noreply.github.com>
Co-authored-by: PaddyMc <paddymchale@hotmail.com>
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