forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgressButton.vue
More file actions
72 lines (70 loc) · 1.52 KB
/
ProgressButton.vue
File metadata and controls
72 lines (70 loc) · 1.52 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
<template>
<button class="q-progress-button" :class="{active: active, indeterminate: indeterminate}">
<span
v-if="!indeterminate"
class="q-progress-button-filler"
:class="{'q-progress-button-dark-filler': darkFiller}"
:style="{width: computedPercentage}"
></span>
<div
class="q-progress-button-content"
:class="stateClass"
>
<div class="q-progress-button-error">
<i>{{ errorIcon }}</i>
</div>
<div class="q-progress-button-label">
<slot></slot>
</div>
<div class="q-progress-button-success">
<i>{{ successIcon }}</i>
</div>
</div>
</button>
</template>
<script>
export default {
props: {
percentage: {
type: Number,
required: true
},
errorIcon: {
type: String,
default: 'warning'
},
successIcon: {
type: String,
default: 'done'
},
darkFiller: {
type: Boolean,
default: false
},
indeterminate: {
type: Boolean,
default: false
}
},
computed: {
active () {
return this.percentage > 0 && this.percentage < 100
},
stateClass () {
if (this.percentage >= 100) {
return 'q-progress-button-complete'
}
if (this.percentage < 0) {
return 'q-progress-button-incomplete'
}
return 'q-progress-button-default'
},
computedPercentage () {
if (this.percentage >= 100) {
return '0%'
}
return Math.max(0, this.percentage) + '%'
}
}
}
</script>