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>
|
2018-12-12 13:44:01 +00:00
|
|
|
<div :style="configuration.style" class="notification-wrap" @mouseover="onMouseOver" @mouseleave="onMouseLeave" >
|
|
|
|
<div class="notification-wrap__text">
|
|
|
|
<div v-html="configuration.imageSource"></div>
|
|
|
|
<p>{{message}}</p>
|
|
|
|
</div>
|
|
|
|
<div class="notification-wrap__buttons-group" v-on:click="onCloseClick">
|
|
|
|
<span class="notification-wrap__buttons-group__close" v-html="configuration.closeImage"></span>
|
2018-12-05 16:39:03 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
2018-12-18 14:43:23 +00:00
|
|
|
import { NOTIFICATION_IMAGES, NOTIFICATION_TYPES } from '@/utils/constants/notification';
|
2019-01-09 15:40:21 +00:00
|
|
|
import { NOTIFICATION_ACTIONS } from '@/utils/constants/actionNames';
|
2018-12-12 13:44:01 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
props: {
|
|
|
|
type: String,
|
|
|
|
message: String,
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
// Force delete notification
|
2018-12-18 14:43:23 +00:00
|
|
|
onCloseClick: function (): void {
|
2019-01-09 15:40:21 +00:00
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.DELETE);
|
2018-12-12 13:44:01 +00:00
|
|
|
},
|
2018-12-18 14:43:23 +00:00
|
|
|
// Force notification to stay on page on mouse over it
|
|
|
|
onMouseOver: function (): void {
|
2019-01-09 15:40:21 +00:00
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.PAUSE);
|
2018-12-12 13:44:01 +00:00
|
|
|
},
|
|
|
|
// Resume notification flow when mouse leaves notification
|
2018-12-18 14:43:23 +00:00
|
|
|
onMouseLeave: function (): void {
|
2019-01-09 15:40:21 +00:00
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.RESUME);
|
2018-12-12 13:44:01 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
2018-12-18 14:43:23 +00:00
|
|
|
configuration: function () {
|
|
|
|
let backgroundColor;
|
|
|
|
let imageSource;
|
2018-12-12 13:44:01 +00:00
|
|
|
|
|
|
|
// Switch for choosing notification style depends on notification type
|
|
|
|
switch (this.$props.type) {
|
2018-12-18 14:43:23 +00:00
|
|
|
case NOTIFICATION_TYPES.SUCCESS:
|
2018-12-12 13:44:01 +00:00
|
|
|
backgroundColor = 'rgba(214, 235, 208, 0.4)';
|
|
|
|
imageSource = NOTIFICATION_IMAGES.SUCCESS;
|
|
|
|
break;
|
2018-12-05 16:39:03 +00:00
|
|
|
|
2018-12-12 13:44:01 +00:00
|
|
|
case NOTIFICATION_TYPES.ERROR:
|
|
|
|
backgroundColor = 'rgba(246, 205, 204, 0.4)';
|
|
|
|
imageSource = NOTIFICATION_IMAGES.ERROR;
|
|
|
|
break;
|
|
|
|
case NOTIFICATION_TYPES.NOTIFICATION:
|
|
|
|
default:
|
|
|
|
backgroundColor = 'rgba(219, 225, 232, 0.4)';
|
|
|
|
imageSource = NOTIFICATION_IMAGES.NOTIFICATION;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-12-18 14:43:23 +00:00
|
|
|
return {
|
2018-12-12 13:44:01 +00:00
|
|
|
style: {
|
|
|
|
backgroundColor
|
|
|
|
},
|
|
|
|
imageSource,
|
|
|
|
closeImage: NOTIFICATION_IMAGES.CLOSE
|
2018-12-18 14:43:23 +00:00
|
|
|
};
|
2018-12-12 13:44:01 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|
2018-12-05 16:39:03 +00:00
|
|
|
|
2018-12-18 14:43:23 +00:00
|
|
|
export default class Notification extends Vue {
|
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped lang="scss">
|
2018-12-12 13:44:01 +00:00
|
|
|
.notification-wrap {
|
2018-12-05 16:39:03 +00:00
|
|
|
width: 100%;
|
2018-12-12 13:44:01 +00:00
|
|
|
height: 98px;
|
2018-12-05 16:39:03 +00:00
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
padding: 0 50px;
|
2018-12-12 13:44:01 +00:00
|
|
|
align-items: center;
|
2018-12-05 16:39:03 +00:00
|
|
|
|
|
|
|
&__text {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
p {
|
|
|
|
font-family: 'montserrat_medium';
|
|
|
|
font-size: 16px;
|
|
|
|
margin-left: 40px;
|
2018-12-12 13:44:01 +00:00
|
|
|
|
|
|
|
span {
|
|
|
|
margin-right: 10px;
|
|
|
|
}
|
2018-12-05 16:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
&__buttons-group {
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
&__close {
|
|
|
|
width: 32px;
|
|
|
|
height: 32px;
|
2018-12-12 13:44:01 +00:00
|
|
|
cursor: pointer;
|
2018-12-05 16:39:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-12-12 13:44:01 +00:00
|
|
|
</style>
|