Skip to content

Commit 9286b97

Browse files
committed
(feat) add file progress bar
1 parent f51fe72 commit 9286b97

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
.vac-progress-wrapper {
2+
position: absolute;
3+
left: 50%;
4+
top: 50%;
5+
transform: translate(-50%, -50%);
6+
z-index: 9;
7+
8+
circle {
9+
transition: stroke-dashoffset 0.35s;
10+
transform: rotate(-90deg);
11+
transform-origin: 50% 50%;
12+
}
13+
14+
.vac-progress-content {
15+
position: absolute;
16+
left: 50%;
17+
top: 50%;
18+
transform: translate(-50%, -50%);
19+
z-index: -1;
20+
margin-top: -2px;
21+
background-color: rgba(0, 0, 0, 0.7);
22+
border-radius: 50%;
23+
24+
.vac-progress-text {
25+
position: absolute;
26+
left: 50%;
27+
top: 50%;
28+
transform: translate(-50%, -50%);
29+
font-weight: bold;
30+
color: white;
31+
32+
.vac-progress-pourcent {
33+
font-size: 9px;
34+
font-weight: normal;
35+
}
36+
}
37+
}
38+
}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<template>
2+
<transition name="vac-fade-spinner" appear>
3+
<div v-if="!show" ref="progress" class="vac-progress-wrapper">
4+
<svg :height="radius * 2" :width="radius * 2">
5+
<circle
6+
stroke="rgba(255, 255, 255, 0.7)"
7+
:stroke-dasharray="circumference + ' ' + circumference"
8+
:style="{
9+
strokeDashoffset: strokeDashoffset,
10+
strokeLinecap: 'round'
11+
}"
12+
:stroke-width="stroke"
13+
fill="transparent"
14+
:r="normalizedRadius"
15+
:cx="radius"
16+
:cy="radius"
17+
/>
18+
</svg>
19+
<div
20+
class="vac-progress-content"
21+
:style="{
22+
height: radius * 2 - 19 + 'px',
23+
width: radius * 2 - 19 + 'px'
24+
}"
25+
>
26+
<div class="vac-progress-text">
27+
{{ progress }}<span class="vac-progress-pourcent">%</span>
28+
</div>
29+
</div>
30+
</div>
31+
</transition>
32+
</template>
33+
34+
<script>
35+
export default {
36+
name: 'ProgressBar',
37+
38+
props: {
39+
show: { type: Boolean, default: false },
40+
progress: { type: Number, default: 0 }
41+
},
42+
43+
data() {
44+
const radius = 35
45+
const stroke = 4
46+
const normalizedRadius = radius - stroke * 2
47+
const circumference = normalizedRadius * 2 * Math.PI
48+
49+
return {
50+
radius,
51+
stroke,
52+
normalizedRadius,
53+
circumference
54+
}
55+
},
56+
computed: {
57+
strokeDashoffset() {
58+
return this.circumference - (this.progress / 100) * this.circumference
59+
}
60+
}
61+
}
62+
</script>

src/lib/Message/MessageFiles/MessageFile/MessageFile.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@
88
@mouseleave="imageHover = false"
99
@click.stop="openFile('preview')"
1010
>
11+
<progress-bar
12+
v-if="file.progress >= 0"
13+
:style="{ top: `${imageResponsive.loaderTop}px` }"
14+
:show="isImageLoading"
15+
:progress="file.progress"
16+
/>
1117
<loader
18+
v-else
1219
:style="{ top: `${imageResponsive.loaderTop}px` }"
1320
:show="isImageLoading"
1421
>
@@ -62,13 +69,14 @@
6269

6370
<script>
6471
import Loader from '../../../../components/Loader/Loader'
72+
import ProgressBar from '../../../../components/ProgressBar/ProgressBar.vue'
6573
import SvgIcon from '../../../../components/SvgIcon/SvgIcon'
6674
6775
const { isImageFile, isVideoFile } = require('../../../../utils/media-file')
6876
6977
export default {
7078
name: 'MessageFile',
71-
components: { SvgIcon, Loader },
79+
components: { SvgIcon, Loader, ProgressBar },
7280
7381
props: {
7482
currentUserId: { type: [String, Number], required: true },

src/styles/index.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
@import '../components/FormatMessage/FormatMessage';
3131
@import '../components/Loader/Loader';
3232
@import '../components/SvgIcon/SvgIcon';
33+
@import '../components/ProgressBar/ProgressBar';

0 commit comments

Comments
 (0)