File tree Expand file tree Collapse file tree 3 files changed +46
-8
lines changed Expand file tree Collapse file tree 3 files changed +46
-8
lines changed Original file line number Diff line number Diff line change
1
+ import React from "react" ;
2
+ import PropTypes from "prop-types" ;
3
+ import { withStyles , createStyles } from "@material-ui/core/styles" ;
4
+ import CircularProgress from "@material-ui/core/CircularProgress" ;
5
+
6
+ const Loader = props => {
7
+ const { loaded, classes } = props ;
8
+ if ( loaded ) {
9
+ return props . children ;
10
+ }
11
+ return (
12
+ < div className = { classes . root } >
13
+ < CircularProgress size = { 100 } />
14
+ </ div >
15
+ ) ;
16
+ } ;
17
+
18
+ Loader . propTypes = {
19
+ loaded : PropTypes . bool ,
20
+ children : PropTypes . element ,
21
+ classes : PropTypes . objectOf ( PropTypes . string )
22
+ } ;
23
+
24
+ const styles = theme =>
25
+ createStyles ( {
26
+ root : {
27
+ display : "flex" ,
28
+ justifyContent : "center" ,
29
+ alignItems : "center" ,
30
+ paddingTop : theme . spacing ( 8 )
31
+ }
32
+ } ) ;
33
+
34
+ export default withStyles ( styles ) ( Loader ) ;
Original file line number Diff line number Diff line change @@ -7,11 +7,13 @@ import Typography from "@material-ui/core/Typography";
7
7
import PreferenceForm from "./PreferenceForm" ;
8
8
import Preview from "./Preview" ;
9
9
import ErrorSnackbar from "./ErrorSnackbar" ;
10
+ import Loader from "./Loader" ;
10
11
import { loadPreferences , savePreferences } from "../ipfs/preferences" ;
11
12
12
13
const DEFAULT_CID = "QmYiGo3KpK5Ca928ujpH2MKJgVEkLE981gj1QERYC5h8e8" ;
13
14
class Main extends React . Component {
14
15
state = {
16
+ ipfsLoaded : false ,
15
17
cid : "" ,
16
18
preferences : {
17
19
username : "" ,
@@ -61,7 +63,8 @@ class Main extends React.Component {
61
63
this . setState ( {
62
64
cid,
63
65
preferences,
64
- justLoaded : true
66
+ justLoaded : true ,
67
+ ipfsLoaded : true
65
68
} ) ;
66
69
} ;
67
70
@@ -104,7 +107,6 @@ class Main extends React.Component {
104
107
< Typography variant = "h4" gutterBottom >
105
108
IPFS Portable User Settings
106
109
</ Typography >
107
- { /* <div className={classes.main}> */ }
108
110
< Grid container spacing = { 3 } >
109
111
< Grid item sm = { 12 } md = { 6 } >
110
112
< PreferenceForm
@@ -119,13 +121,14 @@ class Main extends React.Component {
119
121
/>
120
122
</ Grid >
121
123
< Grid item sm = { 12 } md = { 6 } >
122
- < Preview
123
- cid = { this . state . cid }
124
- preferences = { this . state . preferences }
125
- />
124
+ < Loader loaded = { this . state . ipfsLoaded } >
125
+ < Preview
126
+ cid = { this . state . cid }
127
+ preferences = { this . state . preferences }
128
+ />
129
+ </ Loader >
126
130
</ Grid >
127
131
</ Grid >
128
- { /* </div> */ }
129
132
< ErrorSnackbar
130
133
error = { this . state . error }
131
134
onClose = { this . handleErrorClose }
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ SubmitButton.propTypes = {
27
27
textNormal : PropTypes . string . isRequired ,
28
28
textSubmitted : PropTypes . string . isRequired ,
29
29
icon : PropTypes . element ,
30
- submitted : PropTypes . bool
30
+ submitted : PropTypes . bool ,
31
+ classes : PropTypes . objectOf ( PropTypes . string )
31
32
} ;
32
33
33
34
const styles = theme =>
You can’t perform that action at this time.
0 commit comments