Skip to content

Commit b680317

Browse files
authored
Merge pull request #120 from enkryptcom/ui/nft-detail-update
UI/nft detail update
2 parents 12e4977 + 86eb3df commit b680317

4 files changed

Lines changed: 112 additions & 22 deletions

File tree

packages/extension/src/ui/action/components/base-search/index.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const textValue = computed({
5959
@import "~@action/styles/theme.less";
6060
6161
.app-search {
62-
background: @gray01;
62+
background: transparent;
6363
border-radius: 10px;
6464
margin: 17px 0 8px 0;
6565
height: 40px;
@@ -68,9 +68,10 @@ const textValue = computed({
6868
padding-left: 40px;
6969
padding-right: 40px;
7070
box-sizing: border-box;
71+
border: 1px solid @gray02;
7172
7273
&.border {
73-
border: 1px solid rgba(0, 0, 0, 0.1);
74+
border: 1px solid @gray02 !important;
7475
box-shadow: none !important;
7576
margin: 0;
7677
background: @white;
@@ -80,6 +81,7 @@ const textValue = computed({
8081
background: @white;
8182
box-shadow: 0px 0.25px 1px rgba(0, 0, 0, 0.039),
8283
0px 0.85px 3px rgba(0, 0, 0, 0.19);
84+
border-color: @white;
8385
}
8486
8587
&__icon {
@@ -94,7 +96,7 @@ const textValue = computed({
9496
font-style: normal;
9597
font-weight: normal;
9698
font-size: 14px;
97-
line-height: 40px;
99+
line-height: 38px;
98100
letter-spacing: 0.25px;
99101
background: none;
100102
color: @primaryLabel;
@@ -103,6 +105,10 @@ const textValue = computed({
103105
&.border {
104106
line-height: 38px;
105107
}
108+
109+
&::placeholder {
110+
color: @tertiaryLabel;
111+
}
106112
}
107113
108114
&__clear {

packages/extension/src/ui/action/views/network-nfts/components/network-nfts-item.vue

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div class="network-nfts__item" @mouseleave="closeMoreMenu">
3-
<a class="network-nfts__item-image" @click="toggleDetail">
3+
<a class="network-nfts__item-image" @click="detailClicked">
44
<img :src="item.image" alt="" @error="imageLoadError" />
55
<div class="network-nfts__item-name">{{ item.name }}</div>
66
</a>
@@ -17,13 +17,6 @@
1717
@update:hide-me="toggleMoreMenu"
1818
@mouseleave="toggleMoreMenu"
1919
/>
20-
21-
<nft-detail-view
22-
v-if="isDetail"
23-
:item="item"
24-
:link-action="openLink"
25-
@close:popup="toggleDetail"
26-
/>
2720
</div>
2821
</template>
2922

@@ -32,13 +25,11 @@ import { ref } from "vue";
3225
import { NFTItem } from "@/types/nft";
3326
import { PropType } from "vue";
3427
import NetworkNftsItemMoreMenu from "./network-nfts-item-more-menu.vue";
35-
import NftDetailView from "@action/views/nft-detail-view/index.vue";
3628
const notfoundimg = require("@action/assets/common/not-found.jpg");
3729
const imageLoadError = (img: any) => {
3830
img.target.src = notfoundimg;
3931
};
4032
const isOpenMore = ref(false);
41-
const isDetail = ref(false);
4233
const props = defineProps({
4334
item: {
4435
type: Object as PropType<NFTItem>,
@@ -59,18 +50,18 @@ const props = defineProps({
5950
},
6051
},
6152
});
53+
const emit = defineEmits<{
54+
(e: "update:toggleDetail", item: NFTItem | null): void;
55+
}>();
56+
const detailClicked = () => {
57+
emit("update:toggleDetail", props.item);
58+
};
6259
const toggleMoreMenu = () => {
6360
isOpenMore.value = !isOpenMore.value;
6461
};
6562
const closeMoreMenu = () => {
6663
isOpenMore.value = false;
6764
};
68-
const toggleDetail = () => {
69-
isDetail.value = !isDetail.value;
70-
};
71-
const openLink = () => {
72-
window.open(props.item.url, "_blank");
73-
};
7465
</script>
7566

7667
<style lang="less">

packages/extension/src/ui/action/views/network-nfts/index.vue

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@
1111
:favorites="favoriteNFTs"
1212
@update:fav-clicked="favClicked"
1313
@update:hide-clicked="hideClicked"
14+
@update:toggle-detail="toggleDetail"
1415
/>
1516
<network-nfts-category
1617
v-for="(item, index) in NFTs"
1718
:key="index"
1819
:collection="item"
1920
@update:fav-clicked="favClicked"
2021
@update:hide-clicked="hideClicked"
22+
@update:toggle-detail="toggleDetail"
2123
/>
2224
<network-nfts-hidden
2325
v-if="hiddenNFTs.length"
2426
:hiddens="hiddenNFTs"
2527
@update:fav-clicked="favClicked"
2628
@update:hide-clicked="hideClicked"
29+
@update:toggle-detail="toggleDetail"
2730
/>
2831
</div>
2932
</custom-scrollbar>
@@ -32,6 +35,17 @@
3235
v-if="!NFTs.length && !favoriteNFTs.length && !hiddenNFTs.length"
3336
:is-empty="isNoNFTs"
3437
/>
38+
39+
<nft-detail-view
40+
v-if="!!detailNFT"
41+
:item="detailNFT"
42+
:is-favorite="isFavorite"
43+
:link-action="openLink"
44+
v-bind="$attrs"
45+
@close:popup="toggleDetail(null)"
46+
@update:fav-clicked="favClicked"
47+
@update:hide-clicked="hideClicked"
48+
/>
3549
</div>
3650
</template>
3751

@@ -42,12 +56,13 @@ import NetworkNftsCategory from "./components/network-nfts-category.vue";
4256
import NetworkNftsFavorite from "./components/network-nfts-favorite.vue";
4357
import NetworkNftsHidden from "./components/network-nfts-hidden.vue";
4458
import NetworkNftsEmpty from "./components/network-nfts-empty.vue";
45-
import { onMounted, PropType, ref, watch } from "vue";
59+
import { onMounted, PropType, ref, watch, computed } from "vue";
4660
import { NodeType } from "@/types/provider";
4761
import { AccountsHeaderData } from "../../types/account";
4862
import { NFTCollection, NFTItem } from "@/types/nft";
4963
import NFTState from "@/libs/nft-state";
5064
import scrollSettings from "@/libs/utils/scroll-settings";
65+
import NftDetailView from "@action/views/nft-detail-view/index.vue";
5166
5267
const nftState = new NFTState();
5368
const props = defineProps({
@@ -64,6 +79,7 @@ const NFTs = ref<NFTCollection[]>([]);
6479
const favoriteNFTs = ref<NFTItem[]>([]);
6580
const hiddenNFTs = ref<NFTItem[]>([]);
6681
const liveNFTCollection = ref<NFTCollection[]>([]);
82+
const detailNFT = ref<NFTItem | null>(null);
6783
const isNoNFTs = ref(false);
6884
6985
watch([props.accountInfo, props.network], () => {
@@ -137,6 +153,19 @@ const hideClicked = async (isHidden: boolean, item: NFTItem) => {
137153
}
138154
localUpdate();
139155
};
156+
const toggleDetail = (item: NFTItem | null) => {
157+
detailNFT.value = item;
158+
};
159+
const openLink = () => {
160+
if (detailNFT.value) window.open(detailNFT.value.url, "_blank");
161+
};
162+
const isFavorite = computed(() => {
163+
if (detailNFT.value && favoriteNFTs.value.length) {
164+
return favoriteNFTs.value.includes(detailNFT.value);
165+
}
166+
167+
return false;
168+
});
140169
</script>
141170

142171
<style lang="less" scoped>

packages/extension/src/ui/action/views/nft-detail-view/index.vue

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@
66
<close-icon />
77
</a>
88

9+
<a class="nft-detail-view__favorite" @click="favClicked(!isFavorite)">
10+
<nft-more-add-to-favorite v-if="!isFavorite" />
11+
<nft-more-delete-from-favorite v-else />
12+
</a>
13+
14+
<notification
15+
v-if="isFavoriteAction"
16+
:hide="toggleNotification"
17+
:text="isFavorite ? 'Added to favorites' : 'Removed from favorites'"
18+
class="nft-detail-view__notification"
19+
/>
20+
921
<h3>{{ item.name.length > 0 ? item.name : "NFT #" + item.id }}</h3>
1022
<img :src="item.image" alt="" @error="imageLoadError" />
1123

@@ -17,16 +29,23 @@
1729
</template>
1830

1931
<script setup lang="ts">
20-
import { PropType } from "vue";
32+
import { PropType, ref, onUpdated, onMounted } from "vue";
2133
import CloseIcon from "@action/icons/common/close-icon.vue";
2234
import ActionMenu from "@action/components/action-menu/index.vue";
35+
import NftMoreAddToFavorite from "@action/icons/nft/nft-more-add-to-favorite.vue";
36+
import NftMoreDeleteFromFavorite from "@action/icons/nft/nft-more-delete-from-favorite.vue";
2337
import { NFTItem } from "@/types/nft";
38+
import Notification from "@action/components/notification/index.vue";
39+
2440
const notfoundimg = require("@action/assets/common/not-found.jpg");
2541
const imageLoadError = (img: any) => {
2642
img.target.src = notfoundimg;
2743
};
2844
29-
defineProps({
45+
const isFavoriteAction = ref(false);
46+
const isFavorite = ref(false);
47+
48+
const props = defineProps({
3049
item: {
3150
type: Object as PropType<NFTItem>,
3251
default: () => {
@@ -37,14 +56,36 @@ defineProps({
3756
type: Function as PropType<() => void>,
3857
default: () => ({}),
3958
},
59+
isFavorite: {
60+
type: Boolean,
61+
default: () => {
62+
return false;
63+
},
64+
},
65+
});
66+
67+
onMounted(() => {
68+
isFavorite.value = props.isFavorite;
4069
});
4170
4271
const emit = defineEmits<{
4372
(e: "close:popup"): void;
73+
(e: "update:favClicked", isFav: boolean, item: NFTItem): void;
4474
}>();
4575
const close = () => {
4676
emit("close:popup");
4777
};
78+
const favClicked = (isFav: boolean) => {
79+
emit("update:favClicked", isFav, props.item);
80+
isFavorite.value = isFav;
81+
82+
setTimeout(() => {
83+
toggleNotification();
84+
}, 100);
85+
};
86+
const toggleNotification = () => {
87+
isFavoriteAction.value = !isFavoriteAction.value;
88+
};
4889
</script>
4990

5091
<style lang="less">
@@ -126,9 +167,32 @@ const close = () => {
126167
}
127168
}
128169
170+
&__favorite {
171+
position: absolute;
172+
top: 8px;
173+
right: 48px;
174+
border-radius: 8px;
175+
cursor: pointer;
176+
transition: background 300ms ease-in-out;
177+
font-size: 0;
178+
padding: 8px;
179+
180+
&:hover {
181+
background: @black007;
182+
}
183+
}
184+
129185
&__action {
130186
margin: 0;
131187
width: 100%;
132188
}
189+
190+
&__notification {
191+
position: absolute;
192+
left: 50%;
193+
transform: translateX(-50%) translateY(0px);
194+
top: 76px;
195+
z-index: 141;
196+
}
133197
}
134198
</style>

0 commit comments

Comments
 (0)