forked from tqtezos/minter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request tqtezos#117 from tqtezos/alex-kooper/asset-details
Adding asset details page base
- Loading branch information
Showing
13 changed files
with
349 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** @jsx jsx */ | ||
import { FC } from 'react'; | ||
import { jsx } from '@emotion/core'; | ||
import { Space, Button } from 'antd'; | ||
|
||
import { ParamName } from './Typography'; | ||
|
||
const Actions: FC = () => ( | ||
<Space size="middle" direction="vertical"> | ||
<div> | ||
<ParamName>STATUS: </ParamName> | ||
<ParamName css={{ fontWeight: 'bold', color: 'red' }}> | ||
NOT FOR SALE | ||
</ParamName> | ||
</div> | ||
|
||
<Button type="primary" shape="round" size="large" css={{ width: '10em' }}> | ||
List For Sale | ||
</Button> | ||
</Space> | ||
); | ||
|
||
export default Actions; |
50 changes: 50 additions & 0 deletions
50
client/src/components/AssetDetailsPage/AssetDescription.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,50 @@ | ||
/** @jsx jsx */ | ||
import url from 'url'; | ||
import { FC, Fragment } from 'react'; | ||
import { jsx } from '@emotion/core'; | ||
|
||
import { Description, ParamName, ParamValue } from './Typography'; | ||
import { NonFungibleToken } from '../../generated/graphql_schema'; | ||
import { Skeleton } from 'antd'; | ||
import config from '../../config'; | ||
|
||
const AssetDescription: FC<{ nft?: NonFungibleToken }> = ({ nft }) => ( | ||
<Fragment> | ||
{!nft ? ( | ||
<Skeleton title={false} paragraph={{ rows: 3 }} /> | ||
) : ( | ||
<Fragment> | ||
<Description>{nft.extras.description}</Description> | ||
|
||
<div> | ||
<ParamName>Type: </ParamName> | ||
<ParamValue>Digital Art</ParamValue> | ||
</div> | ||
|
||
<div> | ||
<ParamName>Collection: </ParamName> | ||
<ParamValue>{nft.contractInfo.name}</ParamValue> | ||
</div> | ||
|
||
<div> | ||
<ParamName>Owner: </ParamName> | ||
|
||
<ParamValue> | ||
<img | ||
src={url.resolve(config.tzktAvatarUrl, nft.owner)} | ||
css={{ width: '2.5em' }} | ||
alt="" | ||
/> | ||
{nft.owner} | ||
</ParamValue> | ||
</div> | ||
|
||
<div css={{ marginTop: '4em' }}> | ||
<ParamName>History: </ParamName> | ||
</div> | ||
</Fragment> | ||
)} | ||
</Fragment> | ||
); | ||
|
||
export default AssetDescription; |
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,37 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const Name = styled.div({ | ||
fontFamily: 'sans-serif', | ||
fontSize: '45px', | ||
lineHeight: '60px', | ||
letterSpacing: '0.75px', | ||
color: 'black' | ||
}); | ||
|
||
export const Description = styled.p({ | ||
fontFamily: 'sans-serif', | ||
fontWeight: 300, | ||
fontSize: '20px', | ||
lineHeight: '30px', | ||
letterSpacing: '0.75px', | ||
color: 'black' | ||
}); | ||
|
||
export const ParamName = styled.span({ | ||
fontFamily: 'sans-serif', | ||
fontWeight: 300, | ||
fontSize: '20px', | ||
lineHeight: '30px', | ||
letterSpacing: '0.75px', | ||
color: 'black' | ||
}); | ||
|
||
export const ParamValue = styled.span({ | ||
fontFamily: 'sans-serif', | ||
fontStyle: 'italic', | ||
fontWeight: 300, | ||
fontSize: '20px', | ||
lineHeight: '30px', | ||
letterSpacing: '0.75px', | ||
color: 'black' | ||
}); |
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,128 @@ | ||
/** @jsx jsx */ | ||
import { FC, Fragment } from 'react'; | ||
import { jsx } from '@emotion/core'; | ||
import { Row, Col, Spin, Skeleton, Alert as AntdAlert } from 'antd'; | ||
import { Flip, AttentionSeeker } from 'react-awesome-reveal'; | ||
|
||
import Page from '../Page'; | ||
import { BackButtonRow } from '../common/PageTitle'; | ||
import { Name } from './Typography'; | ||
import AssetDescription from './AssetDescription'; | ||
import Actions from './Actions'; | ||
import { useNftsQuery } from '../common/useNftsQuery'; | ||
import { NonFungibleToken } from '../../generated/graphql_schema'; | ||
import { urlFromCid } from '../../api/ipfsUploader'; | ||
import { useWalletAddress } from '../App/globalContext'; | ||
import NotConnectedAlert from '../common/NotConnectedAlert'; | ||
|
||
const Image: FC<{ nft?: NonFungibleToken }> = ({ nft }) => { | ||
return ( | ||
<Fragment> | ||
{!nft ? ( | ||
<Skeleton.Image | ||
css={{ | ||
display: 'flex', | ||
flex: 1, | ||
width: '70%', | ||
padding: '1em', | ||
border: 'solid 1px' | ||
}} | ||
/> | ||
) : ( | ||
<div css={{ width: '70%', padding: '1em', border: 'solid 1px' }}> | ||
<Flip key={nft.extras.ipfs_cid}> | ||
<img | ||
css={{ width: '100%' }} | ||
src={urlFromCid(nft.extras.ipfs_cid)} | ||
alt="" | ||
/> | ||
</Flip> | ||
</div> | ||
)} | ||
</Fragment> | ||
); | ||
}; | ||
|
||
const AssetDetails: FC<{ nft?: NonFungibleToken }> = ({ nft }) => ( | ||
<Row> | ||
<Col offset={3} span={18}> | ||
<Row> | ||
<Col offset={12} span={12}> | ||
{nft ? <Name>{nft.name}</Name> : <Skeleton paragraph={false} />} | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col span={12}> | ||
<Image nft={nft} /> | ||
</Col> | ||
<Col span={12}> | ||
<AssetDescription nft={nft} /> | ||
</Col> | ||
</Row> | ||
<Row> | ||
<Col offset={12} span={12}> | ||
<Actions /> | ||
</Col> | ||
</Row> | ||
</Col> | ||
</Row> | ||
); | ||
|
||
const Alert: FC<{ message: string; description: string }> = ({ | ||
message, | ||
description | ||
}) => ( | ||
<AttentionSeeker effect="headShake"> | ||
<AntdAlert | ||
css={{ marginTop: '3em', marginBottom: '3em', width: '50em' }} | ||
type="error" | ||
message={message} | ||
description={description} | ||
showIcon | ||
/> | ||
</AttentionSeeker> | ||
); | ||
interface Props { | ||
contractAddress: string; | ||
tokenId: number; | ||
} | ||
|
||
export const PageBody: FC<Props> = ({ contractAddress, tokenId }) => { | ||
const walletAddress = useWalletAddress(); | ||
const { data, error, loading } = useNftsQuery(contractAddress); | ||
const nft = data?.nfts.find(t => t.tokenId === tokenId); | ||
|
||
if (!walletAddress) | ||
return ( | ||
<NotConnectedAlert | ||
message="Cannot show asset details!" | ||
description="To see your asset details please connect to your wallet first." | ||
/> | ||
); | ||
|
||
if (error) | ||
return <Alert message="GraphQL Error!" description={error.toString()} />; | ||
|
||
if (data && !nft) | ||
return ( | ||
<Alert | ||
message="GraphQL Error!" | ||
description={`Cannot find token ${tokenId} in contract ${contractAddress}`} | ||
/> | ||
); | ||
|
||
return ( | ||
<Spin spinning={loading} size="large"> | ||
<AssetDetails nft={nft} /> | ||
</Spin> | ||
); | ||
}; | ||
|
||
const AssetDetailsPage: FC<Props> = ({ contractAddress, tokenId }) => ( | ||
<Page> | ||
<BackButtonRow onClick={() => window.history.back()} /> | ||
<PageBody contractAddress={contractAddress} tokenId={tokenId} /> | ||
</Page> | ||
); | ||
|
||
export default AssetDetailsPage; |
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
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
Oops, something went wrong.