adrema/resources/js/components/VNotification.vue

46 lines
1.3 KiB
Vue
Raw Permalink Normal View History

2021-06-22 23:00:14 +02:00
<template>
<div class="grid gap-2 has-contents">
<transition-group name="fadeRight" tag="div">
2022-02-12 15:19:59 +01:00
<div v-for="item, index in items" :key="'i'+index"
2022-02-10 02:18:57 +01:00
:class="`${colors[item.type].bg} ${colors[item.type].text} h-12 flex flex-col items-start justify-center shadow-2xl rounded-sm px-6`"
2021-06-22 23:00:14 +02:00
>
2022-02-12 15:19:59 +01:00
<div class="text-sm" v-for="message, mindex in item.messages" :key="mindex" v-text="message"></div>
2021-06-22 23:00:14 +02:00
</div>
</transition-group>
</div>
</template>
<script>
export default {
2022-02-10 02:18:57 +01:00
data: function() {
return {
colors: {
red: {
bg: 'bg-red-300',
text: 'text-red-800'
},
green: {
bg: 'bg-green-300',
text: 'text-green-800'
}
}
};
},
2021-06-22 23:00:14 +02:00
computed: {
items() {
var i = [];
for (const field in this.$page.props.errors) {
i.push({ messages: this.$page.props.errors[field], type: 'red' });
}
if (this.$page.props.flash && this.$page.props.flash.success) {
i.push({ messages: [ this.$page.props.flash.success ], type: 'green' });
}
return i;
}
}
};
</script>