Skip to content

Commit

Permalink
Merge pull request #5801 from Jarsen136/issue-5775
Browse files Browse the repository at this point in the history
fix: Activity event improvements
  • Loading branch information
vikiival committed Apr 27, 2023
2 parents 6687ea6 + 90af86d commit cd50b75
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 90 deletions.
2 changes: 1 addition & 1 deletion components/collection/activity/events/Events.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="column">
<span>{{ $t('activity.event.item') }}</span>
</div>
<div class="column">
<div class="column is-1">
<span>{{ $t('activity.event.event') }}</span>
</div>
<div class="column">
Expand Down
39 changes: 0 additions & 39 deletions components/collection/activity/events/eventRow/EventRowAvatar.vue

This file was deleted.

29 changes: 17 additions & 12 deletions components/collection/activity/events/eventRow/EventRowDesktop.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<template>
<div class="columns mb-2">
<div class="column">
<div class="column is-clipped">
<div class="is-flex is-align-items-center">
<nuxt-link
:to="`/${urlPrefix}/gallery/${event.nft.id}`"
class="height-50px">
<EventRowAvatar :avatar="avatar" :name="event.nft.name" />
<NeoAvatar
:avatar="avatar"
:placeholder="placeholder"
:name="event.nft.name"
:size="50" />
</nuxt-link>
<nuxt-link :to="`/${urlPrefix}/gallery/${event.nft.id}`">
<div class="ml-5 has-text-weight-bold is-clipped elipsis">
<nuxt-link
class="is-ellipsis is-inline-block"
:to="`/${urlPrefix}/gallery/${event.nft.id}`">
<span class="ml-5 has-text-weight-bold is-clipped">
{{ event.nft.name }}
</div>
</span>
</nuxt-link>
</div>
</div>

<div class="column">
<div class="column is-1">
<div class="height-50px is-flex is-align-items-center">
<div
class="border is-size-7 is-justify-content-center py-1 my-2 is-flex is-align-items-center fixed-width fixed-height"
Expand All @@ -25,7 +31,7 @@
</div>
</div>

