-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathNotificationsButton.vue
More file actions
92 lines (82 loc) · 2.43 KB
/
NotificationsButton.vue
File metadata and controls
92 lines (82 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<template>
<div class="notifications-button-wrapper">
<button class="notifications-button" data-el="notifications-button" data-click-exclude="right-drawer" @click="onClick">
<MailIcon />
<ff-notification-pill v-if="hasNotifications" data-el="notification-pill" class="ml-3" :count="notificationsCount" />
</button>
</div>
</template>
<script>
import { MailIcon } from '@heroicons/vue/outline'
import { mapActions, mapState } from 'pinia'
import { markRaw } from 'vue'
import NotificationsDrawer from './drawers/notifications/NotificationsDrawer.vue'
import { useAccountStore } from '@/stores/account.js'
import { useUxDrawersStore } from '@/stores/ux-drawers.js'
export default {
name: 'NotificationsButton',
components: { MailIcon },
computed: {
...mapState(useUxDrawersStore, ['rightDrawer']),
...mapState(useAccountStore, ['hasNotifications', 'unreadNotificationsCount']),
notificationsCount: function () {
// Return null if count = 0 so we don't show a 0 in the pill
if (!this.unreadNotificationsCount) {
return null
}
return this.unreadNotificationsCount
}
},
methods: {
...mapActions(useUxDrawersStore, ['openRightDrawer', 'closeRightDrawer']),
onClick () {
this.openRightDrawer({ component: markRaw(NotificationsDrawer) })
}
}
}
</script>
<style scoped lang="scss">
.notifications-button-wrapper {
.notifications-button {
color: $ff-grey-800;
display: flex;
align-items: center;
flex: 1;
justify-content: center;
width: 100%;
height: 100%;
padding: 18px;
position: relative;
> * {
pointer-events: none;
}
svg {
flex: 1;
width: 24px;
height: 24px;
transition: ease-in-out .1s;
object-fit: contain;
}
&:hover {
svg {
will-change: transform ;
color: $ff-indigo-600;
transform: scale(1.25) translateZ(0); /* Using slight adjustments to whole values */
backface-visibility: hidden;
perspective: 1000px;
stroke-width: 1.5px;
shape-rendering: geometricPrecision;
text-rendering: geometricPrecision;
}
}
.ff-notification-pill {
bottom: 10px;
right: 5px;
position: absolute;
font-size: 0.65rem;
padding: 0 7px;
background-color: $ff-red-500;
}
}
}
</style>