-
Notifications
You must be signed in to change notification settings - Fork 581
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(DIA-1017): add bottom sheet to infinite discovery #11318
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { FollowButton } from "@artsy/palette-mobile" | ||
import { ArtistFollowButtonQuery } from "__generated__/ArtistFollowButtonQuery.graphql" | ||
import { ArtistFollowButton_artist$key } from "__generated__/ArtistFollowButton_artist.graphql" | ||
import { useFollowArtist } from "app/utils/mutations/useFollowArtist" | ||
import { FC } from "react" | ||
import { useLazyLoadQuery, graphql, useFragment } from "react-relay" | ||
|
||
interface ArtistFollowButtonProps { | ||
artist: ArtistFollowButton_artist$key | ||
} | ||
|
||
export const ArtistFollowButton: FC<ArtistFollowButtonProps> = ({ artist }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Separated the personalized data into an individual query. |
||
const data = useFragment(fragment, artist) | ||
const [commitMutation, isInFlight] = useFollowArtist() | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const handleOnPress = () => { | ||
commitMutation({ | ||
variables: { input: { artistID: data.internalID, unfollow: data.isFollowed } }, | ||
updater: (store) => { | ||
store.get(data.internalID)?.setValue(!data.isFollowed, "isFollowed") | ||
}, | ||
}) | ||
} | ||
|
||
return <FollowButton isFollowed={data.isFollowed} onPress={handleOnPress} loading={isInFlight} /> | ||
} | ||
|
||
const fragment = graphql` | ||
fragment ArtistFollowButton_artist on Artist { | ||
internalID @required(action: NONE) | ||
isFollowed @required(action: NONE) | ||
} | ||
` | ||
|
||
interface ArtistFollowButtonQueryRendererProps { | ||
artistID: string | ||
} | ||
|
||
export const ArtistFollowButtonQueryRenderer: FC<ArtistFollowButtonQueryRendererProps> = ({ | ||
artistID, | ||
}) => { | ||
const data = useLazyLoadQuery<ArtistFollowButtonQuery>(query, { id: artistID }) | ||
|
||
if (!data.artist) { | ||
return <FollowButton isFollowed={false} /> | ||
} | ||
|
||
return <ArtistFollowButton artist={data.artist} /> | ||
} | ||
|
||
const query = graphql` | ||
query ArtistFollowButtonQuery($id: String!) { | ||
artist(id: $id) { | ||
...ArtistFollowButton_artist | ||
} | ||
} | ||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { EntityHeader, Flex, Touchable } from "@artsy/palette-mobile" | ||
import { ArtistListItemShortQuery } from "__generated__/ArtistListItemShortQuery.graphql" | ||
import { ArtistListItemShort_artist$key } from "__generated__/ArtistListItemShort_artist.graphql" | ||
import { ArtistFollowButtonQueryRenderer } from "app/Components/ArtistFollowButton" | ||
import { ReadMore } from "app/Components/ReadMore" | ||
import { navigate } from "app/system/navigation/navigate" | ||
import { truncatedTextLimit } from "app/utils/hardware" | ||
import { withSuspense } from "app/utils/hooks/withSuspense" | ||
import { FC } from "react" | ||
import { graphql, useFragment, useLazyLoadQuery } from "react-relay" | ||
|
||
interface ArtistListItemShortProps { | ||
artist: ArtistListItemShort_artist$key | ||
} | ||
|
||
export const ArtistListItemShort: FC<ArtistListItemShortProps> = ({ artist }) => { | ||
const data = useFragment(fragment, artist) | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const image = data.coverArtwork?.image?.cropped?.url ?? undefined | ||
const bio = data?.biographyBlurb?.text | ||
const bioTextLimit = truncatedTextLimit() | ||
|
||
const handleOnPress = () => { | ||
navigate(data.href) | ||
} | ||
|
||
return ( | ||
<> | ||
<Flex flexDirection="row" justifyContent="space-between" alignItems="center"> | ||
<Touchable onPress={handleOnPress} style={{ flex: 1 }}> | ||
<EntityHeader | ||
name={data.name} | ||
initials={data.initials} | ||
imageUrl={image} | ||
meta={data.formattedNationalityAndBirthday ?? undefined} | ||
RightButton={<ArtistFollowButtonQueryRenderer artistID={data.internalID} />} | ||
/> | ||
</Touchable> | ||
</Flex> | ||
|
||
{!!bio && ( | ||
<ReadMore content={bio} maxChars={bioTextLimit} textVariant="xs" linkTextVariant="xs" /> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
const fragment = graphql` | ||
fragment ArtistListItemShort_artist on Artist { | ||
internalID @required(action: NONE) | ||
name @required(action: NONE) | ||
initials @required(action: NONE) | ||
href @required(action: NONE) | ||
formattedNationalityAndBirthday | ||
|
||
coverArtwork { | ||
image { | ||
cropped(height: 45, width: 45) { | ||
url | ||
} | ||
} | ||
} | ||
biographyBlurb { | ||
text | ||
} | ||
} | ||
` | ||
|
||
interface ArtworkListItemShortWithSuspenseProps { | ||
artistSlug: string | ||
} | ||
|
||
export const ArtworkListItemShortWithSuspense = withSuspense<ArtworkListItemShortWithSuspenseProps>( | ||
{ | ||
Component: ({ artistSlug }) => { | ||
const data = useLazyLoadQuery<ArtistListItemShortQuery>(query, { slug: artistSlug }) | ||
|
||
if (!data?.artist) { | ||
return null | ||
} | ||
|
||
return <ArtistListItemShort artist={data.artist} /> | ||
}, | ||
LoadingFallback: () => null, | ||
ErrorFallback: () => null, | ||
} | ||
) | ||
|
||
const query = graphql` | ||
query ArtistListItemShortQuery($slug: String!) { | ||
artist(id: $slug) { | ||
...ArtistListItemShort_artist | ||
name | ||
} | ||
} | ||
` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { FollowButton } from "@artsy/palette-mobile" | ||
import { PartnerFollowButtonQuery } from "__generated__/PartnerFollowButtonQuery.graphql" | ||
import { PartnerFollowButton_partner$key } from "__generated__/PartnerFollowButton_partner.graphql" | ||
import { useFollowProfile } from "app/utils/mutations/useFollowProfile" | ||
import { FC } from "react" | ||
import { graphql, useFragment, useLazyLoadQuery } from "react-relay" | ||
|
||
interface PartnerFollowButtonProps { | ||
partner: PartnerFollowButton_partner$key | ||
} | ||
|
||
export const PartnerFollowButton: FC<PartnerFollowButtonProps> = ({ partner }) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Created a version of the follow button personalized and with an isolated query. Same as we do for ArtistFollows |
||
const data = useFragment(fragment, partner) | ||
const { followProfile, isInFlight } = useFollowProfile({ | ||
id: data?.profile.id ?? "", | ||
internalID: data?.profile.internalID ?? "", | ||
isFollowed: !!data?.profile.isFollowed, | ||
}) | ||
|
||
if (!data) { | ||
return null | ||
} | ||
|
||
const handleOnPress = () => { | ||
followProfile() | ||
} | ||
|
||
return ( | ||
<FollowButton | ||
isFollowed={!!data.profile.isFollowed} | ||
onPress={handleOnPress} | ||
loading={isInFlight} | ||
/> | ||
) | ||
} | ||
|
||
const fragment = graphql` | ||
fragment PartnerFollowButton_partner on Partner { | ||
internalID @required(action: NONE) | ||
profile @required(action: NONE) { | ||
id @required(action: NONE) | ||
internalID @required(action: NONE) | ||
isFollowed | ||
} | ||
} | ||
` | ||
|
||
interface PartnerFollowButtonQueryRendererProps { | ||
partnerID: string | ||
} | ||
|
||
export const PartnerFollowButtonQueryRenderer: FC<PartnerFollowButtonQueryRendererProps> = ({ | ||
partnerID, | ||
}) => { | ||
const data = useLazyLoadQuery<PartnerFollowButtonQuery>(query, { id: partnerID }) | ||
|
||
if (!data.partner) { | ||
return <FollowButton isFollowed={false} /> | ||
} | ||
|
||
return <PartnerFollowButton partner={data.partner} /> | ||
} | ||
|
||
const query = graphql` | ||
query PartnerFollowButtonQuery($id: String!) { | ||
partner(id: $id) { | ||
...PartnerFollowButton_partner | ||
} | ||
} | ||
` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nothing changed so far, lifted up some elements to be able to share the Biography element easily