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

Feature / Drops #359

Merged
merged 70 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
70a8e8f
Drops added to navbar
ismailToyran Aug 9, 2023
567ece0
Drops gql added
ismailToyran Aug 9, 2023
294c0cf
Empty drops page added with fetching enabled
ismailToyran Aug 9, 2023
5b36bc2
useDropTimeline hook added
ismailToyran Aug 9, 2023
0531438
Drop card added without locale
ismailToyran Aug 9, 2023
db62c55
Add drops page locales
ismailToyran Aug 9, 2023
dfec82e
Ended drops add pagination
ismailToyran Aug 9, 2023
cf9ae41
Mobile card changes
ismailToyran Aug 9, 2023
0e08494
Add drop card locales
ismailToyran Aug 9, 2023
32fec40
Add countdown locales
ismailToyran Aug 9, 2023
7971d4c
Drop header component added
ismailToyran Aug 10, 2023
a6797c1
DropMintSchedule component added
ismailToyran Aug 10, 2023
3126839
DropProgress component added
ismailToyran Aug 10, 2023
ff8f722
Drop MintFormEnded component added
ismailToyran Aug 10, 2023
ca100f8
Drop MintForm component added
ismailToyran Aug 10, 2023
7260cfe
Drop MintFormInprogress component added
ismailToyran Aug 10, 2023
26aab8e
Drop MintFormUpcoming component added
ismailToyran Aug 10, 2023
187aa8e
Drop ListItem component added
ismailToyran Aug 10, 2023
e3e34aa
Change collection detail page location
ismailToyran Aug 10, 2023
269e1aa
MintDrop Modal component added
ismailToyran Aug 10, 2023
cdb5260
New convert functions added
ismailToyran Aug 10, 2023
d605155
Collection drop detail page added
ismailToyran Aug 10, 2023
ab427d2
Collection drop detail graphql added
ismailToyran Aug 10, 2023
4aabb85
ConnectButtonWithNetworkSwitch isDisabled case improvement
ismailToyran Aug 10, 2023
a435390
Merge branch 'dev' into feature/drops
ismailToyran Aug 24, 2023
5f436af
Pagination fix
ismailToyran Aug 24, 2023
997c16d
Apply design changes
ismailToyran Aug 24, 2023
2198233
Locales added to DropProgress component
ismailToyran Aug 28, 2023
4dbaec9
Extra css removal
ismailToyran Aug 28, 2023
bc9a599
Locales added to ListItem component
ismailToyran Aug 28, 2023
cf31870
Locales added to MintForm Ended component
ismailToyran Aug 28, 2023
bd1289e
Locales added to MintForm Upcoming component
ismailToyran Aug 28, 2023
aa5d84d
Locales added to MintForm Inprogress component
ismailToyran Aug 28, 2023
abc2c97
Skeleton added to drop detail page
ismailToyran Aug 29, 2023
b0019db
Merge branch 'dev' into feature/drops
ismailToyran Aug 29, 2023
b74c7a8
Fix build
ismailToyran Aug 29, 2023
b6dd45c
Loader fix
ismailToyran Aug 29, 2023
7c62966
Connect to new version of liteflow-js that needs to be released
ismailToyran Aug 29, 2023
018052a
Countdown style fix
ismailToyran Sep 5, 2023
b7857e9
Upcoming currency image and text fix
ismailToyran Sep 5, 2023
20e57b5
Add interval back
ismailToyran Sep 5, 2023
c5e1909
Merge branch 'dev' into feature/drops
ismailToyran Sep 5, 2023
5cd8737
chains import fix
ismailToyran Sep 5, 2023
fb991a3
Fix imports with the new hook useEnvironment
ismailToyran Sep 5, 2023
791f3c0
Merge branch 'dev' into feature/drops
ismailToyran Sep 22, 2023
074c85c
Update libraries
ismailToyran Sep 22, 2023
0542a99
Connect to the new version of the liteflow package
ismailToyran Sep 22, 2023
80d377f
Remove bignumber.js imports
ismailToyran Sep 22, 2023
8aa9944
Remove BigNumber calculation from mintPercentage
ismailToyran Sep 22, 2023
6a33dec
Merge branch 'dev' into feature/drops
ismailToyran Sep 22, 2023
5824a2d
Merge branch 'dev' into feature/drops
ismailToyran Sep 26, 2023
4e804d3
Refactor drops query
ismailToyran Sep 26, 2023
c0417b0
Refactor countdown component
ismailToyran Sep 26, 2023
1383e12
Simplify drops to render and add refetch
ismailToyran Sep 26, 2023
b01e911
Add different redirection for the quantity provided
ismailToyran Sep 27, 2023
f65ac36
remove duplicated collection header component
antho1404 Sep 30, 2023
4bab636
use bignumber and make supply nullable
antho1404 Sep 30, 2023
e67fed5
redirect based on actual result
antho1404 Sep 30, 2023
43886a4
improve naming and simplify convert
antho1404 Sep 30, 2023
1cd2a1b
update timeline naming
antho1404 Sep 30, 2023
df1e2e2
remove unused minttype
antho1404 Sep 30, 2023
9c39d15
add metadata
antho1404 Sep 30, 2023
a1edb23
simplify listing
antho1404 Sep 30, 2023
747700b
Update components/Drop/ListItem.tsx
ismailToyran Oct 2, 2023
086d769
Merge pull request #438 from liteflow-labs/feature/drops-updates
ismailToyran Oct 2, 2023
ebde0e1
Drop supply available translation fix
ismailToyran Oct 2, 2023
8b76425
Translation added to mint drop modal
ismailToyran Oct 2, 2023
25ccef2
Some changes after revert regarding collection header
ismailToyran Oct 2, 2023
4207a36
Merge branch 'dev' into feature/drops
ismailToyran Oct 2, 2023
54426c7
Hide navbar buttons related to drops
ismailToyran Oct 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 45 additions & 6 deletions components/Countdown/Countdown.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Box, Flex, Text } from '@chakra-ui/react'
import useTranslation from 'next-translate/useTranslation'
import { FC, HTMLAttributes, useEffect, useMemo, useState } from 'react'
import { FC, useEffect, useMemo, useState } from 'react'

