2021-02-08 11:08:35 +00:00
|
|
|
<template>
|
2021-12-01 07:15:39 +00:00
|
|
|
<div class="notifications-link">
|
2022-03-25 13:32:45 +00:00
|
|
|
<woot-button
|
|
|
|
class-names="notifications-link--button"
|
|
|
|
variant="clear"
|
|
|
|
color-scheme="secondary"
|
|
|
|
:class="{ 'is-active': isNotificationPanelActive }"
|
|
|
|
@click="openNotificationPanel"
|
|
|
|
>
|
|
|
|
<fluent-icon icon="alert" />
|
|
|
|
<span v-if="unreadCount" class="badge warning">{{ unreadCount }}</span>
|
|
|
|
</woot-button>
|
2021-12-01 07:15:39 +00:00
|
|
|
</div>
|
2021-02-08 11:08:35 +00:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import { mapGetters } from 'vuex';
|
2021-12-01 05:03:18 +00:00
|
|
|
|
2021-02-08 11:08:35 +00:00
|
|
|
export default {
|
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
accountId: 'getCurrentAccountId',
|
|
|
|
notificationMetadata: 'notifications/getMeta',
|
|
|
|
}),
|
|
|
|
unreadCount() {
|
|
|
|
if (!this.notificationMetadata.unreadCount) {
|
2021-12-02 05:32:43 +00:00
|
|
|
return '';
|
2021-02-08 11:08:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this.notificationMetadata.unreadCount < 100
|
2021-12-01 07:15:39 +00:00
|
|
|
? `${this.notificationMetadata.unreadCount}`
|
2021-02-08 11:08:35 +00:00
|
|
|
: '99+';
|
|
|
|
},
|
2022-03-25 13:32:45 +00:00
|
|
|
isNotificationPanelActive() {
|
|
|
|
return this.$route.name === 'notifications_index';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
openNotificationPanel() {
|
|
|
|
if (this.$route.name !== 'notifications_index') {
|
|
|
|
this.$emit('open-notification-panel');
|
|
|
|
}
|
|
|
|
},
|
2021-02-08 11:08:35 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2021-12-01 07:15:39 +00:00
|
|
|
.notifications-link {
|
|
|
|
margin-bottom: var(--space-small);
|
2021-02-08 11:08:35 +00:00
|
|
|
}
|
2022-03-25 13:32:45 +00:00
|
|
|
|
|
|
|
.badge {
|
|
|
|
position: absolute;
|
|
|
|
right: var(--space-minus-smaller);
|
|
|
|
top: var(--space-minus-smaller);
|
|
|
|
}
|
|
|
|
.notifications-link--button {
|
|
|
|
display: flex;
|
|
|
|
position: relative;
|
|
|
|
border-radius: var(--border-radius-large);
|
|
|
|
border: 1px solid transparent;
|
|
|
|
color: var(--s-600);
|
|
|
|
margin: var(--space-small) 0;
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
background: var(--w-50);
|
|
|
|
color: var(--s-600);
|
|
|
|
}
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
border-color: var(--w-500);
|
|
|
|
}
|
|
|
|
|
|
|
|
&.is-active {
|
|
|
|
background: var(--w-50);
|
|
|
|
color: var(--w-500);
|
|
|
|
}
|
|
|
|
}
|
2021-02-08 11:08:35 +00:00
|
|
|
</style>
|