Skip to content

Commit

Permalink
Merge pull request #4511 from kodadot/feat-new-nft-card
Browse files Browse the repository at this point in the history
#4496 gallery card changes
  • Loading branch information
yangwao committed Dec 22, 2022
2 parents f446005 + 546c0fa commit 3b62e14
Show file tree
Hide file tree
Showing 11 changed files with 201 additions and 79 deletions.
2 changes: 1 addition & 1 deletion components/carousel/module/CarouselAgnostic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const props = defineProps<{
nfts: CarouselNFT[]
}>()
const url = inject('itemUrl') as string
const url = inject('itemUrl', 'gallery') as string
const isCollection = computed(() => url.includes('collection'))
provide('isCollection', isCollection.value)
Expand Down
17 changes: 10 additions & 7 deletions components/carousel/module/CarouselInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
v-if="!isCollection && item.collectionName && item.collectionId"
:title="item.collectionName"
:to="
urlOf({ id: item.collectionId, url: 'collection', chain: item.chain })
urlOf({
id: item.collectionId,
url: 'collection',
chain: item.chain,
})
"
class="is-size-7 carousel-info-name">
class="is-size-7 carousel-info-collection-name">
{{ item.collectionName }}
</nuxt-link>

<div v-if="showPrice" class="carousel-meta">
<CommonTokenMoney
:custom-token-id="getTokenId(item.chain)"
:value="item.price"
class="has-text-weight-bold" />
<p class="is-size-7">{{ chainName }}</p>
:value="item.price" />
<p class="is-size-7 chain-name">{{ chainName }}</p>
</div>
</div>
</template>
Expand All @@ -43,8 +46,8 @@ const props = defineProps<{
}>()
const { urlPrefix } = usePrefix()
const { urlOf } = useCarouselUrl()
const url = inject('itemUrl') as string
const isCollection = inject<boolean>('isCollection')
const url = inject('itemUrl', 'gallery') as string
const isCollection = inject<boolean>('isCollection', false)
const chainName = computed(() => {
const name = {
rmrk: 'RMRK',
Expand Down
4 changes: 2 additions & 2 deletions components/carousel/module/CarouselMedia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ defineProps<{
}>()
const { urlOf } = useCarouselUrl()
const url = inject('itemUrl') as string
const isCollection = inject('isCollection')
const url = inject('itemUrl', 'gallery') as string
const isCollection = inject('isCollection', false)
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -26,52 +26,7 @@
v-for="nft in results"
:key="nft.id"
:class="`column is-4 column-padding ${scrollItemClassName}`">
<div class="card nft-card">
<nuxt-link
:to="`/${urlPrefix}/gallery/${nft.id}`"
class="nft-card__skeleton">
<div class="card-image">
<span v-if="nft.emoteCount" class="card-image__emotes">
<b-icon icon="heart" />
<span class="card-image__emotes__count">{{
nft.emoteCount
}}</span>
</span>
<PreviewMediaResolver
:src="nft.image || nft.animation_url"
:metadata="nft.metadata"
:mime-type="nft.type" />
<span
v-if="nft.price > 0 && showPriceValue"
class="card-image__price">
<CommonTokenMoney
:value="nft.price"
:data-cy="results.indexOf(nft)"
inline />
</span>
</div>

<div class="card-content">
<span
v-if="!isLoading"
class="title mb-0 is-4 has-text-centered"
:title="getDisplayNameOfNft(nft)">
<nuxt-link :to="`/${urlPrefix}/gallery/${nft.id}`">
<div class="has-text-overflow-ellipsis">
{{ getDisplayNameOfNft(nft) }}
</div>
</nuxt-link>
<p
v-if="nft.count > 2"
:title="`${nft.count} items available in collection`"
class="is-absolute nft-collection-counter title is-6">
「{{ nft.count }}」
</p>
</span>
<!-- <b-skeleton :active="isLoading"> </b-skeleton> -->
</div>
</nuxt-link>
</div>
<NftCard :nft="nft" />
</div>
</div>
<InfiniteLoading
Expand Down Expand Up @@ -109,27 +64,30 @@ import AuthMixin from '@/utils/mixins/authMixin'
import InfiniteScrollMixin from '@/utils/mixins/infiniteScrollMixin'
import PrefixMixin from '@/utils/mixins/prefixMixin'
import { NFT, NFTMetadata } from '../service/scheme'
import { NFT, NFTMetadata } from '../../rmrk/service/scheme'
import { SearchQuery } from './search/types'
import { getNameOfNft, getSanitizer } from '../utils'
import { getNameOfNft, getSanitizer } from '../../rmrk/utils'
// import passionQuery from '@/queries/rmrk/subsquid/passionFeed.graphql'
type GraphResponse = NFTEntitiesWithCount<GraphNFT>
type SearchedNftsWithMeta = NFTWithCollectionMeta & NFTMetadata
const components = {
GalleryCardList: () => import('./GalleryCardList.vue'),
GalleryCardList: () => import('../../rmrk/Gallery/GalleryCardList.vue'),
Search: () => import('@/components/search/Search.vue'),
Money: () => import('@/components/shared/format/Money.vue'),
Pagination: () => import('./Pagination.vue'),
Pagination: () => import('../../rmrk/Gallery/Pagination.vue'),
Loader: () => import('@/components/shared/Loader.vue'),
BasicImage: () => import('@/components/shared/view/BasicImage.vue'),
PreviewMediaResolver: () =>
import('@/components/media/PreviewMediaResolver.vue'),
InfiniteLoading: () => import('vue-infinite-loading'),
ScrollTopButton: () => import('@/components/shared/ScrollTopButton.vue'),
CommonTokenMoney: () => import('@/components/shared/CommonTokenMoney.vue'),
CarouselMedia: () => import('@/components/carousel/module/CarouselMedia.vue'),
CarouselInfo: () => import('@/components/carousel/module/CarouselInfo.vue'),
NftCard: () => import('./NftCard.vue'),
}
@Component<Gallery>({
Expand Down Expand Up @@ -434,7 +392,7 @@ export default class Gallery extends mixins(
position: relative;
overflow: hidden;
border-radius: 0px;
border: 1px solid $black;
&-image {
&__emotes {
position: absolute;
Expand All @@ -457,7 +415,7 @@ export default class Gallery extends mixins(
color: #fff;
bottom: 10px;
left: 10px;
font-size: 14px;
font-size: 12px;
z-index: 3;
transition: all 0.3s;
}
Expand All @@ -470,21 +428,11 @@ export default class Gallery extends mixins(
@media screen and (min-width: 1024px) {
&-content {
position: absolute;
bottom: -45px;
bottom: 0;
left: 0;
width: 100%;
transition: all 0.3s;
background: #fff;
opacity: 0;
}
&:hover .card-content {
bottom: 0;
opacity: 1;
z-index: 2;
background: $frosted-glass-background;
backdrop-filter: $frosted-glass-backdrop-filter;
border-radius: 0;
}
&:hover .gallery__image-wrapper img {
Expand All @@ -501,10 +449,6 @@ export default class Gallery extends mixins(
top: 15px;
right: 15px;
}
&:hover .card-image__price {
bottom: 62px;
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions components/shared/gallery/NftCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<template>
<NeoNftCard :nft="nft" :prefix="urlPrefix" :show-price="showPrice" />
</template>

<script lang="ts" setup>
import { NeoNftCard } from '@kodadot1/brick'
import type { NFT } from '@/components/rmrk/service/scheme'
const { urlPrefix } = usePrefix()
const props = defineProps<{
nft: NFT
}>()
const showPrice = computed((): boolean => {
return Number(props.nft?.price) > 0
})
</script>
52 changes: 52 additions & 0 deletions libs/ui/src/components/NeoNftCard/NeoNftCard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@import '../../scss/variable.scss';

.nft-card {
&:hover {
box-shadow: $primary-shadow;
}
}
.nft-media {
border: 1px solid $black;
border-bottom: none !important;
box-shadow: none;
}

.nft-media-info {
border: 1px solid $black;
padding: 13px;
min-height: 102px;
}

.nft-info-collection-name {
color: $k-grey;
&:hover {
color: $black;
}
}

.chain-name {
text-transform: uppercase;
color: $k-grey;
}

.dark-mode {
.nft-card {
&:hover {
box-shadow: $primary-shadow-dark;
}
}

.nft-media {
border: 1px solid $white;
}

.nft-info-collection-name {
&:hover {
color: $white;
}
}

.nft-media-info {
border: 1px solid $white;
}
}
26 changes: 26 additions & 0 deletions libs/ui/src/components/NeoNftCard/NeoNftCard.story.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<template>
<Story title="NeoNftCard">
<Variant title="Nft Card">
<NeoNftCard :nft="nft" prefix="rmrk" show-price />
</Variant>
</Story>
</template>

<script lang="ts" setup>
import NeoNftCard from './NeoNftCard.vue'
const nft = {
id: '1825819407-173',
metadata:
'ipfs://ipfs/bafkreig6e5x4nrif2jis4lbqmozx3el5nejskhbkbma7wmoyf2mrmehk2u',
name: 'KoDragon#166',
price: '20',
sn: '173',
image:
'https://kodadot.mypinata.cloud/ipfs/bafybeigdh3ecetqmzplrjrovs5po23vwpikh2vgtfjai4vky5qzitjzaq4',
collection: {
id: '1825819407',
name: 'KoDragons',
},
}
</script>
49 changes: 49 additions & 0 deletions libs/ui/src/components/NeoNftCard/NeoNftCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<template>
<div class="nft-card">
<nuxt-link :to="`/${prefix}/gallery/${nft.id}`">
<MediaItem
:key="nft.image"
class="nft-media"
:src="nft.image"
:animation-src="nft.animationUrl"
:mime-type="nft.mimeType"
:title="nft?.name" />
</nuxt-link>
<div
class="nft-media-info is-flex is-flex-direction-column is-justify-content-space-between">
<div class="is-flex is-flex-direction-column">
<span class="is-ellipsis has-text-weight-bold">{{ nft.name }}</span>
<nuxt-link
v-if="nft.collection.name && nft.collection.id"
:title="nft.collectionName || nft.collection.name"
:to="`/${prefix}/collection/${nft.collection.id}`"
class="is-size-7 nft-info-collection-name">
{{ nft.collection.name }}
</nuxt-link>
</div>
<div
class="is-flex is-align-items-center is-justify-content-space-between mt-2">
<CommonTokenMoney v-if="showPrice" :value="nft.price" />
<span class="chain-name">{{ prefix }}</span>
</div>
</div>
</div>
</template>
<script lang="ts" setup>
import MediaItem from '../MediaItem/MediaItem.vue'
import CommonTokenMoney from '@/components/shared/CommonTokenMoney.vue'
import type { NFT } from '@/components/rmrk/service/scheme'
defineProps<{
nft: NFT
prefix: string
showPrice: boolean
}>()
</script>
<style lang="scss" scoped>
@import './NeoNftCard.scss';
</style>
3 changes: 2 additions & 1 deletion libs/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { default as NeoDropdown } from './components/NeoDropdown/NeoDropdown.vue
export { default as NeoDropdownItem } from './components/NeoDropdown/NeoDropdownItem.vue'
export { default as NeoSelect } from './components/NeoSelect/NeoSelect.vue'

export { default as SampleButton } from './components/TheButton/TheButton.vue'
export { default as TheButton } from './components/TheButton/TheButton.vue'
export { default as DisablableTab } from './components/DisablableTab/DisablableTab'
export { default as NeoTooltip } from './components/NeoTooltip/NeoTooltip'
export { default as NeoNftCard } from './components/NeoNftCard/NeoNftCard'
2 changes: 2 additions & 0 deletions libs/ui/src/scss/variable.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ $shade: #cccccc;
$dark-accent: #1a1718;
$primary-shadow: 4px 4px hsl(0deg, 0%, 4%);
$primary-shadow-dark: 4px 4px white;
$black: #000000;
$white: #ffffff;

0 comments on commit 3b62e14

Please sign in to comment.