storj/web/satellite/src/components/notifications/Notification.vue

112 lines
3.2 KiB
Vue
Raw Normal View History

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<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>
</div>
</div>
</template>
<script lang="ts">
import { Component, Vue } from 'vue-property-decorator';
import { NOTIFICATION_IMAGES, NOTIFICATION_TYPES } from '@/utils/constants/notification';
@Component({
props: {
type: String,
message: String,
},
methods: {
// Force delete notification
onCloseClick: function (): void {
this.$store.dispatch('deleteNotification');
},
// Force notification to stay on page on mouse over it
onMouseOver: function (): void {
this.$store.dispatch('pauseNotification');
},
// Resume notification flow when mouse leaves notification
onMouseLeave: function (): void {
this.$store.dispatch('resumeNotification');
},
},
computed: {
configuration: function () {
let backgroundColor;
let imageSource;
// 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;
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;
}
return {
style: {
backgroundColor
},
imageSource,
closeImage: NOTIFICATION_IMAGES.CLOSE
};
},
}
})
export default class Notification extends Vue {
}
</script>
<style scoped lang="scss">
.notification-wrap {
width: 100%;
height: 98px;
display: flex;
justify-content: space-between;
padding: 0 50px;
align-items: center;
&__text {
display: flex;
align-items: center;
p {
font-family: 'montserrat_medium';
font-size: 16px;
margin-left: 40px;
span {
margin-right: 10px;
}
}
}
&__buttons-group {
display: flex;
&__close {
width: 32px;
height: 32px;
cursor: pointer;
}
}
}
</style>