From bf47681e325e18edb3b5bfa4c655095189697e8b Mon Sep 17 00:00:00 2001 From: eug-vs Date: Sat, 15 Aug 2020 03:48:53 +0300 Subject: refactor: separate Message component --- src/components/EmptyState/EmptyState.tsx | 24 +++------------ src/components/Loading/Loading.tsx | 23 ++++++-------- src/components/Message/Message.tsx | 42 ++++++++++++++++++++++++++ src/containers/Notifications/Notifications.tsx | 2 +- 4 files changed, 56 insertions(+), 35 deletions(-) create mode 100644 src/components/Message/Message.tsx (limited to 'src') 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 = ({ variant = 'default', message }) => { const classes = useStyles(); - const { icon, tagline } = CONTEXT[variant]; return ( -
+ No content - - {tagline} - - -

- {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 = React.memo(({ tagline, message }) => { return ( -
- -
+ + + ); }); 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 = React.memo(({ tagline, message, children }) => { + const classes = useStyles(); + + return ( +
+
+ {children} +
+ + {tagline} + + + {message} + +
+ ); +}); + +export default Message; diff --git a/src/containers/Notifications/Notifications.tsx b/src/containers/Notifications/Notifications.tsx index 2a9ea13..655e7be 100644 --- a/src/containers/Notifications/Notifications.tsx +++ b/src/containers/Notifications/Notifications.tsx @@ -4,7 +4,7 @@ import EmptyState from '../../components/EmptyState/EmptyState'; const useStyles = makeStyles(theme => ({ root: { - marginTop: theme.spacing(25) + marginTop: theme.spacing(16) } })); -- cgit v1.2.3