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

107 lines
2.9 KiB
Vue
Raw Normal View History

2019-01-24 20:15:10 +00:00
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
<template>
<div :style="notification.style" class="notification-wrap" :class="{ active: isClassActive }" @mouseover="onMouseOver" @mouseleave="onMouseLeave" >
<div class="notification-wrap__text-area">
<div class="notification-wrap__text-area__image" v-html="notification.imgSource"></div>
<p class="notification-wrap__text-area__message">{{notification.message}}</p>
</div>
<div class="notification-wrap__buttons-group" @click="onCloseClick">
<span class="notification-wrap__buttons-group__close">
<CloseIcon/>
</span>
</div>
</div>
</template>
<script lang="ts">
2019-09-09 11:33:39 +01:00
import { Component, Prop, Vue } from 'vue-property-decorator';
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';
@Component({
components: {
CloseIcon,
},
})
export default class NotificationItem extends Vue {
2019-09-09 11:33:39 +01:00
@Prop({default: () => new DelayedNotification(() => { return; }, '', '')})
private notification: DelayedNotification;
2019-09-09 11:33:39 +01:00
public isClassActive = false;
2019-09-09 11:33:39 +01:00
// Force delete notification
public onCloseClick(): void {
this.$store.dispatch(NOTIFICATION_ACTIONS.DELETE, this.notification.id);
}
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-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-09-09 11:33:39 +01:00
}
</script>
<style scoped lang="scss">
.notification-wrap {
position: relative;
right: -100%;
width: calc(100% - 40px);
2019-09-13 11:25:52 +01:00
height: auto;
display: flex;
justify-content: space-between;
2019-09-13 11:25:52 +01:00
padding: 20px;
align-items: center;
border-radius: 12px;
margin-bottom: 7px;
transition: all 0.3s;
&__text-area {
display: flex;
align-items: center;
&__image {
max-height: 40px;
}
&__message {
font-family: 'font_medium', sans-serif;
font-size: 14px;
2019-09-13 11:25:52 +01:00
height: auto;
width: 270px;
margin: 0 0 0 17px;
word-break: break-word;
}
}
&__buttons-group {
display: flex;
&__close {
width: 32px;
height: 32px;
cursor: pointer;
}
}
}
.active {
right: 0;
}
</style>