-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
482 additions
and
232 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,186 @@ | ||
<template> | ||
<NuxtLink class="relative block w-[310px]" :to="detailsPageRoute"> | ||
<NFTGemWrapper :is-nft-book="true" :class-id="''"> | ||
<template #default="gem"> | ||
<NFTPortfolioCard | ||
:class="{ 'border-like-collection border-[2px]': collectionId }" | ||
:hover-class="gem.hoverClass" | ||
> | ||
<div | ||
class="relative flex items-center justify-center w-full h-full rounded-t-[inherit]" | ||
> | ||
<NFTBookCoverWithFrame | ||
:class="['w-full', 'rounded-t-[inherit] rounded-b-[0]']" | ||
:src="imageSrc" | ||
:alt="collectionName" | ||
:cover-resize="450" | ||
class-aspect-ratio="aspect-[1]" | ||
/> | ||
</div> | ||
<div | ||
:class="[ | ||
'flex', | ||
'flex-col', | ||
'text-center', | ||
'whitespace-pre-line', | ||
'px-[24px]', | ||
'pt-[48px]', | ||
'py-[24px]', | ||
'bg-white', | ||
'relative', | ||
'rounded-b-[inherit] !rounded-t-[0]', | ||
]" | ||
> | ||
<div class="flex flex-col items-center justify-center mt-[-70px]"> | ||
<Identity | ||
:avatar-url="ownerAvatar" | ||
:avatar-size="40" | ||
:is-lazy-loaded="true" | ||
/> | ||
<Label | ||
class="w-full mt-[8px] text-like-green font-[600]" | ||
content-class="min-w-0" | ||
align="center" | ||
> | ||
<span class="text-medium-gray">by</span> | ||
<span class="truncate">{{ ownerDisplayName }}</span> | ||
</Label> | ||
</div> | ||
<Label preset="h5" class="mt-[12px] break-normal" align="center">{{ | ||
collectionName | ||
}}</Label> | ||
<div class="flex items-center justify-center mt-[16px]"> | ||
<ButtonV2 | ||
preset="secondary" | ||
:text="priceLabel" | ||
:is-disabled="!stock" | ||
@click="handleClickCollect" | ||
> | ||
<template #prepend> | ||
<NFTWidgetIconInsertCoin class="w-[16px]" /> | ||
</template> | ||
</ButtonV2> | ||
</div> | ||
</div> | ||
</NFTPortfolioCard> | ||
</template> | ||
</NFTGemWrapper> | ||
</NuxtLink> | ||
</template> | ||
<script> | ||
import { mapActions, mapGetters } from 'vuex'; | ||
import { formatNumberWithUSD } from '~/util/ui'; | ||
import { parseNFTMetadataURL } from '~/util/nft'; | ||
import collectionMixin from '~/mixins/nft-collection'; | ||
export default { | ||
name: 'NFTBookCollectionItemCard', | ||
props: { | ||
collectionId: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
mixins: [collectionMixin], | ||
Check warning on line 84 in src/components/NFTBook/CollectionItemCard.vue GitHub Actions / Deploy
|
||
data() { | ||
return { | ||
data: null, | ||
}; | ||
}, | ||
computed: { | ||
...mapGetters([ | ||
'getNFTCollectionInfoByCollectionId', | ||
'getUserInfoByAddress', | ||
]), | ||
detailsPageRoute() { | ||
return this.localeLocation({ | ||
name: 'nft-collection-collectionId', | ||
params: { collectionId: this.collectionId }, | ||
}); | ||
}, | ||
// nftCollection() { | ||
// let { locale } = this.$i18n; | ||
// if (locale === 'zh-Hant') { | ||
// locale = 'zh'; | ||
// } | ||
// const defaultLocale = 'en'; | ||
// const collection = this.getNFTCollectionInfoByCollectionId( | ||
// this.collectionId | ||
// ); | ||
// if (collection) { | ||
// let { name, description, image } = collection; | ||
// const { id, priceInDecimal, stock, ownerWallet } = collection; | ||
// const price = priceInDecimal / 100; | ||
// if (typeof name === 'object') { | ||
// name = name[locale] || name[defaultLocale] || ''; | ||
// } | ||
// if (typeof description === 'object') { | ||
// description = description[locale] || description[defaultLocale] || ''; | ||
// } | ||
// const priceLabel = formatNumberWithUSD(price); | ||
// image = parseNFTMetadataURL(image); | ||
// return { | ||
// id, | ||
// name, | ||
// image, | ||
// description, | ||
// priceLabel, | ||
// price, | ||
// value: -1, | ||
// stock, | ||
// ownerWallet, | ||
// }; | ||
// } | ||
// return null; | ||
// }, | ||
priceLabel() { | ||
return this.formattedCollection?.priceLabel; | ||
}, | ||
stock() { | ||
return this.formattedCollection?.stock; | ||
}, | ||
imageSrc() { | ||
return parseNFTMetadataURL(this.formattedCollection?.image); | ||
}, | ||
ownerWallet() { | ||
return this.formattedCollection?.ownerWallet; | ||
}, | ||
ownerDisplayName() { | ||
return ( | ||
this.getUserInfoByAddress(this.ownerWallet)?.displayName || | ||
this.ownerWallet | ||
); | ||
}, | ||
ownerAvatar() { | ||
return this.getUserInfoByAddress(this.ownerWallet)?.avatar; | ||
}, | ||
}, | ||
async mounted() { | ||
try { | ||
const data = await this.lazyFetchNFTCollectionInfoByCollectionId({ | ||
collectionId: this.collectionId, | ||
}); | ||
if (data?.ownerWallet) { | ||
this.lazyGetUserInfoByAddresses(data.ownerWallet); | ||
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(`Error fetching collection info: ${error}`); | ||
} | ||
console.log('collectionId', this.collectionId); | ||
Check warning on line 171 in src/components/NFTBook/CollectionItemCard.vue GitHub Actions / Deploy
|
||
console.log('this.formattedCollection', this.formattedCollection); | ||
Check warning on line 172 in src/components/NFTBook/CollectionItemCard.vue GitHub Actions / Deploy
|
||
}, | ||
methods: { | ||
...mapActions([ | ||
'lazyFetchNFTCollectionInfoByCollectionId', | ||
'lazyGetUserInfoByAddresses', | ||
]), | ||
parseNFTMetadataURL, | ||
handleClickCollect() { | ||
this.$emit('click-collect'); | ||
this.$router.push(this.detailsPageRoute); | ||
}, | ||
}, | ||
}; | ||
</script> |
Oops, something went wrong.