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(home view): add icons to navigation pills #11528

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anandaroop
Copy link
Member

@anandaroop anandaroop commented Feb 11, 2025

Note

Depends on artsy/metaphysics#6423

This PR resolves ONYX-1464

Description

Consumes the new icon field of the NavigationPill MP type in order to render icons in the Quick Links section of the home view.

iOS Android
iOS TKTK

PR Checklist

  • I have tested my changes on iOS and Android.
  • I hid my changes behind a feature flag, or they don't need one.
  • I have included screenshots or videos, or I have not changed the UI.
  • I have added tests, or my changes don't require any.
  • I added an app state migration, or my changes do not require one.
  • I have documented any follow-up work that this PR will require, or it does not require any.
  • I have added a changelog entry below, or my changes do not require one.

To the reviewers 👀

  • I would like at least one of the reviewers to run this PR on the simulator or device.
Changelog updates

Changelog updates

Cross-platform user-facing changes

  • Display icons with home view navigation pills

iOS user-facing changes

Android user-facing changes

Dev changes

Need help with something? Have a look at our docs, or get in touch with us.

@anandaroop
Copy link
Member Author

Seeing a large number of unrelated failures, will have to investigate…

@anandaroop anandaroop force-pushed the anandaroop/ONYX-1484-quick-links-icons branch from e4a978c to 9b76941 Compare February 11, 2025 04:20
Comment on lines +190 to +194
const SUPPORTED_ICONS: Record<string, ComponentType> = {
FollowArtistIcon,
AuctionIcon,
HeartIcon,
}
Copy link
Member Author

Choose a reason for hiding this comment

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

We may want to launch with a larger set of icons supported right at the outset.

Comment on lines +2 to +14
import {
AuctionIcon,
Box,
Flex,
FlexProps,
FollowArtistIcon,
HeartIcon,
Pill,
Skeleton,
Spacer,
Text,
useSpace,
} from "@artsy/palette-mobile"
Copy link
Member Author

Choose a reason for hiding this comment

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

Wondering how this will change if @MrSltun's icon refactor moves forward, or if we need to account for that already…

Copy link
Member

Choose a reason for hiding this comment

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

I believe only the name would change, maybe adding the color using the useColor hook, but I don't think it would take that much effort to change it after the refactor :)

Comment on lines +199 to +200
if (name && name in SUPPORTED_ICONS) {
const Icon = SUPPORTED_ICONS[name]
Copy link
Contributor

@dariakoko dariakoko Feb 11, 2025

Choose a reason for hiding this comment

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

I'm wondering if using something like switch ... case would be better here to make sure that if the name of the ion changes we're safe

switch ( name ) {
  case 'HeartIcon':
      return HeartIcon
  case 'AuctionIcon':
      return AuctionIcon
  ...
  default: 
       return null
}

example after updating icons:

switch ( name ) {
 case 'HeartIcon':
     return HeartIconNew
 case 'AuctionIcon':
     return AuctionIconNew
 ...
 default: 
      return null
}

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a great point.

Just glancing at the first batch of icons we're looking at something like…

artsy/palette-mobile artsy/icons
today, in this PR upcoming, after refactor
AuctionIcon Gavel
HeartIcon HeartStrokeIcon
FollowArtistIcon 🚫 (missing?!)

…with more to come if we add even more supported icons.


I think that instead of a switch statement, the existing mapping on L190 already provides the place to do this:

// today
const SUPPORTED_ICONS: Record<string, ComponentType> = {
   FollowArtistIcon,
   AuctionIcon,
   HeartIcon,
 }
// re-mapped in the future
const SUPPORTED_ICONS: Record<string, ComponentType> = {
   "FollowArtistIcon": FollowArtistIconTBD,
   "AuctionIcon": Gavel,
   "HeartIcon":  HeartStrokeIcon,
 }

So I'm inclined to leave this as-is, unless you foresee any problems with that.

Copy link
Member Author

@anandaroop anandaroop Feb 11, 2025

Choose a reason for hiding this comment

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

Even better might be to do the (inverted) mapping now, and then simplify it in the future once that refactor lands:

// mapped today
const SUPPORTED_ICONS: Record<string, ComponentType> = {
   "FollowArtistIcon": FollowArtistIcon,
   "Gavel": AuctionIcon,
   "HeartStrokeIcon": HeartIcon ,
 }
// un-mapped in the future
const SUPPORTED_ICONS: Record<string, ComponentType> = {
   FollowArtistIcon,
   AuctionIcon,
   HeartIcon,
 }

That might make things tidier for future-us 🤷🏽

Copy link
Member Author

Choose a reason for hiding this comment

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

But I would only want to do that^ if we are 99% sure that refactor is going to proceed. (Wdyt @MrSltun?)

Copy link
Member

@MounirDhahri MounirDhahri left a comment

Choose a reason for hiding this comment

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

image

@anandaroop anandaroop force-pushed the anandaroop/ONYX-1484-quick-links-icons branch from 9b76941 to cdc4852 Compare February 11, 2025 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants