-
Notifications
You must be signed in to change notification settings - Fork 569
Expand file tree
/
Copy pathLoadingPlaceholder.vue
More file actions
216 lines (185 loc) · 4.59 KB
/
Copy pathLoadingPlaceholder.vue
File metadata and controls
216 lines (185 loc) · 4.59 KB
1
2
3
4
5
6
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
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
206
207
208
209
210
211
212
213
214
215
216
<!--
- SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<ul :class="'placeholder-list placeholder-list--' + type">
<li v-for="(item, index) in placeholderData" :key="index" class="placeholder-item">
<div
v-if="type !== 'event-cards'"
class="placeholder-item__avatar"
:style="{ '--avatar-size': item.avatarSize }">
<div class="placeholder-item__avatar-circle" />
</div>
<div class="placeholder-item__content" :style="{ '--last-line-width': item.width }">
<div v-for="idx in item.amount" :key="idx" class="placeholder-item__content-line" />
</div>
<div v-if="type === 'messages'" class="placeholder-item__info" />
</li>
</ul>
</template>
<script>
import { AVATAR } from '../../constants.ts'
export default {
name: 'LoadingPlaceholder',
props: {
type: {
type: String,
required: true,
validator(value) {
return ['conversations', 'messages', 'participants', 'event-cards'].includes(value)
},
},
count: {
type: Number,
default: 5,
},
},
computed: {
placeholderData() {
const data = []
for (let i = 0; i < this.count; i++) {
// set up amount of lines in skeleton and generate random widths for last line
data.push({
amount: this.type === 'messages'
? 4
: this.type === 'conversations' ? 2 : 1,
width: this.type === 'participants'
? '60%'
: this.type === 'event-cards' ? '100%' : (Math.floor(Math.random() * 40) + 30) + '%',
avatarSize: (this.type === 'messages' ? AVATAR.SIZE.SMALL : AVATAR.SIZE.DEFAULT) + 'px',
})
}
return data
},
},
}
</script>
<style lang="scss" scoped>
@use '../../assets/variables.scss' as *;
.placeholder-list {
width: 100%;
transform: translateZ(0); // enable hardware acceleration
}
.placeholder-item {
display: flex;
gap: 8px;
width: 100%;
&__avatar {
flex-shrink: 0;
&-circle {
height: var(--avatar-size);
width: var(--avatar-size);
border-radius: var(--avatar-size);
}
}
&__content {
display: flex;
flex-direction: column;
width: 100%;
&-line {
margin: 5px 0 4px;
width: 100%;
height: 15px;
&:last-child {
width: var(--last-line-width);
}
}
}
}
// Conversations placeholder ruleset
.placeholder-list--conversations {
.placeholder-item {
margin: 2px 0;
padding: 8px 10px;
&__content {
width: 70%;
}
}
}
// Messages placeholder ruleset
.placeholder-list--messages {
max-width: $messages-list-max-width;
margin: auto;
.placeholder-item {
padding-inline-end: 8px;
&__avatar {
width: 48px;
padding: 20px 8px 0;
}
&__content {
max-width: $messages-text-max-width;
padding: 12px 0;
&-line {
margin: 4px 0 3px;
&:first-child {
margin-bottom: 9px;
width: 20%;
}
}
}
&__info {
width: 100px;
height: 15px;
margin-block: var(--default-clickable-area) 0;
margin-inline: 8px var(--default-clickable-area);
animation-delay: 0.8s;
}
}
}
// Participants placeholder ruleset
.placeholder-list--participants {
.placeholder-item {
--padding: calc(var(--default-grid-baseline) * 2);
gap: calc(var(--default-grid-baseline) * 2);
padding: calc(var(--padding) * 3 / 2) var(--padding) var(--padding);
height: 59px;
align-items: center;
&__avatar {
margin: auto;
}
}
}
// Event cards placeholder ruleset
.placeholder-list--event-cards {
display: flex;
gap: calc(var(--default-grid-baseline) * 2);
flex-wrap: nowrap;
overflow: hidden;
margin-bottom: calc(var(--default-grid-baseline) * 2);
margin-top: calc(var(--default-grid-baseline) * 2);
.placeholder-item {
&:first-child {
margin-inline-start: var(--dashboard-section-inline-padding);
}
&__content {
width: 300px;
&-line {
margin: 0;
height: 175px;
background-color: var(--color-primary-element-light);
border-radius: var(--border-radius-large);
// Tinted shimmer, to match the event cards this stands in for
background-image: linear-gradient(90deg, var(--color-primary-element-light-hover) 65%, var(--color-primary-element-light) 70%, var(--color-primary-element-light-hover) 75%);
}
}
}
}
// Animation
.placeholder-item__avatar-circle,
.placeholder-item__content-line,
.placeholder-item__info {
background-size: 200vw;
background-image: linear-gradient(90deg, var(--color-placeholder-dark) 65%, var(--color-placeholder-light) 70%, var(--color-placeholder-dark) 75%);
animation: loading-animation 3s forwards infinite linear;
will-change: background-position;
}
@keyframes loading-animation {
0% {
background-position: 0;
}
100% {
background-position: 140vw;
}
}
</style>