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

feat: Pricing on drop cards #10741

Merged
merged 3 commits into from
Aug 12, 2024
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
33 changes: 28 additions & 5 deletions components/drops/BasicDropCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,25 @@
<div
class="h-[28px] flex justify-between items-center flex-wrap gap-y-4 gap-x-2"
>
<slot name="supply">
<div>
<span>{{ minted }}</span><span class="text-k-grey">/{{ dropMax }}</span>
<div class="flex gap-4">
<slot name="supply">
<div>
<span>{{ minted }}</span><span class="text-k-grey text-xs">/{{ dropMax }}</span>
</div>
</slot>
<div
v-if="Number(dropPrice)"
class="flex gap-1 items-baseline"
>
<span>{{ formattedPrice }}</span><span class="text-k-grey text-xs">USD</span>
</div>
</slot>
<div
v-else
>
<span>{{ $t('free') }}</span>
</div>
</div>

<CollectionDropCollectedBy
v-if="ownerAddresses.length"
:addresses="ownerAddresses"
Expand All @@ -74,9 +88,10 @@
<script setup lang="ts">
import type { Prefix } from '@kodadot1/static'
import type { DropStatus } from '@/components/drops/useDrops'
import { chainPropListOf } from '@/utils/config/chain.config'

const emit = defineEmits(['click'])
withDefaults(
const props = withDefaults(
defineProps<{
image: string | undefined
name: string
Expand All @@ -91,6 +106,7 @@ withDefaults(
minted?: number
ownerAddresses?: string[]
dropCreator?: string | null
dropPrice?: string
}>(),
{
loading: false,
Expand All @@ -107,6 +123,13 @@ withDefaults(
)

const { placeholder } = useTheme()

const chainPropList = chainPropListOf(props.dropPrefix)
const { usd: formattedPrice } = useAmount(
computed(() => props.dropPrice),
toRef(chainPropList.tokenDecimals),
toRef(chainPropList.tokenSymbol),
)
</script>

<style scoped lang="scss">
Expand Down
1 change: 1 addition & 0 deletions components/drops/DropCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
:drop-status="drop.status"
:drop-max="drop.max || FALLBACK_DROP_COLLECTION_MAX"
:drop-prefix="drop.chain"
:drop-price="drop.price"
:minted="drop.minted"
@click="click"
/>
Expand Down
2 changes: 1 addition & 1 deletion components/drops/DropCardSkeleton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div
class="flex justify-between items-center flex-wrap gap-y-4 gap-x-2 w-full"
>
<div class="w-16 flex gap-2">
<div class="w-32 flex gap-2">
<NeoSkeleton
height="28"
width="100%"
Expand Down
1 change: 1 addition & 0 deletions components/drops/calendar/DropsCalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
:time-tag-with-time="calendarHasTime(item)"
:drop-prefix="item.chain"
:drop-creator="item.creator"
:drop-price="item.price"
@click="() => handleClick(item)"
>
<template
Expand Down
2 changes: 1 addition & 1 deletion composables/useAmount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function (
Number(tokenAmount.value) * Math.pow(10, -tokenDecimals.value),
Number(getCurrentTokenValue(chainSymbol.value)),
)
return value ? `$${value}` : ''
return typeof value === 'number' && value >= 0 ? `$${value}` : ''
})

return {
Expand Down
Loading