-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
104 lines (95 loc) · 2.6 KB
/
index.js
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
import React, { Component } from 'react'
import moment from 'moment'
import Timeline from 'react-calendar-timeline'
import containerResizeDetector from '../../../src/resize-detector/container'
// you would use this in real life:
// import containerResizeDetector from 'react-calendar-timeline/lib/resize-detector/container'
import generateFakeData from '../generate-fake-data'
var keys = {
groupIdKey: 'id',
groupTitleKey: 'title',
groupRightTitleKey: 'rightTitle',
itemIdKey: 'id',
itemTitleKey: 'title',
itemDivTitleKey: 'title',
itemGroupKey: 'group',
itemTimeStartKey: 'start',
itemTimeEndKey: 'end'
}
export default class App extends Component {
constructor(props) {
super(props)
const { groups, items } = generateFakeData(10, 200)
const defaultTimeStart = moment()
.startOf('day')
.toDate()
const defaultTimeEnd = moment()
.startOf('day')
.add(1, 'day')
.toDate()
const width = 80
this.state = {
groups,
items,
defaultTimeStart,
defaultTimeEnd,
width
}
}
render() {
const {
groups,
items,
defaultTimeStart,
defaultTimeEnd,
width
} = this.state
return (
<div>
<div style={{ width: `${width}%`, float: 'left' }}>
<Timeline
groups={groups}
items={items}
keys={keys}
sidebarWidth={150}
sidebarContent={<div>Above The Left er aew rawe rwea rwae</div>}
rightSidebarWidth={150}
rightSidebarContent={<div>Above The Right</div>}
canMove
canResize="right"
canSelect
itemsSorted
itemTouchSendsClick={false}
stackItems
itemHeightRatio={0.75}
resizeDetector={containerResizeDetector}
defaultTimeStart={defaultTimeStart}
defaultTimeEnd={defaultTimeEnd}
/>
</div>
<div style={{ width: `${100 - width}%`, float: 'left' }}>
<div style={{ padding: 20 }}>
The timeline is {width}% wide.
<br />
<br />
Set containers width:
<br />
{[20, 40, 60, 80].map(p => (
<span
key={p}
onClick={() => this.setState({ width: p })}
style={{
cursor: 'pointer',
marginLeft: 10,
textDecoration: p === width ? 'underline' : 'none'
}}
>
{p}%
</span>
))}
</div>
</div>
</div>
)
}
}