gancio/components/Snackbar.vue

45 lines
1 KiB
Vue
Raw Normal View History

2020-07-25 21:41:22 +02:00
<template lang='pug'>
2022-07-01 15:55:09 +02:00
v-snackbar(
v-model="active"
:color="color"
:bottom="bottom"
:top="top"
:left="left"
:right="right"
transition='scroll-x-reverse-transition'
2022-07-01 15:55:09 +02:00
:timeout="timeout")
v-icon.mr-3(color="white" v-text='icon')
span {{ message }}
template(v-slot:action="{ }")
v-icon(size="16" @click="active = false" v-text='mdiCloseCircle')
2020-07-25 21:41:22 +02:00
</template>
<script>
import { mdiAlert, mdiCloseCircle, mdiInformation } from '@mdi/js'
2020-07-25 21:41:22 +02:00
export default {
data () {
return {
2022-07-01 15:55:09 +02:00
mdiAlert, mdiCloseCircle, mdiInformation,
icon: mdiInformation,
2020-10-09 00:40:36 +02:00
color: 'secondary',
2020-09-05 01:21:47 +02:00
bottom: true,
top: false,
2020-07-25 21:41:22 +02:00
left: false,
right: true,
2020-07-25 21:41:22 +02:00
active: false,
timeout: 5000,
message: ''
}
},
created () {
2020-10-09 00:40:36 +02:00
this.$root.$message = (message, opts = {}) => {
2020-07-25 21:41:22 +02:00
this.active = true
2020-10-07 11:12:13 +02:00
this.message = this.$t(message, opts)
2022-08-05 18:10:36 +02:00
this.color = opts.color || 'primary'
this.icon = opts.icon || (this.color === 'success' ? mdiInformation : mdiAlert)
2020-07-28 12:24:39 +02:00
}
2020-07-25 21:41:22 +02:00
}
}
</script>