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">
|
2019-07-08 14:45:25 +01:00
|
|
|
import { Component, Vue } from 'vue-property-decorator';
|
|
|
|
import { NOTIFICATION_IMAGES, NOTIFICATION_TYPES } from '@/utils/constants/notification';
|
|
|
|
import { NOTIFICATION_ACTIONS } from '@/utils/constants/actionNames';
|
2018-12-12 13:44:01 +00:00
|
|
|
|
2019-07-08 14:45:25 +01:00
|
|
|
@Component({
|
|
|
|
props: {
|
|
|
|
type: String,
|
|
|
|
message: String,
|
2018-12-12 13:44:01 +00:00
|
|
|
},
|
2019-07-08 14:45:25 +01:00
|
|
|
methods: {
|
|
|
|
// Force delete notification
|
|
|
|
onCloseClick: function (): void {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.DELETE);
|
|
|
|
},
|
|
|
|
// Force notification to stay on page on mouse over it
|
|
|
|
onMouseOver: function (): void {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.PAUSE);
|
|
|
|
},
|
|
|
|
// Resume notification flow when mouse leaves notification
|
|
|
|
onMouseLeave: function (): void {
|
|
|
|
this.$store.dispatch(NOTIFICATION_ACTIONS.RESUME);
|
|
|
|
},
|
2018-12-12 13:44:01 +00:00
|
|
|
},
|
2019-07-08 14:45:25 +01:00
|
|
|
computed: {
|
|
|
|
configuration: function () {
|
|
|
|
let backgroundColor;
|
|
|
|
let imageSource;
|
2018-12-12 13:44:01 +00:00
|
|
|
|
2019-07-08 14:45:25 +01:00
|
|
|
// Switch for choosing notification style depends on notification type
|
|
|
|
switch (this.$props.type) {
|
|
|
|
case NOTIFICATION_TYPES.SUCCESS:
|
|
|
|
backgroundColor = 'rgba(214, 235, 208, 0.4)';
|
|
|
|
imageSource = NOTIFICATION_IMAGES.SUCCESS;
|
|
|
|
break;
|
2018-12-05 16:39:03 +00:00
|
|
|
|
2019-07-08 14:45:25 +01: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-12 13:44:01 +00:00
|
|
|
|
2019-07-08 14:45:25 +01:00
|
|
|
return {
|
|
|
|
style: {
|
|
|
|
backgroundColor
|
|
|
|
},
|
|
|
|
imageSource,
|
|
|
|
closeImage: NOTIFICATION_IMAGES.CLOSE
|
|
|
|
};
|
|
|
|
},
|
|
|
|
}
|
|
|
|
})
|
2018-12-05 16:39:03 +00:00
|
|
|
|
2019-07-08 14:45:25 +01: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 {
|
2019-03-26 16:38:35 +00:00
|
|
|
font-family: 'font_medium';
|
2018-12-05 16:39:03 +00:00
|
|
|
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>
|