Newer
Older
<template>
<div
v-if="messages && messages.length > 0"
class="row over-content"
>
<div class="fourteen wide column">
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<ul
class="message-list"
aria-live="assertive"
>
<li
v-for="message in messages"
:key="'message-' + message.counter"
:ref="'message-' + message.counter"
:class="['list-container', { 'show': removedItem !== message.counter }]"
>
<div :class="['list-item', { 'show': removedItem !== message.counter }]">
<div :class="['ui', message.level ? message.level : 'info', 'message']">
<i
class="close icon"
aria-hidden="true"
@click="removeListItem(message.counter)"
/>
<div class="header">
<i
class="info circle icon"
aria-hidden="true"
/>
Informations
</div>
<ul class="list">
{{
message.comment
}}
</ul>
</div>
</div>
</li>
</ul>
<!-- <transition-group name="fadeDownUp">
<div
v-for="(message, index) in messages"
:key="'message-' + index"
:class="['ui', message.level ? message.level : 'info', 'message']"
>
<i
class="close icon"
aria-hidden="true"
@click="DISCARD_MESSAGE(message)"
/>
<div class="header">
<i
class="info circle icon"
aria-hidden="true"
/>
Informations
</div>
<ul class="list">
{{
message.comment
}}
</ul>
</div>
</template>
<script>
import { mapState, mapMutations } from 'vuex';
export default {
name: 'MessageInfo',
computed: {
...mapState(['messages']),
},
methods: {
...mapMutations(['DISCARD_MESSAGE']),
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
animateList() {
const listItems = document.querySelectorAll('.list-item');
function calculateHeightOfListContainer(){
const firstListItem = listItems[0];
let heightOfListItem = firstListItem.clientHeight;
const styleTag = document.createElement('style');
document.body.prepend(styleTag);
styleTag.innerHTML = `.list-container.show {
height: ${heightOfListItem}px;
}`;
//setTimeout(function(){
// styleTag.innerHTML += `.list-container {
// transition: all 0.6s ease-out;
// }`;
//}, 0);
}
calculateHeightOfListContainer();
},
removeListItem(messageCount){
const container = this.$refs['message-' + messageCount][0];
console.log(container);
container.ontransitionend = () => {
console.log('container removed');
this.DISCARD_MESSAGE(messageCount);
};
console.log(container.ontransitionend);
this.removedItem = messageCount; // starts the transition by removing class show (with height)
},
/* addElement(e){
const container = document.createElement('li'); container.classList.add('list-container'); container.setAttribute('role', 'listitem');
const listItem = document.createElement('div'); listItem.classList.add('list-item'); listItem.innerHTML = 'List Item';
container.append(listItem);
addBtn.parentNode.insertBefore(container, addBtn);
container.onclick = removeListItem;
setTimeout(function(){
container.classList.add('show'); listItem.classList.add('show');
}, 15);
} */
},
};
</script>
.row.over-content {
position: absolute; /* to display message info over page content */
z-index: 99;
opacity: 0.95;
width: calc(100% - 4em); /* 4em is #content left + right paddings */
top: calc(61px + 1em); /* 61px is #app-header height */
right: 2em; /* 2em is #content left paddings */
}
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
.message-list{
list-style: none;
}
.list-container{
list-style: none;
width: 100%;
height: 0;
position: relative;
cursor: pointer;
overflow: hidden;
transition: all 0.6s ease-out;
}
.list-container.show{
height: 95px;
}
.list-container.show:not(:first-child){
margin-top: 10px;
}
.list-container .list-item{
padding: .5rem 0;
width: 100%;
position: absolute;
opacity: 0;
top: 0;
left: 0;
transition: all 0.6s ease-out;
}
.list-container .list-item.show{
opacity: 1;
}
ul.list{
overflow: scroll;
height: 2em;
margin-bottom: .5em !important;
}
.ui.message {
overflow: hidden;
padding-bottom: 0 !important;
}
.ui.message::after {
content: "";
position: absolute;
bottom: 1em;
left: 1em;
right: 0;
width: calc(100% - 2em);
}
.ui.info.message::after {
box-shadow: 0px 0px 7px 13px rgb(248, 255, 255);
}
.ui.positive.message::after {
box-shadow: 0px 0px 7px 13px red;
}
.ui.negative.message::after {
box-shadow: 0px 0px 7px 13px red;
}
animation: fadeInDown .5s;
}
.fadeDownUp-leave-active {
animation: fadeOutUp .5s;
}
@keyframes fadeInDown {
from {
opacity: 0;
transform: translate3d(0, -100%, 0);
}
to {
opacity: 1;
transform: translate3d(0, 0, 0);
}
}
@keyframes fadeOutUp {
0% {
opacity: 1;
}
100% {
opacity: 0;
transform: translate3d(0, -100%, 0);
}
.ui.message > .close.icon {
cursor: pointer;
position: absolute;
margin: 0em;
top: 0.78575em;
right: 0.5em;
opacity: 0.7;
-webkit-transition: opacity 0.1s ease;
transition: opacity 0.1s ease;
}
</style>