<div class="column">
<div class="column is-ellipsis">
<div class="height-50px is-flex is-align-items-center">
<div v-if="amount === blank">
{{ blank }}
Expand Down Expand Up @@ -84,14 +90,16 @@ import {
getToAddress,
interactionNameMap,
} from './common'
import EventRowAvatar from './EventRowAvatar.vue'
import { NeoAvatar } from '@kodadot1/brick'
const { urlPrefix } = usePrefix()
const props = defineProps<{
event: InteractionWithNFT | Offer
}>()
const avatar = ref<string>()
const { placeholder } = useTheme()
const interactionName = computed(
() => interactionNameMap[props.event.interaction] || props.event.interaction
Expand All @@ -117,14 +125,11 @@ const getAvatar = async () => {
.fixed-width {
width: 66px;
}
.fixed-height {
height: 22px;
}
.height-50px {
height: 50px;
}
.elipsis {
text-overflow: ellipsis;
}
</style>
89 changes: 51 additions & 38 deletions components/collection/activity/events/eventRow/EventRowTablet.vue
Original file line number Diff line number Diff line change
@@ -1,59 +1,61 @@
<template>
<div class="mb-5">
<div class="is-flex height-50px line-height-1">
<div class="mb-6 is-flex is-flex-direction-column gap-10px">
<div class="is-flex height-70px line-height-1">
<nuxt-link :to="`/${urlPrefix}/gallery/${event.nft.id}`">
<div class="mr-5">
<EventRowAvatar :avatar="avatar" :name="event.nft.name" />
<NeoAvatar
:avatar="avatar"
:placeholder="placeholder"
:name="event.nft.name"
:size="70" />
</div>
</nuxt-link>
<div
class="is-flex is-flex-direction-column is-flex-grow-1 is-justify-content-space-between">
<div class="is-flex is-justify-content-space-between">
<nuxt-link :to="`/${urlPrefix}/gallery/${event.nft.id}`">
<div class="has-text-weight-bold is-clipped elipsis">
{{ event.nft.name }}
</div>
</nuxt-link>
<CommonTokenMoney v-if="amount !== blank" :value="amount" />
</div>
class="is-flex is-flex-direction-column is-justify-content-center gap-10px is-flex-grow-1">
<nuxt-link
class="is-ellipsis is-inline-block mobile-fixed-width"
:to="`/${urlPrefix}/gallery/${event.nft.id}`">
<span class="has-text-weight-bold">
{{ event.nft.name }}
</span>
</nuxt-link>

<div
class="is-flex is-justify-content-space-between is-align-items-center">
<div
class="border is-size-7 is-justify-content-center py-1 is-flex is-align-items-center fixed-width fixed-height"
:class="getInteractionColor(event.interaction)">
{{ interactionName }}
</div>
<div>
{{ timeAgo(event.timestamp) }}
</div>
class="border is-size-7 is-justify-content-center is-flex is-align-items-center fixed-width fixed-height"
:class="getInteractionColor(event.interaction)">
{{ interactionName }}
</div>
</div>
</div>
<div class="is-flex mt-4 gap">
<div class="is-flex is-align-items-center">
<div class="is-flex">
<div class="is-flex is-justify-content-space-between is-flex-grow-1">
<CommonTokenMoney v-if="amount !== blank" :value="amount" />
<span v-else>
{{ blank }}
</span>
<span>
{{ timeAgo(event.timestamp) }}
</span>
</div>
</div>

<div class="is-flex gap">
<div v-if="fromAddress !== blank" class="is-flex is-align-items-center">
<span class="is-size-7 mr-3">{{ $t('activity.event.from') }}:</span>
<nuxt-link
v-if="fromAddress !== blank"
:to="`/${urlPrefix}/u/${fromAddress}`"
class="has-text-link">
class="has-text-link is-ellipsis">
<IdentityIndex ref="identity" :address="fromAddress" show-clipboard />
</nuxt-link>
<div v-else>
{{ blank }}
</div>
</div>

<div class="is-flex is-align-items-center">
<div v-if="toAddress !== blank" class="is-flex is-align-items-center">
<span class="is-size-7 mr-3">{{ $t('activity.event.to') }}:</span>
<nuxt-link
v-if="toAddress !== blank"
:to="`/${urlPrefix}/u/${toAddress}`"
class="has-text-link">
class="has-text-link is-ellipsis">
<IdentityIndex ref="identity" :address="toAddress" show-clipboard />
</nuxt-link>
<div v-else>
{{ blank }}
</div>
</div>
</div>
</div>
Expand All @@ -75,15 +77,15 @@ import {
getToAddress,
interactionNameMap,
} from './common'
import EventRowAvatar from './EventRowAvatar.vue'
import { NeoAvatar } from '@kodadot1/brick'
const { urlPrefix } = usePrefix()
const props = defineProps<{
event: InteractionWithNFT | Offer
}>()
const avatar = ref<string>()
const { placeholder } = useTheme()
const interactionName = computed(
() => interactionNameMap[props.event.interaction] || props.event.interaction
)
Expand All @@ -105,19 +107,30 @@ const getAvatar = async () => {
</script>

<style scoped lang="scss">
@import '@/styles/abstracts/variables';
.fixed-width {
width: 66px;
}
.mobile-fixed-width {
@include mobile {
width: 240px;
}
}
.fixed-height {
height: 22px;
}
.height-50px {
height: 50px;
.height-70px {
height: 70px;
}
.line-height-1 {
line-height: 1;
}
.gap-10px {
gap: 10px;
}
.gap {
gap: 1rem;
}
Expand Down
4 changes: 4 additions & 0 deletions libs/ui/src/components/NeoAvatar/NeoAvatar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.neo-avatar {
max-width: none !important;
object-fit: cover;
}
21 changes: 21 additions & 0 deletions libs/ui/src/components/NeoAvatar/NeoAvatar.story.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<template>
<Story title="NeoAvatar">
<Variant title="Nft Avatar">
<NeoAvatar
:avatar="image"
:placeholder="image"
:name="name"
:size="size" />
</Variant>
</Story>
</template>

<script lang="ts" setup>
import NeoAvatar from './NeoAvatar.vue'
const image =
'https://kodadot.mypinata.cloud/ipfs/bafybeigdh3ecetqmzplrjrovs5po23vwpikh2vgtfjai4vky5qzitjzaq4'
const name = 'NFT Avatar'
const size = 70
</script>
39 changes: 39 additions & 0 deletions libs/ui/src/components/NeoAvatar/NeoAvatar.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<template>
<img
v-if="avatar"
:src="avatar"
:alt="name"
class="border neo-avatar"
:style="customStyle"
@error="onError" />
<img
v-else
:src="placeholder"
:style="customStyle"
class="border neo-avatar" />
</template>

<script setup lang="ts">
const props = defineProps<{
avatar?: string
placeholder: string
name: string
size: number
}>()
const customStyle = computed(() => ({
width: `${props.size}px`,
height: `${props.size}px`,
}))
const onError = (e: Event) => {
const target = e.target as HTMLImageElement
if (target) {
target.src = props.placeholder
}
}
</script>

<style lang="scss">
@import './NeoAvatar.scss';
</style>
1 change: 1 addition & 0 deletions libs/ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ export { default as NeoTabItem } from './components/NeoTab/NeoTabItem'
export { default as NeoIcon } from './components/NeoIcon/NeoIcon'
export { default as NeoCollapse } from './components/NeoCollapse/NeoCollapse'
export { default as NeoModal } from './components/NeoModal/NeoModal'
export { default as NeoAvatar } from './components/NeoAvatar/NeoAvatar'

export { default as Neo } from '@oruga-ui/oruga'

0 comments on commit cd50b75

Please sign in to comment.