2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-12-05 16:39:03 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
<template>
|
2019-08-21 14:21:23 +01:00
|
|
|
<div :style="notification.style" class="notification-wrap" :class="{ active: isClassActive }" @mouseover="onMouseOver" @mouseleave="onMouseLeave" >
|
2019-09-26 14:36:12 +01:00
|
|
|
<div class="notification-wrap__text-area">
|
2019-10-11 11:53:22 +01:00
|
|
|
<div class="notification-wrap__text-area__image" v-html="notification.imgSource"></div>
|
2019-09-26 14:36:12 +01:00
|
|
|
<p class="notification-wrap__text-area__message">{{notification.message}}</p>
|
2018-12-12 13:44:01 +00:00
|
|
|
</div>
|
2019-08-21 14:21:23 +01:00
|
|
|
<div class="notification-wrap__buttons-group" @click="onCloseClick">
|
2019-07-18 14:39:39 +01:00
|
|
|
<span class="notification-wrap__buttons-group__close">
|
2019-10-23 13:26:39 +01:00
|
|
|
<CloseIcon/>
|
2019-07-18 14:39:39 +01:00
|
|
|
</span>
|
2018-12-05 16:39:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
2019-09-09 11:33:39 +01:00
|
|
|
import { Component, Prop, Vue } from 'vue-property-decorator';
|
2018-12-12 13:44:01 +00:00
|
|
|
|
2019-10-23 13:26:39 +01:00
|
|
|
import CloseIcon from '@/../static/images/notifications/close.svg';
|
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import { DelayedNotification } from '@/types/DelayedNotification';
|
|
|
|
import { NOTIFICATION_ACTIONS } from '@/utils/constants/actionNames';
|
2018-12-12 13:44:01 +00:00
|
|
|
|
2019-10-23 13:26:39 +01:00
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
CloseIcon,
|
|
|
|
},
|
|
|
|
})
|
2019-09-26 14:36:12 +01:00
|
|
|
export default class NotificationItem extends Vue {
|
2019-09-09 11:33:39 +01:00
|
|
|
@Prop({default: () => new DelayedNotification(() => { return; }, '', '')})
|
|
|
|
private notification: DelayedNotification;
|
2019-08-21 14:21:23 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
public isClassActive = false;
|
2018-12-12 13:44:01 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
// Force delete notification
|
|
|
|
public onCloseClick(): void {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.DELETE, this.notification.id);
|
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
// Force notification to stay on page on mouse over it
|
|
|
|
public onMouseOver(): void {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.PAUSE, this.notification.id);
|
|
|
|
}
|
2019-08-21 14:21:23 +01:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
// Resume notification flow when mouse leaves notification
|
|
|
|
public onMouseLeave(): void {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.RESUME, this.notification.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
public mounted() {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.isClassActive = true;
|
|
|
|
}, 100);
|
2019-07-18 14:39:39 +01:00
|
|
|
}
|
2019-09-09 11:33:39 +01:00
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2018-12-12 13:44:01 +00:00
|
|
|
.notification-wrap {
|
2019-08-21 14:21:23 +01:00
|
|
|
position: relative;
|
|
|
|
right: -100%;
|
|
|
|
width: calc(100% - 40px);
|
2019-09-13 11:25:52 +01:00
|
|
|
height: auto;
|
2018-12-05 16:39:03 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
2019-09-13 11:25:52 +01:00
|
|
|
padding: 20px;
|
2018-12-12 13:44:01 +00:00
|
|
|
align-items: center;
|
2019-08-21 14:21:23 +01:00
|
|
|
border-radius: 12px;
|
|
|
|
margin-bottom: 7px;
|
|
|
|
transition: all 0.3s;
|
2018-12-05 16:39:03 +00:00
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&__text-area {
|
2018-12-05 16:39:03 +00:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
2019-10-11 11:53:22 +01:00
|
|
|
&__image {
|
|
|
|
max-height: 40px;
|
|
|
|
}
|
|
|
|
|
2019-09-26 14:36:12 +01:00
|
|
|
&__message {
|
2019-10-28 15:59:19 +00:00
|
|
|
font-family: 'font_medium', sans-serif;
|
2019-08-21 14:21:23 +01:00
|
|
|
font-size: 14px;
|
2019-09-13 11:25:52 +01:00
|
|
|
height: auto;
|
|
|
|
width: 270px;
|
|
|
|
margin: 0 0 0 17px;
|
2019-10-11 11:53:22 +01:00
|
|
|
word-break: break-word;
|
2018-12-05 16:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__buttons-group {
|
|
|
|
display: flex;
|
2019-10-28 15:59:19 +00:00
|
|
|
|
2018-12-05 16:39:03 +00:00
|
|
|
&__close {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
2018-12-12 13:44:01 +00:00
|
|
|
cursor: pointer;
|
2018-12-05 16:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-21 14:21:23 +01:00
|
|
|
|
|
|
|
.active {
|
|
|
|
right: 0;
|
|
|
|
}
|
2018-12-12 13:44:01 +00:00
|
|
|
</style>
|