2020-05-15 17:52:59 +02:00
|
|
|
<template>
|
|
|
|
<div class="toast mt-2" :class="notificationStatus.className">
|
2020-05-17 19:34:56 +02:00
|
|
|
<span class="p-vcentered text-left" :class="{'expanded': isExpanded}">
|
2020-08-12 10:48:18 +02:00
|
|
|
<i class="mdi mdi-24px mr-2" :class="notificationStatus.iconName" />
|
2020-05-15 17:52:59 +02:00
|
|
|
<span class="notification-message">{{ message }}</span>
|
|
|
|
</span>
|
2020-05-17 19:34:56 +02:00
|
|
|
<i
|
|
|
|
v-if="isExpandable"
|
2020-08-12 10:48:18 +02:00
|
|
|
class="mdi mdi-24px c-hand expand-btn"
|
|
|
|
:class="isExpanded ? 'mdi-chevron-up' : 'mdi-chevron-down'"
|
2020-05-17 19:34:56 +02:00
|
|
|
@click="toggleExpand"
|
2020-08-12 10:48:18 +02:00
|
|
|
/>
|
2020-05-18 18:06:32 +02:00
|
|
|
<button class="btn btn-clear ml-2" @click="hideToast" />
|
2020-05-15 17:52:59 +02:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-05-17 19:34:56 +02:00
|
|
|
export default {
|
2020-05-15 17:52:59 +02:00
|
|
|
name: 'BaseNotification',
|
|
|
|
props: {
|
|
|
|
message: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
|
|
|
status: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
}
|
|
|
|
},
|
2020-05-17 19:34:56 +02:00
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
isExpanded: false
|
|
|
|
};
|
|
|
|
},
|
2020-05-15 17:52:59 +02:00
|
|
|
computed: {
|
|
|
|
notificationStatus () {
|
|
|
|
let className = '';
|
|
|
|
let iconName = '';
|
|
|
|
switch (this.status) {
|
|
|
|
case 'success':
|
|
|
|
className = 'toast-success';
|
2020-08-12 10:48:18 +02:00
|
|
|
iconName = 'mdi-check';
|
2020-05-15 17:52:59 +02:00
|
|
|
break;
|
|
|
|
case 'error':
|
|
|
|
className = 'toast-error';
|
2020-08-12 10:48:18 +02:00
|
|
|
iconName = 'mdi-alert-rhombus';
|
2020-05-15 17:52:59 +02:00
|
|
|
break;
|
|
|
|
case 'warning':
|
|
|
|
className = 'toast-warning';
|
2020-08-12 10:48:18 +02:00
|
|
|
iconName = 'mdi-alert';
|
2020-05-15 17:52:59 +02:00
|
|
|
break;
|
|
|
|
case 'primary':
|
|
|
|
className = 'toast-primary';
|
2020-08-12 10:48:18 +02:00
|
|
|
iconName = 'mdi-information-outline';
|
2020-05-15 17:52:59 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return { className, iconName };
|
2020-05-17 19:34:56 +02:00
|
|
|
},
|
|
|
|
isExpandable () {
|
|
|
|
return this.message.length > 80;
|
2020-05-15 17:52:59 +02:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
hideToast () {
|
|
|
|
this.$emit('close');
|
2020-05-17 19:34:56 +02:00
|
|
|
},
|
|
|
|
toggleExpand () {
|
|
|
|
this.isExpanded = !this.isExpanded;
|
2020-05-15 17:52:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
<style scoped>
|
2020-07-31 18:16:28 +02:00
|
|
|
.toast {
|
|
|
|
display: flex;
|
|
|
|
justify-content: space-between;
|
|
|
|
user-select: text;
|
|
|
|
word-break: break-all;
|
|
|
|
width: fit-content;
|
|
|
|
margin-left: auto;
|
|
|
|
}
|
2020-05-15 17:52:59 +02:00
|
|
|
|
2020-07-31 18:16:28 +02:00
|
|
|
.notification-message {
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
display: inline-block;
|
|
|
|
max-width: 30rem;
|
|
|
|
}
|
2020-05-17 19:34:56 +02:00
|
|
|
|
2020-08-12 10:48:18 +02:00
|
|
|
.expand-btn {
|
|
|
|
align-items: initial;
|
|
|
|
}
|
|
|
|
|
2020-07-31 18:16:28 +02:00
|
|
|
.expanded .notification-message {
|
|
|
|
white-space: initial;
|
|
|
|
}
|
2020-05-15 17:52:59 +02:00
|
|
|
</style>
|