mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +00:00
Refactor #3965 - For Toast
This commit is contained in:
parent
b96dff4711
commit
41c4194b27
5 changed files with 266 additions and 220 deletions
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<Portal>
|
||||
<div ref="container" :class="containerClass" v-bind="{ ...$attrs, ...ptm('root') }">
|
||||
<div ref="container" :class="cx('root')" v-bind="{ ...$attrs, ...ptm('root') }">
|
||||
<transition-group name="p-toast-message" tag="div" @enter="onEnter" @leave="onLeave" v-bind="ptm('message')">
|
||||
<ToastMessage
|
||||
v-for="msg of messages"
|
||||
|
@ -22,7 +22,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import BaseComponent from 'primevue/basecomponent';
|
||||
import BaseToast from './BaseToast.vue';
|
||||
import Portal from 'primevue/portal';
|
||||
import ToastEventBus from 'primevue/toasteventbus';
|
||||
import { ObjectUtils, UniqueComponentId, ZIndexUtils } from 'primevue/utils';
|
||||
|
@ -32,55 +32,10 @@ var messageIdx = 0;
|
|||
|
||||
export default {
|
||||
name: 'Toast',
|
||||
extends: BaseComponent,
|
||||
extends: BaseToast,
|
||||
inheritAttrs: false,
|
||||
emits: ['close', 'life-end'],
|
||||
props: {
|
||||
group: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
position: {
|
||||
type: String,
|
||||
default: 'top-right'
|
||||
},
|
||||
autoZIndex: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
baseZIndex: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
breakpoints: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
closeIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
infoIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
warnIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
errorIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
successIcon: {
|
||||
type: String,
|
||||
default: undefined
|
||||
},
|
||||
closeButtonProps: {
|
||||
type: null,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
messages: []
|
||||
|
@ -190,15 +145,6 @@ export default {
|
|||
}
|
||||
},
|
||||
computed: {
|
||||
containerClass() {
|
||||
return [
|
||||
'p-toast p-component p-toast-' + this.position,
|
||||
{
|
||||
'p-input-filled': this.$primevue.config.inputStyle === 'filled',
|
||||
'p-ripple-disabled': this.$primevue.config.ripple === false
|
||||
}
|
||||
];
|
||||
},
|
||||
attributeSelector() {
|
||||
return UniqueComponentId();
|
||||
}
|
||||
|
@ -209,99 +155,3 @@ export default {
|
|||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.p-toast {
|
||||
position: fixed;
|
||||
width: 25rem;
|
||||
}
|
||||
|
||||
.p-toast-message-content {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.p-toast-message-text {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.p-toast-top-right {
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
.p-toast-top-left {
|
||||
top: 20px;
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.p-toast-bottom-left {
|
||||
bottom: 20px;
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
.p-toast-bottom-right {
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
.p-toast-top-center {
|
||||
top: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.p-toast-bottom-center {
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
}
|
||||
|
||||
.p-toast-center {
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
min-width: 20vw;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.p-toast-icon-close {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.p-toast-icon-close.p-link {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
.p-toast-message-enter-from {
|
||||
opacity: 0;
|
||||
-webkit-transform: translateY(50%);
|
||||
-ms-transform: translateY(50%);
|
||||
transform: translateY(50%);
|
||||
}
|
||||
|
||||
.p-toast-message-leave-from {
|
||||
max-height: 1000px;
|
||||
}
|
||||
|
||||
.p-toast .p-toast-message.p-toast-message-leave-to {
|
||||
max-height: 0;
|
||||
opacity: 0;
|
||||
margin-bottom: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.p-toast-message-enter-active {
|
||||
-webkit-transition: transform 0.3s, opacity 0.3s;
|
||||
transition: transform 0.3s, opacity 0.3s;
|
||||
}
|
||||
|
||||
.p-toast-message-leave-active {
|
||||
-webkit-transition: max-height 0.45s cubic-bezier(0, 1, 0, 1), opacity 0.3s, margin-bottom 0.3s;
|
||||
transition: max-height 0.45s cubic-bezier(0, 1, 0, 1), opacity 0.3s, margin-bottom 0.3s;
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue