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

[TAS-2320] 🚸 Add loading placeholder for <itemCard/> #1896

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 23 additions & 8 deletions src/components/NFTBook/ItemCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,18 @@
v-if="!isCompactPreset && !isDetailsPreset"
class="flex justify-between px-[8px] sm:px-[24px] mt-[20px]"
>
<div v-if="nftBookAvailablePriceLabel">
<Label
preset="p5"
class="text-like-green-dark"
:text="nftBookAvailablePriceLabel"
/>
</div>
<Label
v-if="isLoading"
preset="p5"
class="text-medium-gray"
:text="$t('nft_details_page_label_item_loading')"
/>
<Label
v-else-if="nftBookAvailablePriceLabel"
preset="p5"
class="text-like-green-dark"
:text="nftBookAvailablePriceLabel"
/>
<Label
v-else
preset="p5"
Expand Down Expand Up @@ -308,6 +313,11 @@ export default {
default: '',
},
},
data() {
return {
isLoading: false,
};
},
computed: {
creatorDisplayName() {
return (
Expand Down Expand Up @@ -424,7 +434,12 @@ export default {
},
methods: {
async fetchInfo() {
await this.lazyFetchNFTClassAggregatedData();
this.isLoading = true;
try {
await this.lazyFetchNFTClassAggregatedData();
} finally {
this.isLoading = false;
}
},
onClickAvatar() {
this.$emit('click-avatar', this.iscnOwner);
Expand Down
27 changes: 22 additions & 5 deletions src/components/NFTBook/ItemCardV2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>

<div class="mt-[16px] text-[#1F1F1F] text-[0.875rem] laptop:text-[1rem]">
{{ productAvailablePriceLabel || $t('nft_details_page_label_sold_out') }}
{{ priceLabel }}
</div>
</div>
</template>
Expand Down Expand Up @@ -68,6 +68,11 @@ export default {
default: true,
},
},
data() {
return {
isLoading: false,
};
},
computed: {
classId() {
return this.itemId.startsWith('likenft1') ? this.itemId : '';
Expand All @@ -81,16 +86,28 @@ export default {
this.productOwner
);
},
priceLabel() {
if (this.isLoading) return this.$t('nft_details_page_label_item_loading');
return (
this.productAvailablePriceLabel ||
this.$t('nft_details_page_label_sold_out')
);
},
},
mounted() {
if (!this.isLazyLoaded) this.fetchInfo();
},
methods: {
async fetchInfo() {
if (this.isCollection) {
await this.lazyFetchNFTCollectionInfo();
} else {
await this.lazyFetchNFTClassAggregatedData();
this.isLoading = true;
try {
if (this.isCollection) {
await this.lazyFetchNFTCollectionInfo();
} else {
await this.lazyFetchNFTClassAggregatedData();
}
} finally {
this.isLoading = false;
}
},
},
Expand Down
31 changes: 23 additions & 8 deletions src/components/NFTCollection/ItemCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,18 @@
class="flex justify-between px-[8px] sm:px-[24px] mt-[20px]"
>
<template v-if="!isDetailsPreset">
<div v-if="collectionAvailablePriceLabel">
<Label
preset="p5"
class="text-like-green-dark"
:text="collectionAvailablePriceLabel"
/>
</div>
<Label
v-if="isLoading"
preset="p5"
class="text-medium-gray"
:text="$t('nft_details_page_label_item_loading')"
/>
<Label
v-else-if="collectionAvailablePriceLabel"
preset="p5"
class="text-like-green-dark"
:text="collectionAvailablePriceLabel"
/>
<Label
v-else
preset="p5"
Expand Down Expand Up @@ -232,6 +237,11 @@ export default {
default: '',
},
},
data() {
return {
isLoading: false,
};
},
computed: {
...mapGetters(['getIsHideNFTBookDownload']),
creatorDisplayName() {
Expand Down Expand Up @@ -339,7 +349,12 @@ export default {
},
methods: {
async fetchInfo() {
await this.lazyFetchNFTCollectionInfo();
try {
this.isLoading = true;
await this.lazyFetchNFTCollectionInfo();
} finally {
this.isLoading = false;
}
},
onClickAvatar() {
this.$emit('click-avatar', this.collectionOwner);
Expand Down
1 change: 1 addition & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@
"nft_details_page_label_ar_view_in_mobile": "Experience your NFT live",
"nft_details_page_label_class_page": "View all events from this content",
"nft_details_page_label_content_types": "FIle Types",
"nft_details_page_label_item_loading": "Loading...",
"nft_details_page_label_loading": "Loading",
"nft_details_page_label_memo": "Enter transfer message",
"nft_details_page_label_nft_id": "NFT ID",
Expand Down
1 change: 1 addition & 0 deletions src/locales/zh-Hant.json
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@
"nft_details_page_label_ar_view_in_mobile": "將你的 NFT 帶到現實",
"nft_details_page_label_class_page": "檢視此系列的其他事件",
"nft_details_page_label_content_types": "檔案類型",
"nft_details_page_label_item_loading": "載入中...",
"nft_details_page_label_loading": "進行中,請稍候⋯⋯",
"nft_details_page_label_memo": "附加留言",
"nft_details_page_label_nft_id": "NFT ID",
Expand Down
Loading