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

#2775 Adding popular collections to landing #3102

Merged
merged 3 commits into from
Jun 4, 2022
Merged
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
6 changes: 3 additions & 3 deletions components/base/CarouselCardList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<div class="media">
<div class="media-content">
<div class="title is-5 is-ellipsis">
<nuxt-link :to="`/rmrk/gallery/${list.id}`">
<nuxt-link :to="`/${url}/${list.id}`">
{{ list.name }}
</nuxt-link>
</div>
Expand Down Expand Up @@ -63,7 +63,7 @@
class="force-clip is-ellipsis" />
</div>
</nuxt-link>
<time class="is-size-7 icon-text">
<time class="is-size-7 icon-text" v-if="list.timestamp">
<b-icon icon="clock" />
<span>{{ list.timestamp }}</span>
</time>
Expand Down Expand Up @@ -98,7 +98,7 @@ const components = {
export default class CarouselList extends mixins(AuthMixin) {
@Prop({ type: Array, required: true }) nfts!: CarouselNFT[]
@Prop({ type: Number, default: 1 }) page!: number

@Prop({ type: String, default: 'rmrk/gallery' }) url!: string
get current() {
return this.page - 1 // 0-indexed
}
Expand Down
1 change: 1 addition & 0 deletions components/landing/Landing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
</div>
<div v-if="prefix === 'rmrk'">
<LazyGalleryLatestSales :passionList="passionList" class="my-5" />
<LazyGalleryPopularCollections class="my-5" />
<LazyGalleryNewestList :passionList="passionList" class="my-5" />
</div>
</div>
Expand Down
83 changes: 83 additions & 0 deletions components/rmrk/Gallery/PopularCollections.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<template>
<div>
<Loader v-model="isLoading" />

<div class="columns is-vcentered">
<div class="column is-four-fifths">
<h1 class="title is-2">{{ $t('Popular Collections') }}</h1>
<p class="subtitle is-size-5">
Discover the most popular collections on rmrk
</p>
</div>
<div class="column has-text-right">
<Pagination
simple
preserveScroll
v-model="currentValue"
:total="total"
:perPage="1" />
</div>
</div>

<CarouselCardList
:nfts="nfts"
:page="currentValue"
:url="`${urlPrefix}/collection`" />
</div>
</template>

<script lang="ts">
import { Component, mixins } from 'nuxt-property-decorator'
import PrefixMixin from '~/utils/mixins/prefixMixin'
import popularCollectionList from '@/queries/rmrk/subsquid/popularCollectionList.graphql'
import { RowSeries } from '~/components/series/types'
import { sanitizeIpfsUrl } from '../utils'

const components = {
CarouselCardList: () => import('@/components/base/CarouselCardList.vue'),
Pagination: () => import('@/components/rmrk/Gallery/Pagination.vue'),
Loader: () => import('@/components/shared/Loader.vue'),
}

@Component<PopularCollections>({
components,
})
export default class PopularCollections extends mixins(PrefixMixin) {
private nfts: RowSeries[] = []
private total = 0
private currentValue = 1

get isLoading(): boolean {
return false
}

async created() {
this.handleResult()
}

protected async handleResult() {
const collections = await this.$apollo.query({
query: popularCollectionList,
client: 'subsquid',
variables: {
orderDirection: 'ASC',
limit: 10,
dateRange: '7 DAY',
prachi00 marked this conversation as resolved.
Show resolved Hide resolved
orderBy: 'volume',
},
})

const {
data: { seriesInsightTable },
} = collections

this.nfts = seriesInsightTable.map(
(e: RowSeries): RowSeries => ({
...e,
image: sanitizeIpfsUrl(e.image),
})
)
kkukelka marked this conversation as resolved.
Show resolved Hide resolved
this.total = this.nfts.length
}
}
</script>
22 changes: 22 additions & 0 deletions queries/rmrk/subsquid/popularCollectionList.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
query popularCollectionList(
$limit: Float
$orderBy: String
$dateRange: String
$orderDirection: String
) {
seriesInsightTable(
limit: $limit
orderBy: $orderBy
orderDirection: $orderDirection
dateRange: $dateRange
) {
id
image
metadata
sold
name
issuer
total
buys
}
}