Skip to content

Commit

Permalink
Merge pull request #421 from reservoirprotocol/armando/grwth-3613-fea…
Browse files Browse the repository at this point in the history
…tured-section

Homepage Redesign
  • Loading branch information
pedromcunha authored Dec 7, 2023
2 parents b3fa647 + c1711e6 commit 4f23e5f
Show file tree
Hide file tree
Showing 6 changed files with 538 additions and 618 deletions.
44 changes: 31 additions & 13 deletions components/common/CollectionsTimeDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { useCollections } from '@reservoir0x/reservoir-kit-ui'
import {
useCollections,
useTrendingCollections,
} from '@reservoir0x/reservoir-kit-ui'
import { Text, Button, Box } from '../primitives'
import {
DropdownMenuItem,
Expand All @@ -10,29 +13,44 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faChevronDown } from '@fortawesome/free-solid-svg-icons'

export type CollectionsSortingOption = NonNullable<
Exclude<Parameters<typeof useCollections>[0], false | undefined>['sortBy']
Exclude<
Parameters<typeof useTrendingCollections>[0],
false | undefined
>['period']
>

const sortingOptions: CollectionsSortingOption[] = [
'1DayVolume',
'7DayVolume',
'30DayVolume',
'allTimeVolume',
'10m',
'1d',
'1h',
'30d',
'30m',
'5m',
'6h',
'7d',
]

const nameForSortingOption = (
option: CollectionsSortingOption,
compact: boolean
) => {
switch (option) {
case '1DayVolume':
return compact ? '24h' : '24 hours'
case '7DayVolume':
return compact ? '7d' : '7 days'
case '30DayVolume':
case '30d':
return compact ? '30d' : '30 days'
case 'allTimeVolume':
return compact ? 'All' : 'All Time'
case '7d':
return compact ? '7d' : '7 days'
case '1d':
return compact ? '24h' : '24 hours'
case '6h':
return compact ? '6h' : '6 hours'
case '1h':
return compact ? '1h' : '1 hour'
case '30m':
return compact ? '30m' : '30 minutes'
case '10m':
return compact ? '10m' : '10 minutes'
case '5m':
return compact ? '5m' : '5 minutes'
}
}

Expand Down
19 changes: 0 additions & 19 deletions components/home/ActiveMintTooltip.tsx

This file was deleted.

192 changes: 192 additions & 0 deletions components/home/FeaturedCards.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useTrendingCollections } from '@reservoir0x/reservoir-kit-ui'
import { Box, Flex, FormatCryptoCurrency, Text } from 'components/primitives'
import Img from 'components/primitives/Img'
import { useMarketplaceChain } from 'hooks'
import Link from 'next/link'

type TrendingCollections = ReturnType<typeof useTrendingCollections>['data']

type FeaturedCardsProps = {
collections: TrendingCollections
loading?: boolean
}

export const FeaturedCards: React.FC<FeaturedCardsProps> = ({
collections,
loading,
}) => {
const marketplaceChain = useMarketplaceChain()

if (!collections) return null

return (
<>
{!loading && collections.length === 0 ? (
<Flex
direction="column"
align="center"
css={{ py: '$6', gap: '$4', width: '100%' }}
>
<Text css={{ color: '$gray11' }}>
<FontAwesomeIcon icon={faMagnifyingGlass} size="2xl" />
</Text>
<Text css={{ color: '$gray11' }}>No collections found</Text>
</Flex>
) : (
<Flex
direction="row"
align="center"
css={{
width: '100%',
overflowY: 'scroll',
gap: '12px',
}}
>
{collections.map((collection) => {
const bannerImage =
collection?.banner ||
collection?.image ||
collection.sampleImages?.[0]

const collectionImage =
collection?.image ||
collection?.banner ||
collection.sampleImages?.[0]

return (
<Link
key={collection.id}
href={`/${marketplaceChain.routePrefix}/collection/${collection.id}`}
>
<Flex
direction="column"
css={{
flex: 1,
width: '330px',
height: '290px',
borderRadius: 12,
cursor: 'pointer',
background: '$neutralBgSubtle',
$$shadowColor: '$colors$panelShadow',
boxShadow: '0 0px 12px 0px $$shadowColor',
p: '16px',
}}
>
<Flex
css={{
mb: '24px',
width: '100%',
height: '100%',
position: 'relative',
}}
>
<Img
src={bannerImage as string}
alt={collection.name as string}
height={150}
width={300}
style={{
objectFit: 'cover',
height: '150px',
width: '300px',
borderRadius: 8,
}}
/>
<Img
src={collectionImage as string}
alt={collection.name as string}
height={50}
width={50}
css={{
position: 'absolute',
inset: '95px 0px 5px 5px',
border: '2px solid white',
borderRadius: 8,
}}
/>
</Flex>
<Flex
direction="column"
css={{
width: '100%',
height: '100%',
}}
>
<Box
css={{
maxWidth: 720,
lineHeight: 1.5,
fontSize: 16,
flex: 1,
fontWeight: 400,
display: '-webkit-box',
color: '$gray12',
fontFamily: '$body',
WebkitLineClamp: 3,
WebkitBoxOrient: 'vertical',
gap: 16,
overflow: 'hidden',
textOverflow: 'ellipsis',
'& a': {
fontWeight: 500,
cursor: 'pointer',
textDecoration: 'underline',
},
}}
>
<Flex
align="center"
css={{
width: 'fit-content',
mb: 16,
gap: '$2',
}}
>
<Text style="h6" as="h6" ellipsify>
{collection?.name}
</Text>
</Flex>
<Flex>
<Box css={{ mr: '$5' }}>
<Text
style="subtitle2"
color="subtle"
as="p"
css={{ mb: 2 }}
>
Floor
</Text>
<FormatCryptoCurrency
amount={
collection?.floorAsk?.price?.amount?.native ?? 0
}
textStyle={'h6'}
logoHeight={12}
address={
collection?.floorAsk?.price?.currency?.contract
}
/>
</Box>

<Box css={{ mr: '$4' }}>
<Text style="subtitle2" color="subtle" as="p">
6h Sales
</Text>
<Text style="h6" as="h4" css={{ mt: 2 }}>
{collection.count?.toLocaleString()}
</Text>
</Box>
</Flex>
</Box>
</Flex>
</Flex>
</Link>
)
})}
</Flex>
)}
</>
)
}
Loading

1 comment on commit 4f23e5f

@vercel
Copy link

@vercel vercel bot commented on 4f23e5f Dec 7, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.