-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathLoaderRow.js
72 lines (63 loc) · 1.83 KB
/
LoaderRow.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
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import css from './MCLRenderer.css';
class LoaderRow extends Component {
static propTypes = {
askAmount: PropTypes.number,
className: PropTypes.string,
columns: PropTypes.arrayOf(PropTypes.string),
columnWidths: PropTypes.object,
height: PropTypes.number,
loadMore: PropTypes.func,
minWidth: PropTypes.number,
rowIndex: PropTypes.number,
styleTop: PropTypes.number,
visible: PropTypes.bool,
};
static defaultProps = {
loadMore: () => {},
visible: true,
};
componentDidMount() {
const { loadMore, askAmount, rowIndex } = this.props;
loadMore(askAmount, rowIndex);
}
componentDidUpdate() {
const { loadMore, askAmount, rowIndex } = this.props;
loadMore(askAmount, rowIndex);
}
render() {
const { className, height, columns, visible, columnWidths, styleTop, rowIndex, minWidth } = this.props;
if (visible) {
return (
<div
data-loader-row-index={rowIndex}
className={css.mclLoaderRow}
style={{ height, top: `${styleTop}px` }}
>
<div
data-loader
className={className}
style={{ height, minWidth }}
>
{
columns.map((c, i) => {
let style = { display: 'flex', flexBasis:'auto' };
if (columnWidths && columnWidths[c]) {
style = { width: `${columnWidths[c]}px` };
}
return (
<div key={`${c}-${i}`} className={css.mclCell} style={style}>
<div className={css.mclRowPlaceholder} />
</div>
);
})
}
</div>
</div>
);
}
return null;
}
}
export default LoaderRow;