-
-
Notifications
You must be signed in to change notification settings - Fork 366
/
Copy pathCollectionInfo.vue
175 lines (163 loc) · 5.2 KB
/
CollectionInfo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<template>
<div class="md:flex justify-between">
<div class="max-w-screen-sm">
<CollectionHeroButtons class="is-hidden-tablet" />
<div
v-if="address"
class="flex mb-4"
>
<div
class="rounded-full w-full md:w-auto border border-k-shade flex justify-start px-3"
>
<IdentityItem
:label="$t('activity.creator')"
:prefix="urlPrefix"
:account="address"
class="identity-name-font-weight-regular"
data-testid="collection-creator-address"
/>
</div>
</div>
<div class="mb-4">
<span
v-if="recipient"
class="inline"
>
<span class="capitalize text-neutral-7">{{ $t('royalty') }}</span>
{{ royalty }}%
<tippy
:arrow="true"
placement="bottom"
class="text-neutral-7"
:append-to="body"
>
<NeoIcon
class="w-4 h-4"
icon="info-circle"
/>
<template #content>
<div class="bg-background-color border py-2 px-4 text-xs">
Recipient Address:
<nuxt-link
:to="`/${urlPrefix}/u/${recipient}`"
class="text-k-blue hover:text-k-blue-hover"
>
<IdentityIndex
ref="identity"
:address="recipient"
show-clipboard
/>
</nuxt-link>
</div>
</template>
</tippy>
<span class="text-neutral-5 mx-2">•</span>
</span>
<span v-if="createdAt">
<span class="capitalize text-neutral-7">{{ $t('created') }}</span> {{ new Date(createdAt).toLocaleDateString() }}
<span class="text-neutral-5 mx-2">•</span>
</span>
<span>
<span class="capitalize text-neutral-7">{{
$t('activity.network')
}}</span> {{ chain }}
<span class="text-neutral-5 mx-2">•</span>
</span>
<span>
<span class="capitalize text-neutral-7">{{ $t('supply') }}</span> {{ stats.maxSupply || $t('helper.unlimited') }}
</span>
</div>
<div class="break-words">
<Markdown
:source="visibleDescription"
data-testid="collection-description"
/>
</div>
<NeoButton
v-if="hasSeeAllDescriptionOption"
class="no-shadow is-text underline text-left p-0"
:label="seeAllDescription ? $t('showLess') : $t('showMore')"
data-testid="description-show-less-more-button"
@click="toggleSeeAllDescription"
/>
</div>
<div class="w-full lg:w-72 pt-4">
<CollectionInfoLine :title="$t('activity.floor')">
<CommonTokenMoney
:value="stats.collectionFloorPrice"
inline
:round="2"
/>
</CollectionInfoLine>
<CollectionInfoLine :title="$t('activity.volume')">
<CommonTokenMoney
:value="stats.collectionTradedVolumeNumber"
inline
:round="2"
/>
</CollectionInfoLine>
<CollectionInfoLine
:title="$t('series.owners')"
:value="stats.uniqueOwners"
/>
<CollectionInfoLine :title="$t('activity.listedAndMinted')">
<span class="text-xs text-neutral-7 leading-6 font-normal mr-2">{{
Boolean(stats.collectionLength)
? Math.floor(
(Number(stats.listedCount) / Number(stats.collectionLength))
* 100,
) + '%'
: '-'
}}</span>
{{ stats.listedCount }} /
{{ stats.collectionLength }}
</CollectionInfoLine>
</div>
</div>
</template>
<script setup lang="ts">
import { NeoButton, NeoIcon } from '@kodadot1/brick'
import { useCollectionDetails } from './utils/useCollectionDetails'
import {
DESCRIPTION_MAX_LENGTH,
generatePreviewDescription,
} from '@/components/collection/utils/description'
const props = defineProps<{
collectionId: string
collection?: unknown
}>()
const body = ref(document.body)
const route = useRoute()
const { urlPrefix } = usePrefix()
const { availableChains } = useChain()
const chain = computed(
() =>
availableChains.value.find(chain => chain.value === route.params.prefix)
?.text,
)
const address = computed(() => props.collection?.displayCreator)
const recipient = computed(() => props.collection?.recipient)
const royalty = computed(() => props.collection?.royalty)
const createdAt = computed(() => props.collection?.createdAt)
const seeAllDescription = ref(false)
const toggleSeeAllDescription = () => {
seeAllDescription.value = !seeAllDescription.value
}
const hasSeeAllDescriptionOption = computed(() => {
return (
(props.collection?.meta?.description?.length || 0)
> DESCRIPTION_MAX_LENGTH
)
})
const visibleDescription = computed(() => {
const desc = props.collection?.meta?.description
return (
(!hasSeeAllDescriptionOption.value || seeAllDescription.value
? desc
: generatePreviewDescription(desc)) || ''
)
})
const { stats } = useCollectionDetails({
collectionId: computed(() => props.collectionId),
})
</script>