2019-08-14 09:48:44 +00:00
|
|
|
<template>
|
|
|
|
<transition-group name="toast-fade" tag="div" class="ui-snackbar-container">
|
2020-05-02 04:17:36 +00:00
|
|
|
<woot-snackbar
|
|
|
|
v-for="snackMessage in snackMessages"
|
|
|
|
:key="snackMessage"
|
|
|
|
:message="snackMessage"
|
|
|
|
/>
|
2019-08-14 09:48:44 +00:00
|
|
|
</transition-group>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
/* global bus */
|
|
|
|
import WootSnackbar from './Snackbar';
|
|
|
|
|
|
|
|
export default {
|
2020-05-02 04:17:36 +00:00
|
|
|
components: {
|
|
|
|
WootSnackbar,
|
|
|
|
},
|
2019-08-14 09:48:44 +00:00
|
|
|
props: {
|
|
|
|
duration: {
|
2020-05-02 04:17:36 +00:00
|
|
|
type: Number,
|
2019-08-14 09:48:44 +00:00
|
|
|
default: 2500,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
snackMessages: [],
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
2020-05-02 04:17:36 +00:00
|
|
|
bus.$on('newToastMessage', message => {
|
2019-08-14 09:48:44 +00:00
|
|
|
this.snackMessages.push(message);
|
|
|
|
window.setTimeout(() => {
|
|
|
|
this.snackMessages.splice(0, 1);
|
|
|
|
}, this.duration);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|