File tree Expand file tree Collapse file tree 3 files changed +68
-0
lines changed
views/__backoffice/layouts Expand file tree Collapse file tree 3 files changed +68
-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
+
4
+ import { LinearProgress , withStyles } from '@material-ui/core' ;
5
+
6
+ class LinearDeterminate extends Component {
7
+ state = {
8
+ completed : 0 ,
9
+ } ;
10
+
11
+ componentDidMount ( ) {
12
+ this . timer = setInterval ( this . progress , 500 ) ;
13
+ }
14
+
15
+ componentWillUnmount ( ) {
16
+ clearInterval ( this . timer ) ;
17
+ }
18
+
19
+ progress = ( ) => {
20
+ const { completed } = this . state ;
21
+
22
+ if ( completed === 100 ) {
23
+ this . setState ( { completed : 0 } ) ;
24
+
25
+ return ;
26
+ }
27
+
28
+ const diff = Math . random ( ) * 10 ;
29
+
30
+ this . setState ( { completed : Math . min ( completed + diff , 100 ) } ) ;
31
+ } ;
32
+
33
+ render ( ) {
34
+ const { classes } = this . props ;
35
+ const { completed } = this . state ;
36
+
37
+ return (
38
+ < div className = { classes . root } >
39
+ < LinearProgress
40
+ variant = "determinate"
41
+ value = { completed }
42
+ { ...this . props }
43
+ />
44
+ </ div >
45
+ ) ;
46
+ }
47
+ }
48
+
49
+ LinearDeterminate . propTypes = {
50
+ classes : PropTypes . object . isRequired ,
51
+ } ;
52
+
53
+ const styles = {
54
+ root : {
55
+ flexGrow : 1 ,
56
+ } ,
57
+ } ;
58
+
59
+ export default withStyles ( styles ) ( LinearDeterminate ) ;
Original file line number Diff line number Diff line change
1
+ export { default as LinearDeterminate } from './LinearDeterminate' ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
11
11
} from '@material-ui/core' ;
12
12
13
13
import { Snackbar , Modal } from '../../../ui' ;
14
+ import { LinearDeterminate } from '../../../ui/Loaders' ;
14
15
import { Header , Sidebar } from '../partials' ;
15
16
16
17
class Master extends Component {
@@ -60,6 +61,7 @@ class Master extends Component {
60
61
message,
61
62
alert,
62
63
} = this . props ;
64
+ const { navigating } = pageProps ;
63
65
64
66
const { mobileOpen } = this . state ;
65
67
@@ -78,6 +80,8 @@ class Master extends Component {
78
80
79
81
return (
80
82
< >
83
+ { navigating && < LinearDeterminate className = { classes . loader } /> }
84
+
81
85
< div className = { classes . root } >
82
86
< CssBaseline />
83
87
@@ -163,6 +167,10 @@ Master.propTypes = {
163
167
const drawerWidth = 256 ;
164
168
165
169
const styles = theme => ( {
170
+ loader : {
171
+ zIndex : 9999 ,
172
+ } ,
173
+
166
174
root : {
167
175
display : 'flex' ,
168
176
position : 'relative' ,
You can’t perform that action at this time.
0 commit comments