const refreshRate = 1000

const Countdown: FC<
HTMLAttributes<any> & { date: Date; hideSeconds?: boolean }
> = ({ date, hideSeconds = false, ...props }) => {
type Props = {
date: Date
hideSeconds?: boolean
isStyled?: boolean
}

const Countdown: FC<Props> = ({ date, hideSeconds = false, isStyled }) => {
const { t } = useTranslation('components')
const [diff, setDiff] = useState(+new Date(date) - +new Date())
const d = useMemo(() => Math.floor(diff / (1000 * 60 * 60 * 24)), [diff])
Expand All @@ -22,15 +27,49 @@ const Countdown: FC<
}, [date])

if (diff <= 0) return null

if (isStyled) {
const boxStyle = {
w: 10,
py: 0.5,
background: 'rgba(107, 114, 128, 0.5)',
color: 'white',
rounded: 'lg',
textAlign: 'center' as any,
}
return (
<Flex gap={2}>
{d > 0 && (
<Box {...boxStyle}>
<Text variant="subtitle2">{d}</Text>
<Text variant="caption">{t('countdown.day-long')}</Text>
</Box>
)}
<Box {...boxStyle}>
<Text variant="subtitle2">{`0${h}`.slice(-2)}</Text>
<Text variant="caption">{t('countdown.hour-long')}</Text>
</Box>
<Box {...boxStyle}>
<Text variant="subtitle2">{`0${m}`.slice(-2)}</Text>
<Text variant="caption">{t('countdown.min-long')}</Text>
</Box>
<Box {...boxStyle}>
<Text variant="subtitle2">{`0${s}`.slice(-2)}</Text>
<Text variant="caption">{t('countdown.sec-long')}</Text>
</Box>
</Flex>
)
}

return (
<div {...props}>
<span>
{d > 0 && <span>{t('countdown.day', { value: d })}</span>}{' '}
<span>{t('countdown.hour', { value: `0${h}`.slice(-2) })}</span>{' '}
<span>{t('countdown.min', { value: `0${m}`.slice(-2) })}</span>{' '}
{!hideSeconds && (
<span>{t('countdown.sec', { value: `0${s}`.slice(-2) })}</span>
)}
</div>
</span>
)
}

Expand Down
171 changes: 171 additions & 0 deletions components/Drop/DropCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
import {
Badge,
Box,
Divider,
Flex,
Heading,
Icon,
IconButton,
Stack,
Text,
} from '@chakra-ui/react'
import { HiArrowNarrowRight } from '@react-icons/all-files/hi/HiArrowNarrowRight'
import { HiBadgeCheck } from '@react-icons/all-files/hi/HiBadgeCheck'
import Price from 'components/Price/Price'
import { convertDropActive } from 'convert'
import useTranslation from 'next-translate/useTranslation'
import numbro from 'numbro'
import { useMemo } from 'react'
import { Timeline } from '../../hooks/useDropTimeline'
import { formatAddress } from '../../utils'
import Countdown from '../Countdown/Countdown'
import Image from '../Image/Image'
import Link from '../Link/Link'
import TokenMedia from '../Token/Media'

