aboutsummaryrefslogtreecommitdiff
path: root/src/components/Image/BackgroundImage.tsx
blob: 7d8e6e2522e10bebff6156e01315c93ee192b037 (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
import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import Image from './Image';

interface PropTypes {
  src?: string;
  alt?: string;
}

const useStyles = makeStyles({
  root: {
    position: 'absolute',
    width: '100%',
    height: '100%',
    overflow: 'hidden'
  },
  image: {
    objectFit: 'cover',
    pointerEvents: 'none',
    width: '100%',
    minHeight: '100%'
  }
});

const BackgroundImage: React.FC<PropTypes> = ({ src, alt }) => {
  const classes = useStyles();

  return (
    <div className={classes.root}>
      <Image src={src} alt={alt} className={classes.image} />
    </div>
  );
};

export default BackgroundImage;