aboutsummaryrefslogtreecommitdiff
path: root/src/components/Image/BackgroundImage.tsx
diff options
context:
space:
mode:
authoreug-vs <eug-vs@keemail.me>2020-08-14 15:36:17 +0300
committereug-vs <eug-vs@keemail.me>2020-08-14 15:36:17 +0300
commitfc95e83e704ec054f551bae587a8a6e5bcaf4135 (patch)
tree195777b0bb4f15719c80d1d407d41fd56f55f3d9 /src/components/Image/BackgroundImage.tsx
parent1d35dd8a80f0ea72306e96c2229a27798ec75ce9 (diff)
downloadwhich-ui-fc95e83e704ec054f551bae587a8a6e5bcaf4135.tar.gz
feat: create Image and BackgroundImage components
Diffstat (limited to 'src/components/Image/BackgroundImage.tsx')
-rw-r--r--src/components/Image/BackgroundImage.tsx35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/components/Image/BackgroundImage.tsx b/src/components/Image/BackgroundImage.tsx
new file mode 100644
index 0000000..824f667
--- /dev/null
+++ b/src/components/Image/BackgroundImage.tsx
@@ -0,0 +1,35 @@
+import React from 'react';
+import { makeStyles } from '@material-ui/core/styles';
+import Image from './Image';
+
+interface PropTypes {
+ src?: string;
+ alt?: string;
+}
+
+const useStyles = makeStyles(theme => ({
+ root: {
+ position: 'absolute',
+ width: '100%',
+ height: '100%'
+ },
+ image: {
+ objectFit: 'cover',
+ pointerEvents: 'none',
+ width: '100%',
+ height: '100%'
+ }
+}));
+
+const BackgroundImage: React.FC<PropTypes> = ({ src, alt }) => {
+ const classes = useStyles();
+
+ return (
+ <picture className={classes.root}>
+ <Image src={src} alt={alt} className={classes.image} />
+ </picture>
+ )
+}
+
+export default BackgroundImage;
+