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
86 lines (67 loc) · 1.96 KB
/
QSeparator.js
File metadata and controls
86 lines (67 loc) · 1.96 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
import { h, computed, getCurrentInstance } from 'vue'
import useDark, { useDarkProps } from '../../composables/private/use-dark.js'
import { createComponent } from '../../utils/private/create.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 createComponent({
name: 'QSeparator',
props: {
...useDarkProps,
spaced: [ Boolean, String ],
inset: [ Boolean, String ],
vertical: Boolean,
color: String,
size: String
},
setup (props) {
const vm = getCurrentInstance()
const isDark = useDark(props, vm.proxy.$q)
const orientation = computed(() => (
props.vertical === true
? 'vertical'
: 'horizontal'
))
const orientClass = computed(() => ` q-separator--${ orientation.value }`)
const insetClass = computed(() => (
props.inset !== false
? `${ orientClass.value }-${ insetMap[ props.inset ] }`
: ''
))
const classes = computed(() =>
`q-separator${ orientClass.value }${ insetClass.value }`
+ (props.color !== void 0 ? ` bg-${ props.color }` : '')
+ (isDark.value === true ? ' q-separator--dark' : '')
)
const style = computed(() => {
const acc = {}
if (props.size !== void 0) {
acc[ props.vertical === true ? 'width' : 'height' ] = props.size
}
if (props.spaced !== false) {
const size = props.spaced === true
? `${ margins.md }px`
: props.spaced in margins ? `${ margins[ props.spaced ] }px` : props.spaced
const dir = props.vertical === true
? [ 'Left', 'Right' ]
: [ 'Top', 'Bottom' ]
acc[ `margin${ dir[ 0 ] }` ] = acc[ `margin${ dir[ 1 ] }` ] = size
}
return acc
})
return () => h('hr', {
class: classes.value,
style: style.value,
'aria-orientation': orientation.value
})
}
})