-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
104 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
apps/web/src/components/Search/SearchDefaultTrendingUsersSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import { graphql, useFragment } from 'react-relay'; | ||
import styled, { keyframes } from 'styled-components'; | ||
|
||
import breakpoints from '~/components/core/breakpoints'; | ||
import { SearchDefaultTrendingUsersSectionFragment$key } from '~/generated/SearchDefaultTrendingUsersSectionFragment.graphql'; | ||
|
||
import { HStack, VStack } from '../core/Spacer/Stack'; | ||
import SuggestedProfileCard from '../Feed/SuggestedProfileCard'; | ||
import SearchResultsHeader from './SearchResultsHeader'; | ||
import { SearchItemType } from './types'; | ||
|
||
type Props = { | ||
queryRef: SearchDefaultTrendingUsersSectionFragment$key; | ||
variant?: 'default' | 'compact'; | ||
onSelect: (item: SearchItemType) => void; | ||
}; | ||
|
||
export default function SearchDefaultTrendingUsersSection({ queryRef, variant, onSelect }: Props) { | ||
const query = useFragment( | ||
graphql` | ||
fragment SearchDefaultTrendingUsersSectionFragment on Query { | ||
trendingUsers5Days: trendingUsers(input: { report: LAST_5_DAYS }) { | ||
... on TrendingUsersPayload { | ||
__typename | ||
users { | ||
username | ||
dbid | ||
...SuggestedProfileCardFragment | ||
} | ||
} | ||
} | ||
...SuggestedProfileCardFollowFragment | ||
} | ||
`, | ||
queryRef | ||
); | ||
|
||
if (query.trendingUsers5Days?.__typename !== 'TrendingUsersPayload') { | ||
return null; | ||
} | ||
|
||
const { users: trendingUsers } = query.trendingUsers5Days; | ||
|
||
return ( | ||
<StyledWrapper gap={8}> | ||
<HeaderWrapper> | ||
<SearchResultsHeader variant={variant}> | ||
Trending collectors and creators | ||
</SearchResultsHeader> | ||
</HeaderWrapper> | ||
<HStack gap={4}> | ||
{trendingUsers?.slice(0, 2)?.map((profile) => ( | ||
<SuggestedProfileCard | ||
key={profile.dbid} | ||
userRef={profile} | ||
queryRef={query} | ||
onClick={() => | ||
onSelect({ | ||
type: 'User' as const, | ||
label: profile.username ?? '', | ||
value: profile.dbid, | ||
}) | ||
} | ||
showFollowButton={false} | ||
/> | ||
))} | ||
</HStack> | ||
</StyledWrapper> | ||
); | ||
} | ||
|
||
const HeaderWrapper = styled(HStack)` | ||
padding: 0px 12px; | ||
@media only screen and ${breakpoints.desktop} { | ||
padding-right: 12px; | ||
padding-left: 8px; | ||
} | ||
`; | ||
|
||
const fadeIn = keyframes` | ||
from { opacity: 0 }; | ||
to { opacity: 0.96 }; | ||
`; | ||
|
||
const StyledWrapper = styled(VStack)` | ||
animation: ${fadeIn} 0.2s ease-out forwards; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters