Skip to content

Commit

Permalink
feat: add official site and description on erc 721/1155 pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-CY committed Nov 17, 2022
1 parent 228bd92 commit db0cc62
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 9 deletions.
28 changes: 24 additions & 4 deletions pages/multi-token-collection/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import InventoryList, { fetchInventoryListOfCollection } from 'components/MultiT
import { client, GraphQLSchema } from 'utils'
import styles from './styles.module.scss'

type CollectionInfoProps = Omit<GraphQLSchema.MultiTokenCollectionListItem, 'id' | 'account'> | undefined
type CollectionInfoProps =
| (Omit<GraphQLSchema.MultiTokenCollectionListItem, 'id' | 'account'> &
Record<'description' | 'official_site', string | null>)
| undefined

interface InfoProps {
erc1155_udts: {
Expand All @@ -40,6 +43,8 @@ const infoQuery = gql`
token_type_count
holders_count
minted_count
description
official_site
}
}
}
Expand Down Expand Up @@ -111,10 +116,21 @@ const MultiTokenCollection = () => {
field: t('contract'),
content: <HashLink label={address as string} href={`/account/${address}`} />,
},

{
field: '',
content: <div data-role="placeholder" style={{ height: `1.5rem` }}></div>,
field: t('officialSite'),
content: info ? (
info.official_site ? (
<HashLink label={info.official_site} href={info.official_site} external />
) : (
'-'
)
) : (
<Skeleton animation="wave" />
),
},
{
field: t('description'),
content: info ? info.description || '-' : <Skeleton animation="wave" />,
},
]

Expand All @@ -131,6 +147,10 @@ const MultiTokenCollection = () => {
field: t('holder_count'),
content: isInfoLoading ? <Skeleton animation="wave" /> : (+info?.holders_count ?? 0).toLocaleString('en'),
},
{
field: '',
content: <div data-role="placeholder" style={{ height: `1.5rem` }}></div>,
},
]

const title = t(`multi-token-collection`)
Expand Down
4 changes: 4 additions & 0 deletions pages/multi-token-collection/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
dd {
white-space: breaks-spaces;
word-break: break-all;
text-transform: none;
}

@media screen and (min-width: 1024px) {
Expand All @@ -50,6 +51,9 @@
& > div {
margin-bottom: 1rem;
}
dl[title=''] {
display: none;
}
}
}

Expand Down
29 changes: 28 additions & 1 deletion pages/nft-collection/[address].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import InventoryList, { fetchInventoryListOfCollection } from 'components/NFTInv
import { client, GraphQLSchema } from 'utils'
import styles from './styles.module.scss'

type CollectionInfoProps = Omit<GraphQLSchema.NftCollectionListItem, 'id' | 'account'> | undefined
type CollectionInfoProps =
| (Omit<GraphQLSchema.NftCollectionListItem, 'id' | 'account'> &
Record<'description' | 'official_site', string | null>)
| undefined

interface CollectionProps {
erc721_udts: {
Expand All @@ -39,6 +42,8 @@ const infoQuery = gql`
icon
holders_count
minted_count
description
official_site
}
}
}
Expand Down Expand Up @@ -110,6 +115,22 @@ const NftCollection = () => {
field: t('contract'),
content: <HashLink label={address as string} href={`/account/${address}`} />,
},
{
field: t('officialSite'),
content: info ? (
info.official_site ? (
<HashLink label={info.official_site} href={info.official_site} external />
) : (
'-'
)
) : (
<Skeleton animation="wave" />
),
},
{
field: t('description'),
content: info ? info.description || '-' : <Skeleton animation="wave" />,
},
]

const stats: Array<{ field: string; content: React.ReactNode }> = [
Expand All @@ -121,6 +142,12 @@ const NftCollection = () => {
field: t('minted_count'),
content: isInfoLoading ? <Skeleton animation="wave" /> : (+info?.minted_count ?? 0).toLocaleString('en'),
},
info?.official_site
? {
field: '',
content: <div data-role="placeholder"></div>,
}
: null,
]

const title = t(`nft-collection`)
Expand Down
4 changes: 4 additions & 0 deletions pages/nft-collection/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
dd {
white-space: breaks-spaces;
word-break: break-all;
text-transform: none;
}

@media screen and (min-width: 1024px) {
Expand All @@ -52,6 +53,9 @@
& > div {
margin-bottom: 1rem;
}
dl[title=''] {
display: none;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion public/locales/en-US/multi-token.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"token-id": "Token ID",
"owner": "Owner",
"name": "Name",
"quantity": "Quantity"
"quantity": "Quantity",
"description": "Description",
"officialSite": "Official Site"
}
4 changes: 3 additions & 1 deletion public/locales/en-US/nft.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"erc-721": "ERC 721",
"token-id": "Token ID",
"owner": "Owner",
"name": "Name"
"name": "Name",
"description": "Description",
"officialSite": "Official Site"
}
4 changes: 3 additions & 1 deletion public/locales/zh-CN/multi-token.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@
"token-id": "通证 ID",
"owner": "所属人",
"name": "名称",
"quantity": "数量"
"quantity": "数量",
"description": "简介",
"officialSite": "官方网站"
}
4 changes: 3 additions & 1 deletion public/locales/zh-CN/nft.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@
"erc-721": "ERC 721",
"token-id": "通证 ID",
"owner": "所属人",
"name": "名称"
"name": "名称",
"description": "简介",
"officialSite": "官方网站"
}

0 comments on commit db0cc62

Please sign in to comment.