forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQTimelineEntry.js
More file actions
123 lines (100 loc) · 2.58 KB
/
QTimelineEntry.js
File metadata and controls
123 lines (100 loc) · 2.58 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
import Vue from 'vue'
import QIcon from '../icon/QIcon.js'
import ListenersMixin from '../../mixins/listeners.js'
import { slot, uniqueSlot } from '../../utils/slot.js'
export default Vue.extend({
name: 'QTimelineEntry',
inject: {
__timeline: {
default () {
console.error('QTimelineEntry needs to be child of QTimeline')
}
}
},
mixins: [ ListenersMixin ],
props: {
heading: Boolean,
tag: {
type: String,
default: 'h3'
},
side: {
type: String,
default: 'right',
validator: v => ['left', 'right'].includes(v)
},
icon: String,
avatar: String,
color: String,
title: String,
subtitle: String,
body: String
},
computed: {
colorClass () {
return `text-${this.color || this.__timeline.color}`
},
classes () {
return `q-timeline__entry--${this.side}` +
(this.icon !== void 0 || this.avatar !== void 0 ? ' q-timeline__entry--icon' : '')
},
reverse () {
return this.__timeline.layout === 'comfortable' && this.__timeline.side === 'left'
}
},
render (h) {
const child = uniqueSlot(this, 'default', [])
if (this.body !== void 0) {
child.unshift(this.body)
}
if (this.heading === true) {
const content = [
h('div'),
h('div'),
h(
this.tag,
{ staticClass: 'q-timeline__heading-title' },
child
)
]
return h('div', {
staticClass: 'q-timeline__heading',
on: { ...this.qListeners }
}, this.reverse === true ? content.reverse() : content)
}
let dot
if (this.icon !== void 0) {
dot = [
h(QIcon, {
staticClass: 'row items-center justify-center',
props: { name: this.icon }
})
]
}
else if (this.avatar !== void 0) {
dot = [
h('img', {
staticClass: 'q-timeline__dot-img',
domProps: { src: this.avatar }
})
]
}
const content = [
h('div', { staticClass: 'q-timeline__subtitle' }, [
h('span', slot(this, 'subtitle', [ this.subtitle ]))
]),
h('div', {
staticClass: 'q-timeline__dot',
class: this.colorClass
}, dot),
h('div', { staticClass: 'q-timeline__content' }, [
h('h6', { staticClass: 'q-timeline__title' }, slot(this, 'title', [ this.title ]))
].concat(child))
]
return h('li', {
staticClass: 'q-timeline__entry',
class: this.classes,
on: { ...this.qListeners }
}, this.reverse === true ? content.reverse() : content)
}
})