type Props = {
drop: ReturnType<typeof convertDropActive>
timeline: Timeline
}

export default function DropCard({ drop, timeline }: Props) {
const { t } = useTranslation('components')

const timelineText = useMemo(() => {
if (timeline === Timeline.UPCOMING) return t('drop.timeline.upcoming')
if (timeline === Timeline.INPROGRESS) return t('drop.timeline.in-progress')
return t('drop.timeline.ended')
}, [t, timeline])

return (
<Box
as={Link}
href={`/collection/${drop.collection.chainId}/${drop.collection.address}/drop`}
borderWidth="1px"
borderRadius="2xl"
w="full"
overflow="hidden"
position="relative"
p={4}
>
<Box
position="absolute"
inset={0}
_after={{
content: '""',
position: 'absolute',
inset: 0,
bg: 'rgba(0,0,0,0.7)',
}}
bg="gray.100"
>
{drop.collection.cover && (
<TokenMedia
imageUrl={drop.collection.cover}
defaultText={drop.collection.name}
animationUrl={undefined}
unlockedContent={null}
sizes="(min-width: 62em) 600px, 100vw"
fill
/>
)}
</Box>

<Flex position="relative" w="full">
{timeline === Timeline.UPCOMING && (
<Countdown date={drop.startDate} isStyled />
)}
<Text as="span" variant="caption" verticalAlign="middle" ml="auto">
<Badge
background="rgba(107, 114, 128, 0.5)"
color="white"
px={2}
py={1}
borderRadius="2xl"
>
{timelineText}
</Badge>
</Text>
</Flex>

<Box
overflow="hidden"
rounded="2xl"
borderWidth="2px"
position="relative"
w={timeline === Timeline.ENDED ? 14 : '72px'}
h={timeline === Timeline.ENDED ? 14 : '72px'}
mt={timeline === Timeline.ENDED ? -3 : 14}
mb={4}
bg="gray.200"
>
{drop.collection.image && (
<Image
src={drop.collection.image}
alt={drop.collection.name}
fill
sizes="72px"
objectFit="cover"
/>
)}
</Box>

<Flex position="relative" justifyContent="space-between" gap={4} w="full">
<Flex flexDir="column" gap={1}>
<Heading variant="heading2" color="white" isTruncated>
{drop.collection.name}
</Heading>

<Flex alignItems="center" gap={1.5}>
<Text variant="button2" color="white">
{t('drop.by', {
address:
drop.collection.deployer.name ||
formatAddress(drop.collection.deployer.address, 10),
})}
</Text>
{drop.collection.deployer?.verified && (
<Icon as={HiBadgeCheck} color="brand.500" h={4} w={4} />
)}
</Flex>

<Flex alignItems="center" gap={2}>
<Text variant="caption" color="white">
{drop.supply === Infinity
? t('drop.supply.infinite')
: t('drop.supply.available', {
count: numbro(drop.supply).format({
thousandSeparated: true,
}),
})}
</Text>
<Divider orientation="vertical" h={4} />
<Stack alignItems="center" direction="row" spacing={1}>
<Flex flexShrink={0}>
<Image
src={drop.currency.image}
alt={drop.currency.symbol}
width={16}
height={16}
w={4}
h={4}
/>
</Flex>
<Text variant="caption" color="white" isTruncated>
<Price amount={drop.unitPrice} currency={drop.currency} />
</Text>
</Stack>
</Flex>
</Flex>
<IconButton
variant="outline"
aria-label="Drop detail"
icon={<Icon as={HiArrowNarrowRight} boxSize={4} />}
placeSelf="flex-end"
color="white"
_hover={{ bg: 'whiteAlpha.200' }}
/>
</Flex>
</Box>
)
}
27 changes: 27 additions & 0 deletions components/Drop/DropDetailSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Flex, Progress, SimpleGrid, Skeleton } from '@chakra-ui/react'
import { FC } from 'react'

type Props = {
items?: number
}

const DropDetailSkeleton: FC<Props> = ({ items = 4 }) => {
return (
<>
<Flex flexDirection="column" py={8} gap={2} width="full">
<Flex justifyContent="space-between" py={2} w="full">
<Skeleton height="1em" width="100px" />
<Skeleton height="1em" width="100px" />
</Flex>
<Progress colorScheme="brand" rounded="full" size="xs" value={0} />
</Flex>
<SimpleGrid columns={{ base: 1, md: 2 }} spacing={4} width="full">
{Array.from({ length: items }).map((_, i) => (
<Skeleton key={i} height={28} borderRadius="2xl" />
))}
</SimpleGrid>
</>
)
}

export default DropDetailSkeleton
Loading