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: notification box #5442

Merged
merged 74 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from 71 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
dea873f
feat: notification box
floyd-li Mar 30, 2023
c8b61e6
feat: update graphql file
floyd-li Mar 31, 2023
be4d385
feat: remove suffix
floyd-li Mar 31, 2023
cfadd6b
feat: watch filter change
floyd-li Mar 31, 2023
7e6e8b7
Merge branch 'main' into feat/notification-box
floyd-li Apr 3, 2023
bfc652a
feat: add limit for notification
floyd-li Apr 3, 2023
5156529
refactor: only select one collection
floyd-li Apr 3, 2023
169d1ec
feat: ui update
floyd-li Apr 3, 2023
96badb8
feat(wip): external link redirect
floyd-li Mar 25, 2023
8a39b72
Update pages/redirect.vue
vikiival Mar 29, 2023
1f78861
feat: redirect modal
floyd-li Mar 31, 2023
15f5e9b
chore: remove unused config
floyd-li Mar 31, 2023
ffe0202
chore: remove unused page
floyd-li Mar 31, 2023
18b8fb1
fix: use little hack to solve i18n not work
floyd-li Mar 31, 2023
f3b9b7e
fix: work break
floyd-li Mar 31, 2023
34579ce
feat: add for more markdown
floyd-li Apr 1, 2023
7610774
Apply suggestions from code review
vikiival Apr 2, 2023
5818931
Update components/massmint/OnBoarding.vue
vikiival Apr 2, 2023
e0251d3
fix: update i18n types
floyd-li Apr 3, 2023
a0f2200
refactor: fix codeclimate issues
floyd-li Apr 3, 2023
5813a53
refactor: fix codeclimate issue
floyd-li Apr 3, 2023
97a359d
feat: add fuzzy matching
floyd-li Apr 3, 2023
c9949a0
fix: Scrolling in profile always kicks me back to top when loading
Jarsen136 Apr 2, 2023
b306267
✨ explore items scrollTopButton
roiLeo Apr 3, 2023
c5cf3bb
added new deployments to bug report
yangwao Apr 3, 2023
e8e26ef
Update bug.yml - canary
yangwao Apr 3, 2023
8472f2f
fix: collection on mobile is broken
Jarsen136 Apr 2, 2023
fe8db27
fix: remove columns
Jarsen136 Apr 3, 2023
b8428e7
#5499 Playing with stepsize on chart
yangwao Apr 3, 2023
b153e37
Merge branch 'main' into feat/notification-box
floyd-li Apr 3, 2023
fa0acaf
fix: upgrade @sentry/browser from 7.30.0 to 7.42.0
snyk-bot Apr 3, 2023
4db2780
chore: update lockfile
preschian Apr 3, 2023
7b6409c
fix: Infinity scroll is slow
Jarsen136 Mar 30, 2023
8d20f08
fix: remvoe vue-lazyload
Jarsen136 Mar 31, 2023
ed74386
fix: remove deps
Jarsen136 Mar 31, 2023
cd09eec
fix: update pnpm lock
Jarsen136 Apr 1, 2023
b383bcf
fix: infinite scroll on higher screen
Jarsen136 Apr 1, 2023
5dda90c
fix: prefetch more page
Jarsen136 Apr 1, 2023
eb18221
fix: infinite scroll with incorrect item width
Jarsen136 Apr 1, 2023
6110fba
fix: remove lazy attr
Jarsen136 Apr 2, 2023
a0f0432
fix: remove default value
Jarsen136 Apr 3, 2023
a4c21a2
Update libs/ui/src/components/MediaItem/type/ImageMedia.vue
vikiival Apr 2, 2023
6a6cdc9
fix: dark mode fallback iamge
Jarsen136 Apr 3, 2023
c89d502
[skip netlify] Update Node.js to ^v16.20.0
renovate[bot] Apr 3, 2023
ad69b07
Merge branch 'main' into feat/notification-box
floyd-li Apr 4, 2023
a845f80
feat(wip): update event type
floyd-li Apr 4, 2023
d48d4ab
fix: deepsource/codeclimate issue
floyd-li Apr 4, 2023
ad0cf22
refactor: adjust locale key order
floyd-li Apr 4, 2023
2505063
Merge branch 'main' into feat/notification-box
vikiival Apr 4, 2023
5d1c8f7
Merge branch 'main' into feat/notification-box
vikiival Apr 5, 2023
e85cd37
Merge branch 'main' into feat/notification-box
vikiival Apr 5, 2023
7ce3b63
Merge branch 'main' into feat/notification-box
vikiival Apr 6, 2023
21109eb
feat: fix type
floyd-li Apr 6, 2023
987c061
refactor: notification graphql query
floyd-li Apr 6, 2023
3d7816e
feat: add url watch
floyd-li Apr 6, 2023
a8f701e
fix(deepsource): remove v-html
floyd-li Apr 6, 2023
1c1399f
Merge commit '6b2be2e4c4da60f4278f3b9ee5f02e62a6c0dcbc'
floyd-li Apr 6, 2023
4445d4a
Merge branch 'main' into feat/notification-box
floyd-li Apr 6, 2023
75d9be5
fix(ui): update color
floyd-li Apr 7, 2023
c1ae90b
fix: update when change network
floyd-li Apr 7, 2023
b6fc81c
refactor: use fragments
floyd-li Apr 7, 2023
aa60c13
feat(ui): update notification item
floyd-li Apr 7, 2023
855d966
fix: query not correct
floyd-li Apr 7, 2023
1fe073f
fix: remove unexpected line
floyd-li Apr 7, 2023
7bd6a45
fix: rounded style
floyd-li Apr 7, 2023
9461ab2
feat: item image size
floyd-li Apr 7, 2023
fb45be2
fix: offer accepted event
floyd-li Apr 7, 2023
2496c87
fix: type waring
floyd-li Apr 7, 2023
e94b764
feat: add tooltip
floyd-li Apr 7, 2023
4131996
fix: money field error
floyd-li Apr 7, 2023
0657a4c
feat: filter expired offer
floyd-li Apr 7, 2023
4170ac4
fix: review suggestions
floyd-li Apr 7, 2023
c4a8b3a
fix: code review suggestions
floyd-li Apr 8, 2023
24098fb
Merge branch 'main' into feat/notification-box
floyd-li Apr 8, 2023
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
5 changes: 5 additions & 0 deletions components/Navbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
id="NavChainSelect"
class="navbar-chain custom-navbar-item"
data-cy="chain-select" />
<NotificationBoxButton
v-if="account"
:show-label="isMobile"
@closeBurgerMenu="closeBurgerMenu" />
<template v-if="isMobile">
<MobileLanguageOption v-if="!account" />
<MobileExpandableSection
Expand Down Expand Up @@ -150,6 +154,7 @@ import ChainSelectDropdown from '~/components/navbar/ChainSelectDropdown.vue'
import StatsDropdown from '~/components/navbar/StatsDropdown.vue'
import MobileNavbarProfile from '~/components/navbar/MobileNavbarProfile.vue'
import ConnectWalletButton from '~/components/shared/ConnectWalletButton.vue'
import NotificationBoxButton from '~/components/navbar/NotificationBoxButton.vue'
import { ConnectWalletModalConfig } from '@/components/common/ConnectWallet/useConnectWallet'
import { BModalConfig } from 'buefy/types/components'
import type Vue from 'vue'
Expand Down
285 changes: 285 additions & 0 deletions components/common/NotificationBox/NotificationBoxModal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,285 @@
<template>
<div class="notification-modal-container is-flex is-flex-direction-column">
<header class="modal-card-head mb-4">
<span class="modal-card-title is-size-6 has-text-weight-bold">
{{ $t('notification.notifications') }}
</span>
<a class="is-flex is-align-items-center" @click="emit('close')">
<NeoIcon icon="close" />
</a>
</header>
<div class="modal-card-body">
<div class="notification-filter pb-5">
<div
class="is-flex is-justify-content-space-between is-align-items-center pb-4">
<span> {{ $t('notification.filters') }} </span>
<NeoButton
v-if="!showFilter"
no-shadow
class="button-rounded"
@click.native="showFilter = !showFilter">
{{ $t('notification.add') }}
<NeoIcon icon="plus" size="small" />
</NeoButton>
<NeoButton
v-else
no-shadow
class="button-rounded"
@click.native="showFilter = !showFilter">
{{ $t('notification.done') }}
<NeoIcon icon="check" size="small" />
</NeoButton>
</div>
<div v-if="showFilter" class="filter-option">
<div
v-if="collections.length > 0"
class="is-flex is-flex-direction-column pb-4">
<span class="is-size-7 has-text-grey mb-2">
{{ $t('notification.byCollection') }}
</span>
<div class="is-flex is-flex-wrap-wrap filter-list">
<div
v-for="(item, index) in collections"
:key="`${item}-${index}`"
class="filter-item rounded px-3 py-1 mb-1 no-wrap"
:class="{
activated: collectionFilter?.id === item.id,
}"
@click="toggleCollectionFilter(item)">
{{ item.name }}
</div>
</div>
</div>
<div class="is-flex is-flex-direction-column pb-4">
<span class="is-size-7 has-text-grey mb-2">{{
$t('notification.byEvent')
}}</span>
<div class="is-flex is-flex-wrap-wrap filter-list">
<div
v-for="event in eventTypes"
:key="event"
class="filter-item rounded px-3 py-1 no-wrap"
:class="{
activated: eventFilter.includes(event),
}"
@click="toggleEventFilter(event)">
{{ getInteractionName(event) }}
</div>
</div>
</div>
</div>
<div v-if="!showFilter && !isFilterEmpty" class="filter-option">
<div class="is-flex filter-display-list pb-3 is-flex-wrap-wrap">
<NeoTag
v-if="collectionFilter"
class="no-wrap mr-1 mb-1 rounded"
@close="collectionFilter = null">
{{ collectionFilter.name }}
</NeoTag>
<NeoTag
v-for="event in eventFilter"
:key="event"
class="no-wrap mb-1 mr-1 rounded"
@close="toggleEventFilter(event)">
{{ getInteractionName(event) }}
</NeoTag>
</div>
</div>
</div>
<div v-if="displayedEvents.length === 0" class="empty-tip">
<p>{{ $t('notification.emptyTipLine1') }}</p>
<p>{{ $t('notification.emptyTipLine2') }}</p>
</div>
<div v-else class="is-flex is-flex-direction-column">
<NotificationItem
v-for="(event, index) in displayedEvents"
:key="`${event.id}-${index}`"
:event="event" />
</div>
</div>
</div>
</template>

