aboutsummaryrefslogtreecommitdiff
path: root/src/components/EmptyState/EmptyState.tsx
blob: 7167ba203eedf374d63fc18a4850c5ecc4c9ca2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';

import Image from '../Image/Image';
import Message from '../Message/Message';
import noContentIcon from '../../assets/noContent.svg';
import constructionIcon from '../../assets/construction.svg';
import serverIcon from '../../assets/server.svg';
import errorIcon from '../../assets/error.svg';


interface PropTypes {
  variant?: 'default' | 'construction' | 'waiting' | 'error';
  message?: string;
  smart?: boolean;
}

const useStyles = makeStyles(theme => ({
  img: {
    width: theme.spacing(24)
  }
}));

const CONTEXT = {
  default: {
    icon: noContentIcon,
    tagline: 'No content'
  },
  construction: {
    icon: constructionIcon,
    tagline: 'Coming soon'
  },
  waiting: {
    icon: serverIcon,
    tagline: 'Waiting for server'
  },
  error: {
    icon: errorIcon,
    tagline: 'Something went wrong'
  }
};

const EmptyState: React.FC<PropTypes> = ({ variant = 'default', smart = false, message }) => {
  const classes = useStyles();
  const { icon, tagline } = CONTEXT[variant];

  const Component = smart ? Image : 'img';

  return (
    <Message tagline={tagline} message={message}>
      <Component src={icon} className={classes.img} alt="No content" />
    </Message>
  );
};

export default EmptyState;