gancio/components/Snackbar.vue

41 lines
841 B
Vue
Raw Normal View History

2020-07-25 21:41:22 +02:00
<template lang='pug'>
v-snackbar(
v-model="active"
:color="color"
:bottom="bottom"
:top="top"
:left="left"
:right="right"
:timeout="timeout")
v-icon.mr-3(color="white") {{icon}}
span {{ message }}
template(v-slot:action="{ }")
v-icon(size="16" @click="active = false") mdi-close-circle
</template>
<script>
export default {
data () {
return {
icon: 'md-alert',
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,
2020-07-28 12:24:39 +02:00
right: false,
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)
2020-10-09 00:40:36 +02:00
this.color = opts.color || 'secondary'
2020-10-07 11:12:13 +02:00
this.icon = opts.icon || 'md-alert'
2020-07-28 12:24:39 +02:00
}
2020-07-25 21:41:22 +02:00
}
}
</script>