<script setup lang="ts">
import { Event, FilterOption } from './types'
import { NeoButton, NeoIcon } from '@kodadot1/brick'
import NeoTag from '@/components/shared/gallery/NeoTag.vue'

import NotificationItem from './NotificationItem.vue'
import {
Interaction,
getInteractionName,
useNotification,
} from './useNotification'

const { $store } = useNuxtApp()

const eventTypes = ref<string[]>([
Interaction.SALE,
Interaction.OFFER,
Interaction.ACCEPTED_OFFER,
])

const collections = ref<FilterOption[]>([])
const allEvents = ref<Event[]>([])

const collectionFilter = ref<FilterOption | null>(null)
const toggleCollectionFilter = (target: FilterOption) => {
if (collectionFilter.value?.id === target.id) {
collectionFilter.value = null
} else {
collectionFilter.value = target
}
}

const eventFilter = ref<string[]>([])
const toggleEventFilter = (target) => {
const index = eventFilter.value.findIndex((x) => x === target)
if (index === -1) {
eventFilter.value.push(target)
} else {
eventFilter.value.splice(index, 1)
}
}

const showFilter = ref(false)
const isFilterEmpty = computed(
() => !collectionFilter.value && eventFilter.value.length === 0
)

const displayedEvents = ref<Event[]>([])

