/
vertical-view-layout.jsx
90 lines (82 loc) · 2.47 KB
/
vertical-view-layout.jsx
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
import * as React from 'react';
import * as PropTypes from 'prop-types';
import { AUTO_HEIGHT } from '@devexpress/dx-scheduler-core';
import Grid from '@material-ui/core/Grid';
import RootRef from '@material-ui/core/RootRef';
import { withStyles } from '@material-ui/core/styles';
const styles = theme => ({
container: {
overflowY: 'auto',
},
stickyHeader: {
top: 0,
zIndex: 1,
tableLayout: 'fixed',
position: 'sticky',
overflow: 'visible',
background: theme.palette.background.paper,
},
timeTable: {
position: 'relative',
},
});
export class VerticalViewLayoutBase extends React.PureComponent {
render() {
const {
timeScaleComponent: TimeScale,
dayScaleComponent: DayScale,
timeTableComponent: TimeTable,
dayScaleEmptyCellComponent: DayScaleEmptyCell,
classes,
layoutRef,
layoutHeaderRef,
height,
} = this.props;
const containerStyle = height === AUTO_HEIGHT ? { height: '100%' } : { height: `${height}px` };
return (
<RootRef rootRef={layoutRef}>
<Grid
container
className={classes.container}
direction="column"
wrap="nowrap"
style={containerStyle}
>
<RootRef rootRef={layoutHeaderRef}>
<Grid
container
direction="row"
className={classes.stickyHeader}
>
<Grid item xs={1} className={classes.emptySpace}>
<DayScaleEmptyCell />
</Grid>
<Grid item xs={11}>
<DayScale />
</Grid>
</Grid>
</RootRef>
<Grid container direction="row">
<Grid item xs={1}>
<TimeScale />
</Grid>
<Grid item xs={11} className={classes.timeTable}>
<TimeTable />
</Grid>
</Grid>
</Grid>
</RootRef>
);
}
}
VerticalViewLayoutBase.propTypes = {
timeScaleComponent: PropTypes.func.isRequired,
dayScaleComponent: PropTypes.func.isRequired,
timeTableComponent: PropTypes.func.isRequired,
dayScaleEmptyCellComponent: PropTypes.func.isRequired,
classes: PropTypes.object.isRequired,
layoutRef: PropTypes.object.isRequired,
layoutHeaderRef: PropTypes.object.isRequired,
height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
};
export const VerticalViewLayout = withStyles(styles, { name: 'VerticalViewLayout' })(VerticalViewLayoutBase);