forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQSeparator.js
More file actions
94 lines (76 loc) · 1.88 KB
/
QSeparator.js
File metadata and controls
94 lines (76 loc) · 1.88 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
import Vue from 'vue'
import DarkMixin from '../../mixins/dark.js'
import ListenersMixin from '../../mixins/listeners.js'
const insetMap = {
true: 'inset',
item: 'item-inset',
'item-thumbnail': 'item-thumbnail-inset'
}
export const margins = {
xs: 2,
sm: 4,
md: 8,
lg: 16,
xl: 24
}
export default Vue.extend({
name: 'QSeparator',
mixins: [ DarkMixin, ListenersMixin ],
props: {
spaced: [ Boolean, String ],
inset: [ Boolean, String ],
vertical: Boolean,
color: String,
size: String
},
computed: {
orientation () {
return this.vertical === true
? 'vertical'
: 'horizontal'
},
classPrefix () {
return ` q-separator--${this.orientation}`
},
insetClass () {
return this.inset !== false
? `${this.classPrefix}-${insetMap[this.inset]}`
: ''
},
classes () {
return `q-separator${this.classPrefix}${this.insetClass}` +
(this.color !== void 0 ? ` bg-${this.color}` : '') +
(this.isDark === true ? ' q-separator--dark' : '')
},
style () {
const style = {}
if (this.size !== void 0) {
style[ this.vertical === true ? 'width' : 'height' ] = this.size
}
if (this.spaced !== false) {
const size = this.spaced === true
? `${margins.md}px`
: this.spaced in margins ? `${margins[this.spaced]}px` : this.spaced
const props = this.vertical === true
? [ 'Left', 'Right' ]
: [ 'Top', 'Bottom' ]
style[`margin${props[0]}`] = style[`margin${props[1]}`] = size
}
return style
},
attrs () {
return {
'aria-orientation': this.orientation
}
}
},
render (h) {
return h('hr', {
staticClass: 'q-separator',
class: this.classes,
style: this.style,
attrs: this.attrs,
on: { ...this.qListeners }
})
}
})