diff options
author | Eugene Sokolov <eug-vs@keemail.me> | 2020-08-15 05:09:14 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-15 05:09:14 +0300 |
commit | 694918dcf0565e14dc4cba69e89907be9bed1544 (patch) | |
tree | ea5d41ef1878cef81d37125abe4a11d6018f130b /src/components | |
parent | 5ef1984e869529bdae38332c9ecf59661e08c364 (diff) | |
parent | f2ad02d1f2aa5acaac430148dadfd2abc9e671e0 (diff) | |
download | which-ui-694918dcf0565e14dc4cba69e89907be9bed1544.tar.gz |
Merge pull request #84 from which-ecosystem/dyno-wakeup
Wakeup dyno before showing layout
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/EmptyState/EmptyState.tsx | 24 | ||||
-rw-r--r-- | src/components/Loading/Loading.tsx | 23 | ||||
-rw-r--r-- | src/components/Message/Message.tsx | 42 |
3 files changed, 55 insertions, 34 deletions
diff --git a/src/components/EmptyState/EmptyState.tsx b/src/components/EmptyState/EmptyState.tsx index 214bb56..f79a391 100644 --- a/src/components/EmptyState/EmptyState.tsx +++ b/src/components/EmptyState/EmptyState.tsx @@ -1,6 +1,7 @@ import React from 'react'; -import Typography from '@material-ui/core/Typography'; import { makeStyles } from '@material-ui/core/styles'; + +import Message from '../Message/Message'; import noContentIcon from '../../assets/noContent.svg'; import constructionIcon from '../../assets/construction.svg'; @@ -11,17 +12,9 @@ interface PropTypes { } const useStyles = makeStyles(theme => ({ - root: { - display: 'flex', - flexDirection: 'column', - justifyContent: 'center', - alignItems: 'center' - }, img: { - margin: theme.spacing(2), width: theme.spacing(24) } - })); const CONTEXT = { @@ -37,21 +30,12 @@ const CONTEXT = { const EmptyState: React.FC<PropTypes> = ({ variant = 'default', message }) => { const classes = useStyles(); - const { icon, tagline } = CONTEXT[variant]; return ( - <div className={classes.root}> + <Message tagline={tagline} message={message}> <img src={icon} className={classes.img} alt="No content" /> - <Typography variant="h5"> - {tagline} - </Typography> - <Typography color="textSecondary"> - <p> - {message} - </p> - </Typography> - </div> + </Message> ); }; diff --git a/src/components/Loading/Loading.tsx b/src/components/Loading/Loading.tsx index 34d436b..fac0049 100644 --- a/src/components/Loading/Loading.tsx +++ b/src/components/Loading/Loading.tsx @@ -1,22 +1,17 @@ import React from 'react'; import CircularProgress from '@material-ui/core/CircularProgress'; -import { makeStyles } from '@material-ui/core'; +import Message from '../Message/Message'; -const useStyles = makeStyles(theme => ({ - loader: { - width: '100%', - textAlign: 'center', - marginTop: theme.spacing(10) - } -})); - -const Loading: React.FC = React.memo(() => { - const classes = useStyles(); +interface PropTypes { + tagline?: string; + message?: string; +} +const Loading: React.FC<PropTypes> = React.memo(({ tagline, message }) => { return ( - <div className={classes.loader}> - <CircularProgress color="primary" style={{ margin: '0 auto' }} /> - </div> + <Message tagline={tagline} message={message}> + <CircularProgress color="primary" /> + </Message> ); }); diff --git a/src/components/Message/Message.tsx b/src/components/Message/Message.tsx new file mode 100644 index 0000000..f568552 --- /dev/null +++ b/src/components/Message/Message.tsx @@ -0,0 +1,42 @@ +import React from 'react'; +import Typography from '@material-ui/core/Typography'; +import { makeStyles } from '@material-ui/core/styles'; + + +interface PropTypes { + tagline?: string; + message?: string; +} + +const useStyles = makeStyles(theme => ({ + root: { + display: 'flex', + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + marginTop: theme.spacing(6) + }, + content: { + margin: theme.spacing(2) + } +})); + +const Message: React.FC<PropTypes> = React.memo(({ tagline, message, children }) => { + const classes = useStyles(); + + return ( + <div className={classes.root}> + <div className={classes.content}> + {children} + </div> + <Typography variant="h5"> + {tagline} + </Typography> + <Typography color="textSecondary"> + {message} + </Typography> + </div> + ); +}); + +export default Message; |