const doSearch = () => {
displayedEvents.value = allEvents.value.filter(
(item) =>
(!collectionFilter.value ||
collectionFilter.value.id === item.nft.collection?.id) &&
(eventFilter.value.length === 0 ||
eventFilter.value.some((x) => x === item.interaction))
)
}

const getNotifications = () => {
const { collections: collectionData, events: allEventsData } =
useNotification($store.getters.getAuthAddress)
collections.value = collectionData as unknown as FilterOption[]
allEvents.value = allEventsData as unknown as Event[]
}

watch(allEvents, doSearch, {
immediate: true,
})

watch(collectionFilter, doSearch, { deep: true })
watch(eventFilter, doSearch, { deep: true })

watch(() => $store.getters.currentUrlPrefix, getNotifications, {
immediate: true,
})
const emit = defineEmits(['close'])
</script>

<style scoped lang="scss">
@import '@/styles/abstracts/variables';
.no-wrap {
floyd-li marked this conversation as resolved.
Show resolved Hide resolved
white-space: nowrap;
}
.rounded {
border-radius: 2rem;
overflow: hidden;
}
.notification-box-modal {
.notification-modal-container {
position: fixed;
top: 0;
right: 0;
height: 100%;
padding-top: 83px;
daiagi marked this conversation as resolved.
Show resolved Hide resolved
max-width: 360px;
width: 100%;
@include mobile {
padding-top: 58px;
max-width: 100vw;
}
@include ktheme() {
background: theme('background-color');
border-left: 1px solid theme('border-color');
floyd-li marked this conversation as resolved.
Show resolved Hide resolved
}
.modal-card-title {
@include ktheme() {
color: theme('text-color');
}
}
.modal-card-head {
background: unset;
padding: 1rem 2rem;
@include ktheme() {
border-bottom: 1px solid theme('border-color');
floyd-li marked this conversation as resolved.
Show resolved Hide resolved
}
}
.modal-card-body {
padding: 0rem 0rem 1rem 0rem;
floyd-li marked this conversation as resolved.
Show resolved Hide resolved
display: block;
@include ktheme() {
background-color: theme('background-color');
}
}
.notification-filter {
flex-shrink: 0;
flex-grow: 0;
position: sticky;
top: 0;
padding-right: 2rem;
padding-left: 2rem;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use bulma classes instead

z-index: 1;
@include ktheme() {
background-color: theme('background-color');
}
& > div:last-child {
@include ktheme() {
border-bottom: 1px solid theme('k-grey');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it not border-color? can use the global class?

}
}

.filter-item {
cursor: pointer;
margin-right: 0.25rem;
floyd-li marked this conversation as resolved.
Show resolved Hide resolved
&:last-child {
margin-right: 0;
}
}
.filter-list {
.filter-item {
@include ktheme() {
border: 1px solid theme('k-shade');
&:hover {
border-color: theme('border-color');
}
&.activated {
color: theme('black');
background-color: theme('k-shade');
}
}
}
}
}
.empty-tip {
@include ktheme() {
color: theme('k-grey');
text-align: center;
}
}
}
}
</style>
<style lang="scss">
Comment on lines +256 to +257
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we have two style tag here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

notification-box-modal container is created dynamically and will not take effect with scoped styels, i create this modal mainly refrence the wallet connect part. hmm, maybe this two modal need a refactor next

.modal-content {
border: none!important;
}
.modal-background {
background-color: rgba(0, 0, 0, 0.17)!important;
}

.notification-box-modal {
.modal-content {
border: none !important;
box-shadow: none !important;
}
.modal-background {
background-color: rgba(0, 0, 0, 0.17) !important;
daiagi marked this conversation as resolved.
Show resolved Hide resolved
}
}
</style>
Loading