mirror of
https://github.com/frappe/books.git
synced 2024-11-12 16:36:27 +00:00
feat: add colored toasts
This commit is contained in:
parent
d4cfbca7df
commit
2508993d47
@ -2,7 +2,6 @@
|
|||||||
<div
|
<div
|
||||||
class="
|
class="
|
||||||
text-gray-900
|
text-gray-900
|
||||||
bg-white
|
|
||||||
shadow-md
|
shadow-md
|
||||||
px-3
|
px-3
|
||||||
py-2
|
py-2
|
||||||
@ -12,20 +11,31 @@
|
|||||||
mb-3
|
mb-3
|
||||||
w-60
|
w-60
|
||||||
"
|
"
|
||||||
|
:class="bgColor"
|
||||||
style="transition: opacity 150ms ease-in"
|
style="transition: opacity 150ms ease-in"
|
||||||
:style="{ opacity }"
|
:style="{ opacity }"
|
||||||
v-if="show"
|
v-if="show"
|
||||||
>
|
>
|
||||||
<feather-icon name="alert-circle" class="w-8 h-8 mr-3 text-gray-800" />
|
<feather-icon
|
||||||
|
:name="iconName"
|
||||||
|
class="w-8 h-8 mr-3 text-gray-800"
|
||||||
|
:class="iconColor"
|
||||||
|
/>
|
||||||
<div>
|
<div>
|
||||||
<p class="text-base">{{ message }}</p>
|
<p class="text-base">{{ message }}</p>
|
||||||
<button v-if="actionText" @click="action" class="text-sm text-gray-700 hover:text-gray-800">
|
<button
|
||||||
|
v-if="actionText"
|
||||||
|
@click="action"
|
||||||
|
class="text-sm text-gray-700 hover:text-gray-800"
|
||||||
|
>
|
||||||
{{ actionText }}
|
{{ actionText }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
import { getBgColorClass, getTextColorClass } from '../colors';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return { opacity: 0, show: true };
|
return { opacity: 0, show: true };
|
||||||
@ -34,8 +44,35 @@ export default {
|
|||||||
message: String,
|
message: String,
|
||||||
action: Function,
|
action: Function,
|
||||||
actionText: String,
|
actionText: String,
|
||||||
|
type: { type: String, default: 'info' },
|
||||||
duration: { type: Number, default: 5000 },
|
duration: { type: Number, default: 5000 },
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
iconName() {
|
||||||
|
switch (this.type) {
|
||||||
|
case 'warning':
|
||||||
|
return 'alert-triangle';
|
||||||
|
case 'success':
|
||||||
|
return 'check-circle';
|
||||||
|
default:
|
||||||
|
return 'alert-circle';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
color() {
|
||||||
|
return {
|
||||||
|
info: 'blue',
|
||||||
|
warning: 'orange',
|
||||||
|
error: 'red',
|
||||||
|
success: 'green',
|
||||||
|
}[this.type];
|
||||||
|
},
|
||||||
|
bgColor() {
|
||||||
|
return getBgColorClass(this.color);
|
||||||
|
},
|
||||||
|
iconColor() {
|
||||||
|
return getTextColorClass(this.color);
|
||||||
|
},
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
const mountTarget = document.createElement('div');
|
const mountTarget = document.createElement('div');
|
||||||
mountTarget.id = 'toast-target';
|
mountTarget.id = 'toast-target';
|
||||||
|
Loading…
Reference in New Issue
Block a user