forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQToggle.js
More file actions
59 lines (58 loc) · 1.43 KB
/
QToggle.js
File metadata and controls
59 lines (58 loc) · 1.43 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
import CheckboxMixin from '../../mixins/checkbox'
import OptionMixin from '../../mixins/option'
import { QIcon } from '../icon'
export default {
name: 'QToggle',
mixins: [CheckboxMixin, OptionMixin],
props: {
icon: String
},
computed: {
currentIcon () {
return (this.isTrue ? this.checkedIcon : this.uncheckedIcon) || this.icon
},
iconColor () {
return __THEME__ === 'ios'
? 'dark'
: (this.isTrue ? 'white' : 'dark')
},
baseClass () {
if (__THEME__ === 'ios' && this.dark) {
return `q-toggle-base-dark`
}
}
},
methods: {
__swipe (evt) {
if (evt.direction === 'left') {
if (this.isTrue) {
this.toggle()
}
}
else if (evt.direction === 'right') {
if (this.isFalse) {
this.toggle()
}
}
},
__getContent (h) {
return [
h('div', { staticClass: 'q-toggle-base', 'class': this.baseClass }),
h('div', { staticClass: 'q-toggle-handle row flex-center' }, [
this.currentIcon
? h(QIcon, {
staticClass: 'q-toggle-icon',
props: { name: this.currentIcon, color: this.iconColor }
})
: null,
__THEME__ === 'mat'
? h('div', { ref: 'ripple', staticClass: 'q-radial-ripple' })
: null
])
]
}
},
beforeCreate () {
this.__kebabTag = 'q-toggle'
}
}