forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQLinearProgress.js
More file actions
134 lines (111 loc) · 3.15 KB
/
QLinearProgress.js
File metadata and controls
134 lines (111 loc) · 3.15 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
import Vue from 'vue'
import DarkMixin from '../../mixins/dark.js'
import { getSizeMixin } from '../../mixins/size.js'
import ListenersMixin from '../../mixins/listeners.js'
import { mergeSlot } from '../../utils/slot.js'
function width (val, reverse, $q) {
return {
transform: reverse === true
? `translateX(${$q.lang.rtl === true ? '-' : ''}100%) scale3d(${-val},1,1)`
: `scale3d(${val},1,1)`
}
}
export default Vue.extend({
name: 'QLinearProgress',
mixins: [
ListenersMixin,
DarkMixin,
getSizeMixin({
xs: 2,
sm: 4,
md: 6,
lg: 10,
xl: 14
})
],
props: {
value: {
type: Number,
default: 0
},
buffer: Number,
color: String,
trackColor: String,
reverse: Boolean,
stripe: Boolean,
indeterminate: Boolean,
query: Boolean,
rounded: Boolean,
instantFeedback: Boolean
},
computed: {
motion () {
return this.indeterminate === true || this.query === true
},
widthReverse () {
return this.reverse !== this.query
},
classes () {
return 'q-linear-progress' +
(this.color !== void 0 ? ` text-${this.color}` : '') +
(this.reverse === true || this.query === true ? ' q-linear-progress--reverse' : '') +
(this.rounded === true ? ' rounded-borders' : '')
},
trackStyle () {
return width(this.buffer !== void 0 ? this.buffer : 1, this.widthReverse, this.$q)
},
trackClass () {
return `q-linear-progress__track--with${this.instantFeedback === true ? 'out' : ''}-transition` +
` q-linear-progress__track--${this.isDark === true ? 'dark' : 'light'}` +
(this.trackColor !== void 0 ? ` bg-${this.trackColor}` : '')
},
modelStyle () {
return width(this.motion === true ? 1 : this.value, this.widthReverse, this.$q)
},
modelClasses () {
return `q-linear-progress__model--with${this.instantFeedback === true ? 'out' : ''}-transition` +
` q-linear-progress__model--${this.motion === true ? 'in' : ''}determinate`
},
stripeStyle () {
return { width: (this.value * 100) + '%' }
},
stripeClass () {
return this.reverse === true ? 'absolute-right' : 'absolute-left'
},
attrs () {
return {
role: 'progressbar',
'aria-valuemin': 0,
'aria-valuemax': 1,
'aria-valuenow': this.indeterminate === true ? void 0 : this.value
}
}
},
render (h) {
const child = [
h('div', {
staticClass: 'q-linear-progress__track absolute-full',
style: this.trackStyle,
class: this.trackClass
}),
h('div', {
staticClass: 'q-linear-progress__model absolute-full',
style: this.modelStyle,
class: this.modelClasses
})
]
this.stripe === true && this.motion === false && child.push(
h('div', {
staticClass: 'q-linear-progress__stripe',
style: this.stripeStyle,
class: this.stripeClass
})
)
return h('div', {
style: this.sizeStyle,
class: this.classes,
attrs: this.attrs,
on: { ...this.qListeners }
}, mergeSlot(child, this, 'default'))
}
})