LiveTile.js
910 Bytes
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
import React from 'react';
import $ from 'jquery'
import PropTypes from 'prop-types';
/* eslint-disable */
import 'metrojs/release/MetroJs.Full/MetroJs';
/* eslint-enable */
import './LiveTile.scss';
class LiveTile extends React.Component {
static propTypes = {
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
};
static defaultProps = {
children: null,
};
constructor(props) {
super(props);
this.state = {
id: `live-tile-${Math.floor(Math.random() * 255)}`,
};
}
componentDidMount() {
const el = $(`#${this.state.id}`);
el.css('height', el.data('height'))
.liveTile();
}
render() {
const {
children,
...attr
} = this.props;
return (
<div {...attr} id={this.state.id} className="live-tile">
{children}
</div>
);
}
}
export default LiveTile;