File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ import React , { Component } from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
+ import TintedHeader from '../../components/misc/TintedHeader' ;
4
+
5
+ class LoadingLarge extends Component {
6
+ static propTypes = {
7
+ children : PropTypes . oneOfType ( [
8
+ PropTypes . node ,
9
+ PropTypes . arrayOf ( PropTypes . node ) ,
10
+ ] ) . isRequired ,
11
+ loading : PropTypes . bool ,
12
+ data : PropTypes . any ,
13
+ title : PropTypes . string ,
14
+ minimun : PropTypes . number ,
15
+ } ;
16
+
17
+ static defaultProps = {
18
+ title : 'Loading...' ,
19
+ minimun : 800 ,
20
+ }
21
+
22
+ constructor ( props ) {
23
+ super ( props ) ;
24
+ this . state = {
25
+ minimunElapsed : false ,
26
+ } ;
27
+ }
28
+
29
+ componentDidMount ( ) {
30
+ setTimeout ( ( ) => {
31
+ this . setState ( {
32
+ minimunElapsed : true ,
33
+ } ) ;
34
+ } , this . props . minimun ) ;
35
+ }
36
+
37
+ render ( ) {
38
+ return (
39
+ < div >
40
+ {
41
+ ( this . state . minimunElapsed && ( ! this . props . loading || this . props . data ) ) ?
42
+ this . props . children :
43
+ < TintedHeader title = { this . props . title } />
44
+ }
45
+ </ div >
46
+ ) ;
47
+ }
48
+ }
49
+
50
+ export default LoadingLarge ;
You can’t perform that action at this time.
0 commit comments