Commit b903406f authored by isstuev's avatar isstuev

design changes

parent ff1463e2
...@@ -21,10 +21,11 @@ import QRCode from 'qrcode'; ...@@ -21,10 +21,11 @@ import QRCode from 'qrcode';
import React from 'react'; import React from 'react';
import type { Address as AddressType } from 'types/api/address'; import type { Address as AddressType } from 'types/api/address';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import qrCodeIcon from 'icons/qr_code.svg'; import qrCodeIcon from 'icons/qr_code.svg';
import getPageType from 'lib/mixpanel/getPageType'; import getPageType from 'lib/mixpanel/getPageType';
import * as mixpanel from 'lib/mixpanel/index'; import * as mixpanel from 'lib/mixpanel/index';
import AddressEntity from 'ui/shared/entities/address/AddressEntity';
const SVG_OPTIONS = { const SVG_OPTIONS = {
margin: 0, margin: 0,
...@@ -101,7 +102,6 @@ const AddressQrCode = ({ address, className, isLoading }: Props) => { ...@@ -101,7 +102,6 @@ const AddressQrCode = ({ address, className, isLoading }: Props) => {
<ModalBody mb={ 0 }> <ModalBody mb={ 0 }>
<AddressEntity <AddressEntity
mb={ 3 } mb={ 3 }
fontSize="md"
fontWeight={ 500 } fontWeight={ 500 }
color="text" color="text"
address={ address } address={ address }
......
import { Flex, Link, Text, LinkBox, LinkOverlay, useColorModeValue, Skeleton } from '@chakra-ui/react'; import { Box, Flex, Link, Text, useColorModeValue, Skeleton } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import type { AddressTokenBalance } from 'types/api/address'; import type { AddressTokenBalance } from 'types/api/address';
...@@ -12,27 +12,26 @@ import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip'; ...@@ -12,27 +12,26 @@ import TruncatedTextTooltip from 'ui/shared/TruncatedTextTooltip';
type Props = AddressTokenBalance & { isLoading: boolean }; type Props = AddressTokenBalance & { isLoading: boolean };
const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLoading }: Props) => { const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLoading }: Props) => {
const tokenLink = route({ pathname: '/token/[hash]', query: { hash: token.address } }); const tokenInstanceLink = tokenId ? route({ pathname: '/token/[hash]/instance/[id]', query: { hash: token.address, id: tokenId } }) : undefined;
return ( return (
<LinkBox <Box
w={{ base: '100%', lg: '210px' }} w={{ base: '100%', lg: '210px' }}
border="1px solid" border="1px solid"
borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') } borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') }
borderRadius="12px" borderRadius="12px"
p="10px" p="10px"
_hover={{ boxShadow: 'md' }}
fontSize="sm" fontSize="sm"
fontWeight={ 500 } fontWeight={ 500 }
lineHeight="20px" lineHeight="20px"
> >
<LinkOverlay href={ isLoading ? undefined : tokenLink }> <Link href={ isLoading ? undefined : tokenInstanceLink }>
<NftMedia <NftMedia
mb="18px" mb="18px"
url={ tokenInstance?.animation_url || tokenInstance?.image_url || null } url={ tokenInstance?.animation_url || tokenInstance?.image_url || null }
isLoading={ isLoading } isLoading={ isLoading }
/> />
</LinkOverlay> </Link>
{ tokenId && ( { tokenId && (
<Flex mb={ 2 } ml={ 1 }> <Flex mb={ 2 } ml={ 1 }>
<Text whiteSpace="pre" variant="secondary">ID# </Text> <Text whiteSpace="pre" variant="secondary">ID# </Text>
...@@ -44,7 +43,7 @@ const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLo ...@@ -44,7 +43,7 @@ const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLo
whiteSpace="nowrap" whiteSpace="nowrap"
textOverflow="ellipsis" textOverflow="ellipsis"
overflow="hidden" overflow="hidden"
href={ route({ pathname: '/token/[hash]/instance/[id]', query: { hash: token.address, id: tokenId } }) } href={ tokenInstanceLink }
> >
{ tokenId } { tokenId }
</Link> </Link>
...@@ -58,7 +57,7 @@ const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLo ...@@ -58,7 +57,7 @@ const NFTItem = ({ token, token_id: tokenId, token_instance: tokenInstance, isLo
noCopy noCopy
noSymbol noSymbol
/> />
</LinkBox> </Box>
); );
}; };
......
import { Icon, useColorModeValue } from '@chakra-ui/react'; import { Icon, useColorModeValue, chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import nftIcon from 'icons/nft_shield.svg'; import nftIcon from 'icons/nft_shield.svg';
const NftFallback = () => { const NftFallback = ({ className }: {className?: string}) => {
return ( return (
<Icon <Icon
className={ className }
as={ nftIcon } as={ nftIcon }
p="50px" p="50px"
color={ useColorModeValue('blackAlpha.500', 'whiteAlpha.500') } color={ useColorModeValue('blackAlpha.500', 'whiteAlpha.500') }
...@@ -14,4 +15,4 @@ const NftFallback = () => { ...@@ -14,4 +15,4 @@ const NftFallback = () => {
); );
}; };
export default NftFallback; export default chakra(NftFallback);
...@@ -20,7 +20,7 @@ const NftImageWithFullscreen = ({ src, onLoad, onError }: Props) => { ...@@ -20,7 +20,7 @@ const NftImageWithFullscreen = ({ src, onLoad, onError }: Props) => {
<> <>
<NftImage src={ src } onLoad={ onLoad } onError={ onError } onClick={ onOpen }/> <NftImage src={ src } onLoad={ onLoad } onError={ onError } onClick={ onOpen }/>
<NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }> <NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }>
<Image src={ src } alt="Token instance image" maxH="90vh" w="100%" maxW="90vw"/> <Image src={ src } alt="Token instance image" maxH="90vh" maxW="90vw"/>
</NftMediaFullscreenModal> </NftMediaFullscreenModal>
</> </>
); );
......
...@@ -10,6 +10,7 @@ import NftImageWithFullscreen from './NftImageWithFullscreen'; ...@@ -10,6 +10,7 @@ import NftImageWithFullscreen from './NftImageWithFullscreen';
import NftVideo from './NftVideo'; import NftVideo from './NftVideo';
import NftVideoWithFullscreen from './NftVideoWithFullscreen'; import NftVideoWithFullscreen from './NftVideoWithFullscreen';
import useNftMediaType from './useNftMediaType'; import useNftMediaType from './useNftMediaType';
import { mediaStyleProps } from './utils';
interface Props { interface Props {
url: string | null; url: string | null;
...@@ -23,6 +24,7 @@ const NftMedia = ({ url, className, isLoading, withFullscreen }: Props) => { ...@@ -23,6 +24,7 @@ const NftMedia = ({ url, className, isLoading, withFullscreen }: Props) => {
const [ isLoadingError, setIsLoadingError ] = React.useState(false); const [ isLoadingError, setIsLoadingError ] = React.useState(false);
const { ref, inView } = useInView({ triggerOnce: true }); const { ref, inView } = useInView({ triggerOnce: true });
const type = useNftMediaType(url, !isLoading && inView); const type = useNftMediaType(url, !isLoading && inView);
const handleMediaLoaded = React.useCallback(() => { const handleMediaLoaded = React.useCallback(() => {
...@@ -36,7 +38,8 @@ const NftMedia = ({ url, className, isLoading, withFullscreen }: Props) => { ...@@ -36,7 +38,8 @@ const NftMedia = ({ url, className, isLoading, withFullscreen }: Props) => {
const content = (() => { const content = (() => {
if (!url || isLoadingError) { if (!url || isLoadingError) {
return <NftFallback/>; const styleProps = withFullscreen ? {} : mediaStyleProps;
return <NftFallback { ...styleProps }/>;
} }
const props = { const props = {
......
...@@ -17,7 +17,7 @@ const NftMediaFullscreenModal = ({ isOpen, onClose, children }: Props) => { ...@@ -17,7 +17,7 @@ const NftMediaFullscreenModal = ({ isOpen, onClose, children }: Props) => {
<Modal isOpen={ isOpen } onClose={ onClose } motionPreset="none"> <Modal isOpen={ isOpen } onClose={ onClose } motionPreset="none">
<ModalOverlay/> <ModalOverlay/>
<ModalContent w="unset" maxW="100vw" p={ 0 }> <ModalContent w="unset" maxW="100vw" p={ 0 }>
<ModalCloseButton position="fixed" color="whiteAlpha.800"/> <ModalCloseButton position="fixed" top={{ base: 2.5, lg: 8 }} right={{ base: 2.5, lg: 8 }} color="whiteAlpha.800"/>
{ children } { children }
</ModalContent> </ModalContent>
</Modal> </Modal>
......
import { chakra } from '@chakra-ui/react'; import { chakra } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { mediaStyleProps } from './utils'; import { mediaStyleProps, videoPlayProps } from './utils';
interface Props { interface Props {
src: string; src: string;
...@@ -13,12 +13,8 @@ interface Props { ...@@ -13,12 +13,8 @@ interface Props {
const NftVideo = ({ src, onLoad, onError, onClick }: Props) => { const NftVideo = ({ src, onLoad, onError, onClick }: Props) => {
return ( return (
<chakra.video <chakra.video
{ ...videoPlayProps }
src={ src } src={ src }
autoPlay
disablePictureInPicture
loop
muted
playsInline
onCanPlayThrough={ onLoad } onCanPlayThrough={ onLoad }
onError={ onError } onError={ onError }
borderRadius="md" borderRadius="md"
......
...@@ -6,6 +6,7 @@ import React from 'react'; ...@@ -6,6 +6,7 @@ import React from 'react';
import NftMediaFullscreenModal from './NftMediaFullscreenModal'; import NftMediaFullscreenModal from './NftMediaFullscreenModal';
import NftVideo from './NftVideo'; import NftVideo from './NftVideo';
import { videoPlayProps } from './utils';
interface Props { interface Props {
src: string; src: string;
...@@ -21,12 +22,8 @@ const NftVideoWithFullscreen = ({ src, onLoad, onError }: Props) => { ...@@ -21,12 +22,8 @@ const NftVideoWithFullscreen = ({ src, onLoad, onError }: Props) => {
<NftVideo src={ src } onLoad={ onLoad } onError={ onError } onClick={ onOpen }/> <NftVideo src={ src } onLoad={ onLoad } onError={ onError } onClick={ onOpen }/>
<NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }> <NftMediaFullscreenModal isOpen={ isOpen } onClose={ onClose }>
<chakra.video <chakra.video
{ ...videoPlayProps }
src={ src } src={ src }
autoPlay
disablePictureInPicture
loop
muted
playsInline
onCanPlayThrough={ onLoad } onCanPlayThrough={ onLoad }
onError={ onError } onError={ onError }
maxH="90vh" maxH="90vh"
......
...@@ -39,3 +39,11 @@ export const mediaStyleProps = { ...@@ -39,3 +39,11 @@ export const mediaStyleProps = {
}, },
}, },
}; };
export const videoPlayProps = {
autoPlay: true,
disablePictureInPicture: true,
loop: true,
muted: true,
playsInline: true,
};
import { Flex, Text, LinkBox, LinkOverlay, useColorModeValue, Skeleton } from '@chakra-ui/react'; import { Box, Flex, Text, Link, useColorModeValue, Skeleton } from '@chakra-ui/react';
import NextLink from 'next/link';
import React from 'react'; import React from 'react';
import type { TokenInstance } from 'types/api/token'; import type { TokenInstance } from 'types/api/token';
import { route } from 'nextjs-routes';
import useIsMobile from 'lib/hooks/useIsMobile'; import useIsMobile from 'lib/hooks/useIsMobile';
import AddressEntity from 'ui/shared/entities/address/AddressEntity'; import AddressEntity from 'ui/shared/entities/address/AddressEntity';
import LinkInternal from 'ui/shared/LinkInternal'; import LinkInternal from 'ui/shared/LinkInternal';
...@@ -24,29 +25,22 @@ const NFTItem = ({ item, isLoading }: Props) => { ...@@ -24,29 +25,22 @@ const NFTItem = ({ item, isLoading }: Props) => {
/> />
); );
const url = route({ pathname: '/token/[hash]/instance/[id]', query: { hash: item.token.address, id: item.id } });
return ( return (
<LinkBox <Box
w={{ base: '100%', lg: '210px' }} w={{ base: '100%', lg: '210px' }}
border="1px solid" border="1px solid"
borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') } borderColor={ useColorModeValue('blackAlpha.100', 'whiteAlpha.200') }
borderRadius="12px" borderRadius="12px"
p="10px" p="10px"
_hover={{ boxShadow: isLoading ? 'none' : 'md' }}
fontSize="sm" fontSize="sm"
fontWeight={ 500 } fontWeight={ 500 }
lineHeight="20px" lineHeight="20px"
> >
{ isLoading ? mediaElement : ( <Link href={ isLoading ? undefined : url }>
<NextLink { mediaElement }
href={{ pathname: '/token/[hash]/instance/[id]', query: { hash: item.token.address, id: item.id } }} </Link>
passHref
legacyBehavior
>
<LinkOverlay>
{ mediaElement }
</LinkOverlay>
</NextLink>
) }
{ item.id && ( { item.id && (
<Flex mb={ 2 } ml={ 1 }> <Flex mb={ 2 } ml={ 1 }>
<Text whiteSpace="pre" variant="secondary">ID# </Text> <Text whiteSpace="pre" variant="secondary">ID# </Text>
...@@ -58,6 +52,7 @@ const NFTItem = ({ item, isLoading }: Props) => { ...@@ -58,6 +52,7 @@ const NFTItem = ({ item, isLoading }: Props) => {
whiteSpace="nowrap" whiteSpace="nowrap"
display="block" display="block"
isLoading={ isLoading } isLoading={ isLoading }
href={ url }
> >
{ item.id } { item.id }
</LinkInternal> </LinkInternal>
...@@ -77,7 +72,7 @@ const NFTItem = ({ item, isLoading }: Props) => { ...@@ -77,7 +72,7 @@ const NFTItem = ({ item, isLoading }: Props) => {
/> />
</Flex> </Flex>
) } ) }
</LinkBox> </Box>
); );
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment