Skip to content

Commit 55c2819

Browse files
author
Guillaume Chau
committed
feat(ui): better build progress
1 parent 120be23 commit 55c2819

File tree

6 files changed

+209
-68
lines changed

6 files changed

+209
-68
lines changed

packages/@vue/cli-service/lib/webpack/DashboardPlugin.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ class DashboardPlugin {
100100
{
101101
type: 'status',
102102
value: 'Compiling'
103+
},
104+
{
105+
type: 'progress',
106+
value: 0
103107
}
104108
])
105109
})
@@ -167,7 +171,7 @@ class DashboardPlugin {
167171
},
168172
{
169173
type: 'progress',
170-
value: 0
174+
value: 1
171175
},
172176
{
173177
type: 'operations',

packages/@vue/cli-ui-addon-webpack/src/components/BuildProgress.vue

Lines changed: 127 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,69 @@
11
<template>
2-
<div class="build-progress">
2+
<div
3+
class="build-progress"
4+
:class="{
5+
[`mode-${mode}`]: true
6+
}"
7+
>
38
<div class="content">
4-
<loading-progress
5-
:progress="progress"
6-
size="128"
7-
counter-clockwise
8-
/>
9-
10-
<div class="progress">
11-
{{ typeof progress === 'number' ? Math.round(progress * 100) : 0 }}
12-
</div>
9+
<div class="progress-wrapper">
10+
<transition-group
11+
name="vue-ui-fade"
12+
class="progress-bars"
13+
>
14+
<div
15+
v-for="(key, index) of Object.keys(progress)"
16+
:key="key"
17+
class="progress-bar-wrapper"
18+
>
19+
<loading-progress
20+
:key="key"
21+
:progress="progress[key]"
22+
:size="128 - 16 * index"
23+
class="progress-bar"
24+
counter-clockwise
25+
:class="{
26+
'disable-animation': progress[key] === 0,
27+
[`mode-${key}`]: true
28+
}"
29+
/>
30+
</div>
31+
</transition-group>
1332

14-
<transition duration="500">
15-
<div v-if="status === 'Success'" class="status-icon done">
16-
<div class="wrapper">
17-
<VueIcon icon="check_circle"/>
33+
<div class="progress">
34+
<div
35+
class="progress-animation"
36+
:class="{
37+
active: status && status !== 'Idle'
38+
}"
39+
>
40+
<div
41+
v-for="n in 4"
42+
:key="n"
43+
class="animation"
44+
:style="{
45+
'animation-delay': `${n * 0.25}s`
46+
}"
47+
/>
1848
</div>
1949
</div>
20-
</transition>
2150

22-
<transition duration="500">
23-
<div v-if="status === 'Failed'" class="status-icon error">
24-
<div class="wrapper">
25-
<VueIcon icon="error"/>
51+
<transition duration="500">
52+
<div v-if="status === 'Success'" class="status-icon done">
53+
<div class="wrapper">
54+
<VueIcon icon="check_circle"/>
55+
</div>
2656
</div>
27-
</div>
28-
</transition>
57+
</transition>
58+
59+
<transition duration="500">
60+
<div v-if="status === 'Failed'" class="status-icon error">
61+
<div class="wrapper">
62+
<VueIcon icon="error"/>
63+
</div>
64+
</div>
65+
</transition>
66+
</div>
2967

3068
<div class="operations">
3169
<span v-if="operations">{{ operations }}</span>
@@ -43,18 +81,23 @@
4381
import { mapGetters } from 'vuex'
4482
4583
export default {
46-
computed: {
47-
...mapGetters([
48-
'mode'
49-
])
50-
},
51-
5284
sharedData () {
5385
return mapSharedData('org.vue.webpack.', {
5486
status: `${this.mode}-status`,
55-
progress: `${this.mode}-progress`,
87+
rawProgress: `${this.mode}-progress`,
5688
operations: `${this.mode}-operations`
5789
})
90+
},
91+
92+
computed: {
93+
...mapGetters([
94+
'mode'
95+
]),
96+
97+
progress () {
98+
const raw = this.rawProgress
99+
return raw && Object.keys(raw).length ? raw : { unknown: 0 }
100+
}
58101
}
59102
}
60103
</script>
@@ -87,6 +130,12 @@ export default {
87130
&:first-letter
88131
text-transform uppercase
89132
133+
.progress-wrapper
134+
width 178px
135+
height @width
136+
position relative
137+
138+
.progress-bar-wrapper,
90139
.progress,
91140
.status-icon
92141
h-box()
@@ -96,12 +145,36 @@ export default {
96145
top 0
97146
left 0
98147
width 100%
99-
height 178px
148+
height @width
149+
150+
.progress-bar
151+
&.disable-animation
152+
>>> path
153+
transition none
154+
&.mode-build-modern
155+
>>> .progress
156+
stroke $vue-ui-color-info
100157
101-
.progress
102-
color lighten($vue-ui-color-dark, 60%)
103-
font-weight lighter
104-
font-size 42px
158+
.progress-animation
159+
display grid
160+
$size = 12px
161+
grid-template-columns repeat(2, $size)
162+
grid-template-rows repeat(2, $size)
163+
grid-template-areas "z1 z4" "z2 z3"
164+
grid-gap 12px
165+
.animation
166+
width 100%
167+
height @width
168+
border-radius 50%
169+
background rgba(black, .1)
170+
transition background .15s
171+
for n in (1..4)
172+
&:nth-child({n})
173+
grid-area 'z%s' % n
174+
&.active
175+
.animation
176+
background $vue-ui-color-primary
177+
animation progress 1s infinite
105178
106179
.status-icon
107180
.wrapper
@@ -161,4 +234,25 @@ export default {
161234
opacity 0
162235
&.v-leave-to
163236
opacity 0
237+
238+
&.mode-build-modern
239+
.progress-animation.active
240+
.animation
241+
background $vue-ui-color-info
242+
243+
.status-icon
244+
&.done
245+
.wrapper::before
246+
background $vue-ui-color-info
247+
>>> svg
248+
fill $vue-ui-color-info
249+
250+
@keyframes progress
251+
0%,
252+
30%
253+
transform none
254+
50%
255+
transform scale(1.5)
256+
80%
257+
transform none
164258
</style>

packages/@vue/cli-ui-addon-webpack/src/components/WebpackAnalyzer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<div class="title">{{ $t('org.vue.vue-webpack.analyzer.title') }}</div>
66

77
<VueSwitch
8-
v-if="modernMode"
8+
v-if="mode !== 'serve' && modernMode"
99
v-model="showModernBuild"
1010
>
1111
{{ $t('org.vue.vue-webpack.modern-mode') }}

packages/@vue/cli-ui-addon-webpack/src/components/WebpackDashboard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</template>
2222

2323
<VueSwitch
24-
v-if="modernMode"
24+
v-if="mode !== 'serve' && modernMode"
2525
v-model="showModernBuild"
2626
>
2727
{{ $t('org.vue.vue-webpack.modern-mode') }}

0 commit comments

Comments
 (0)